Sonnerie connecté
NodeMCU
Installation
Inclure la bibliothèque
"ESP8266WiFi"
const char *ssid = "ASUS";
const char *pass = "simplonco";
-
Afficher "Connecting to: "
-
Afficher la variable ssid
while (WiFi.status() != WL_CONNECTED) {
}
WiFi.begin(ssid, pass);
Récupérer l'adresse IP
WiFi.localIP()
-
Afficher "Wifi connected"
-
Afficher l'adresse IP
bool button;
button = digitalRead(pinNumber);
Afficher "Dring" quand on appuie sur le boutton
MQTT
Installer la bibliothèque
"pubsubclient" de Imroy
ifconfig
IPAddress server(192, 168, 1, 136);
WiFiClient wclient;
PubSubClient client(wclient, server);
client.connect("Boutton");
client.publish("maison","dring");
delay(2000);
NodeJS
-
Installer NVM
-
Ouvrir un nouveau terminal
-
nvm install 6
npm install -g mosca
mosca -v
npm install mqtt
var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://localhost')
var mqtt = require('mqtt');
var client = mqtt.connect('mqtt://localhost');
client.on('connect', function () {
});
client.subscribe('maison');
client.on('message', function (topic, message) {
});
console.log(message);
npm install nodemailer
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'yassin@simplon.co',
pass: 'XXXXX'
}
});
transporter.sendMail({
from: 'yassin@simplon.co',
to: 'enzo@simplon.co',
subject: 'Driing !',
text: 'Une personne sonne à la porte'
});
Copy of Sonnerie connecté
By juliegarnier
Copy of Sonnerie connecté
- 893