Skip to content

Commit

Permalink
Enable ArduinoOTA
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Jan 21, 2017
1 parent 164198b commit d147c9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,7 @@ A sketch for the NodeMCU/ESP8266 which allows controlling a Seville Classics Ult
3. Change `config.h` to match your settings.
4. Ensure all required libraries are loaded in the Arduino IDE:
- [ArduinoJSON](https://github.com/bblanchon/ArduinoJson)
- [ArduinoOTA](https://github.com/esp8266/Arduino/tree/master/libraries/ArduinoOTA)
- [IRemoteESP8266](https://github.com/markszabo/IRremoteESP8266)
- [PubSubClient](https://github.com/knolleary/pubsubclient)
5. Load the sketch.
Expand All @@ -23,6 +24,7 @@ A sketch for the NodeMCU/ESP8266 which allows controlling a Seville Classics Ult
- The red LED flashes everytime a message is sent via MQTT.
- The red LED will stay solid if the board is disconnected from wifi.
- The blue LED will blink anytime IR data is emitted.
- ArduinoOTA is enabled allowing you to upload new versions without needing to plug into a computer. See [the docs](http://esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html#arduino-ide) for more information.

# Topics
| Name | Default State Topic | Default Command Topic | Defined as | Accepts | Description |
Expand Down
8 changes: 8 additions & 0 deletions Seville-MQTT.ino
Expand Up @@ -7,6 +7,7 @@
#include <PubSubClient.h>
#include <IRremoteESP8266.h>
#include <ArduinoJson.h>
#include <ArduinoOTA.h>

#include "config.h"

Expand Down Expand Up @@ -202,6 +203,12 @@ void setup() {
msg.wind = 3; // 1 = normal, 2 = sleeping, 3 = natural

setup_wifi();

char hostname[20];
sprintf(hostname, "Seville-MQTT-%06x", ESP.getChipId());

ArduinoOTA.setHostname(hostname);
ArduinoOTA.begin();
}

void setup_wifi() {
Expand Down Expand Up @@ -286,6 +293,7 @@ void loop() {
delay(REST); // take a rest...
reconnect();
}
ArduinoOTA.handle();
client.loop();
}

Expand Down

0 comments on commit d147c9a

Please sign in to comment.