From 99a1b0ec0dcad73c2ce22238626afa36cb777798 Mon Sep 17 00:00:00 2001 From: Steven Reagan Date: Sun, 27 Sep 2020 09:42:04 -0700 Subject: [PATCH 1/2] Updated sketch to work with new Arduino library and remove adafruit MQTT configuration --- Classroom_Period_Timer_CONFIGURE.ino | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Classroom_Period_Timer_CONFIGURE.ino b/Classroom_Period_Timer_CONFIGURE.ino index 720d6c3..a5228ad 100644 --- a/Classroom_Period_Timer_CONFIGURE.ino +++ b/Classroom_Period_Timer_CONFIGURE.ino @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -14,11 +15,12 @@ /***************** LED LAYOUT AND SETUP *********************************/ #define NUM_LEDS 57 +#define MQTT_TOPIC_NAME /***************** WIFI AND CLOUDMQTT SETUP *****************************/ const char* ssid = "YOURSSID"; const char* password = "YOURWIFIPW"; -const char* mqtt_server = "io.adafruit.com"; +const char* mqtt_server = "ip.of.mqtt.broker"; const int mqtt_port = 1883; const char *mqtt_user = "YOURMQTTUSER"; const char *mqtt_pass = "YOURMQTTPW"; @@ -32,7 +34,7 @@ CRGB leds[NUM_LEDS]; /***************** GLOBAL VARIABLES ************************************/ -const int ledPin = 4; //marked as D2 on the board +const int ledPin = 5; //marked as D1 on the board int totalMinutes = 0; int ledsRemaining = 0; @@ -80,14 +82,14 @@ void reconnect() Serial.println("connected"); if(boot == true) { - client.publish("ADAFRUIT_USER/feeds/status","Rebooted"); + client.publish(MQTT_TOPIC_NAME"/feeds/status","Rebooted"); boot = false; } if(boot == false) { - client.publish("ADAFRUIT_USER/feeds/status","Reconnected"); + client.publish(MQTT_TOPIC_NAME"/feeds/status","Reconnected"); } - client.subscribe("ADAFRUIT_USER/feeds/bells"); + client.subscribe(MQTT_TOPIC_NAME"/feeds/bells"); } } } @@ -124,7 +126,7 @@ void subtractInterval() void checkIn() { - client.publish("ADAFRUIT_USER/feeds/status","OK"); + client.publish(MQTT_TOPIC_NAME"/feeds/status","OK"); } /***************** SETUP FUNCTIONS ****************************************/ @@ -134,15 +136,14 @@ void setup() { Serial.begin(115200); WiFi.setSleepMode(WIFI_NONE_SLEEP); - FastLED.addLeds(leds, NUM_LEDS); + FastLED.addLeds(leds, NUM_LEDS); // GPIO Pin Setup - WiFi.mode(WIFI_STA); setup_wifi(); client.setServer(mqtt_server, mqtt_port); client.setCallback(callback); timer.setInterval(90000, checkIn); - ArduinoOTA.setHostname("classroom227"); + ArduinoOTA.setHostname(mqtt_client_name); ArduinoOTA.begin(); } @@ -176,4 +177,3 @@ void ledTimer() leds[i] = CHSV (colorLED,255,192); } } - From 8821e7e55baff5b21fc7a1b1d252ca748b0dd6e6 Mon Sep 17 00:00:00 2001 From: Steven Reagan Date: Sun, 27 Sep 2020 09:42:04 -0700 Subject: [PATCH 2/2] Updated sketch to work with new Arduino library and remove adafruit MQTT configuration --- Classroom_Period_Timer_CONFIGURE.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classroom_Period_Timer_CONFIGURE.ino b/Classroom_Period_Timer_CONFIGURE.ino index a5228ad..42e0903 100644 --- a/Classroom_Period_Timer_CONFIGURE.ino +++ b/Classroom_Period_Timer_CONFIGURE.ino @@ -15,7 +15,7 @@ /***************** LED LAYOUT AND SETUP *********************************/ #define NUM_LEDS 57 -#define MQTT_TOPIC_NAME +#define MQTT_TOPIC_NAME "MQTT-Topic" /***************** WIFI AND CLOUDMQTT SETUP *****************************/ const char* ssid = "YOURSSID"; @@ -54,6 +54,7 @@ void setup_wifi() Serial.print("Connecting to "); Serial.println(ssid); + WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) {