This code beeping beeps!
This commit is contained in:
parent
9a64876f07
commit
4a4ddc1d28
|
@ -14,6 +14,10 @@
|
||||||
#define mqtt_user SECRET_MQTT_USER
|
#define mqtt_user SECRET_MQTT_USER
|
||||||
#define mqtt_password SECRET_MQTT_PASS
|
#define mqtt_password SECRET_MQTT_PASS
|
||||||
|
|
||||||
|
|
||||||
|
#define window_name "window_0"
|
||||||
|
#define mqtt_root "/house/upstairs_lab/actuators/" window_name
|
||||||
|
|
||||||
#define in_topic "/testing/in"
|
#define in_topic "/testing/in"
|
||||||
#define out_topic "/testing/out"
|
#define out_topic "/testing/out"
|
||||||
// Replace by 2 if you aren't enable to use Serial Monitor... Don't forget to Rewire R1 to GPIO2!
|
// Replace by 2 if you aren't enable to use Serial Monitor... Don't forget to Rewire R1 to GPIO2!
|
||||||
|
@ -38,7 +42,7 @@ void setup_wifi() {
|
||||||
delay(10);
|
delay(10);
|
||||||
// We start by connecting to a WiFi network
|
// We start by connecting to a WiFi network
|
||||||
Serial.println();
|
Serial.println();
|
||||||
WiFi.hostname("ESP-Test1");
|
WiFi.hostname("ESP-" window_name);
|
||||||
Serial.print("Connecting to ");
|
Serial.print("Connecting to ");
|
||||||
Serial.println(wifi_ssid);
|
Serial.println(wifi_ssid);
|
||||||
|
|
||||||
|
@ -60,8 +64,6 @@ void reconnect() {
|
||||||
while (!client.connected()) {
|
while (!client.connected()) {
|
||||||
Serial.print("Attempting MQTT connection...");
|
Serial.print("Attempting MQTT connection...");
|
||||||
// Attempt to connect
|
// Attempt to connect
|
||||||
// If you do not want to use a username and password, change next line to
|
|
||||||
// if (client.connect("ESP8266Client")) {
|
|
||||||
if (client.connect("ESP8266Client", mqtt_user, mqtt_password)) {
|
if (client.connect("ESP8266Client", mqtt_user, mqtt_password)) {
|
||||||
Serial.println("connected");
|
Serial.println("connected");
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,5 +100,6 @@ void loop() {
|
||||||
client.publish(out_topic, String(random(2)).c_str(), true);
|
client.publish(out_topic, String(random(2)).c_str(), true);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
client.subscribe(in_topic);
|
client.subscribe(in_topic);
|
||||||
|
tone(2, 2000, 500);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue