This code beeping beeps!

This commit is contained in:
Kenwood 2021-04-27 17:05:14 -04:00
parent 9a64876f07
commit 4a4ddc1d28
1 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,10 @@
#define mqtt_user SECRET_MQTT_USER
#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 out_topic "/testing/out"
// 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);
// We start by connecting to a WiFi network
Serial.println();
WiFi.hostname("ESP-Test1");
WiFi.hostname("ESP-" window_name);
Serial.print("Connecting to ");
Serial.println(wifi_ssid);
@ -60,8 +64,6 @@ void reconnect() {
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// 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)) {
Serial.println("connected");
} else {
@ -98,5 +100,6 @@ void loop() {
client.publish(out_topic, String(random(2)).c_str(), true);
delay(1000);
client.subscribe(in_topic);
tone(2, 2000, 500);
delay(1000);
}