diff --git a/examples/ESP8266MeshHelloWorld/README.md b/examples/ESP8266MeshHelloWorld/README.md index 82f4b71..2e465b5 100644 --- a/examples/ESP8266MeshHelloWorld/README.md +++ b/examples/ESP8266MeshHelloWorld/README.md @@ -2,11 +2,35 @@ This is a trivial node that can be used to test the mesh network. -## Configuration -a sample configuration is provided in `src/credentials.h.example`. +![](http://i.imgur.com/w0uKBjU.png) + +If nodes can see the router, they communicate directly (Ex: 1 ->2). If not, they pass messages via the mesh network to other nodes. (Ex: 1 -> 2 -> 3) + +## QUICKSTART +This describes one fast and easy way to get started, though there are other options. + +You will require: +- A wirless router, with a dedicated secured (WPA2, AES) 2.4Ghz network, set to control channel 1 (2.412 Ghz), auto 20/40Mhz mode +- A computer (Linux or Windows tested) connected to the above network +- 1 or more ESP8266 chips to test with -1) First copy `src/credentials.h.example` to `src/credentials.h` -2) Edit `credentials.h` and modify the configuration to suit your environment +1) Install the IDE: PlatformIO on the computer http://platformio.org/get-started/ide?install=atom +1b) Install the ESP8266MQTTMesh Library. PlatfromIO Home -> Libraries -> Search -> ```ESP8266MQTTMesh``` -> Install\ +This should automatically install all necessary pre-requisites. +2) Install the MQTT Broker: Mosquitto and all pre-requisites https://mosquitto.org/download/ +3) Install the MQTT UI/Monitor: MQTT.fx http://www.mqttfx.org/ +4) Install Python, and paho-mqtt. In Windows: ```python -m pip install paho-mqtt``` This is needed for OTA updates. +5) In Windows, add outgoing and incoming firewall rules to allow ports 1883 and optionally 1884 +6) Start the Mosquitto Broker. In Windows, start a administrator command prompt, navigate to C:\Program Files (x86)\mosquitto and type in ```net start mosquitto``` +7) Start MQTT.fx and click connect. Button on the right should turn green. Go to the subscribe tab, and click scan under topics collector +8) Connect an ESP8266 module to the computer and Open this example in PlatformIO. Edit the example Configuration as detailed below in the Configuration section. Click Build and ensure that everything works. Then click Upload. If Uploading fails, ensure that the driver for the USB->Serial converter you are using is happy, and that the proper COM port has been selected in PlatformIO. +9) Start the Serial Monitor in PlatformIO to see debug messages as needed. +10) You should now see Topics appearing in MQTT.fx window from step 7). Clicking on a topic should show data +![](http://i.imgur.com/ucylCqR.png) +11) Publishing data to a node can also be done through the UI by selecting the esp8266-in/* topic that matches the esp8266-out/* topic seen in the subscribe window. + +## Configuration +Edit `credentials.h` and modify the configuration to suit your environment The following variables should be set: - *NETWORK_LIST* : Specifies the SSIDs of your wireless network @@ -26,7 +50,6 @@ These options are only relevant if the node is compiled with SSL enabled: ## Compiling and uploading This example has been designed to use platformio for building and install -Assuming you have already setup a platformio environment: ### Non-SSL `platformio run --target upload` @@ -39,3 +62,10 @@ Assuming you have already setup a platformio environment: #### Upload firmware `platformio run -e ssl --target upload` +## OTA (Over the Air, wireless firware Update) (Work in Progress) +PlatformIO stores compiled binaries by default in the same folder as the project. Navigate to ```YOURPROJECTNAME\.pioenvs\esp12e``` and copy firmware.bin. +This repository contains ```send_ota.py``` under utils. Copy this file to the same location as the firmware.bin +To run a OTA example, you can run: (Assuming Windows, and the firmware id is left unchanged from this example) +```python send_ota.py --bin firmware.bin --id 0x1337``` +This *should* update all nodes in the network. + diff --git a/examples/ESP8266MeshHelloWorld/src/ESP8266MeshHelloWorld.ino b/examples/ESP8266MeshHelloWorld/src/ESP8266MeshHelloWorld.cpp similarity index 94% rename from examples/ESP8266MeshHelloWorld/src/ESP8266MeshHelloWorld.ino rename to examples/ESP8266MeshHelloWorld/src/ESP8266MeshHelloWorld.cpp index c9cace7..8a6ec43 100644 --- a/examples/ESP8266MeshHelloWorld/src/ESP8266MeshHelloWorld.ino +++ b/examples/ESP8266MeshHelloWorld/src/ESP8266MeshHelloWorld.cpp @@ -1,3 +1,4 @@ +#include #include "credentials.h" #include #include diff --git a/examples/ESP8266MeshHelloWorld/src/credentials.h.example b/examples/ESP8266MeshHelloWorld/src/credentials.h similarity index 100% rename from examples/ESP8266MeshHelloWorld/src/credentials.h.example rename to examples/ESP8266MeshHelloWorld/src/credentials.h