UPDATE: The official build guide for the ESP8266 gateway can now be found here.
The description in this post is for reference only!
Please find an early release of ESP8266 gateway support in my MySensors 1.5 branch:
https://github.com/Yveaux/Arduino
It has not been tested heavily, but seems to run stable at least with one sensor.
Great feature of this setup is you can run a WiFi gateway with just an ESP8266 and nRF24L01+ radio, no further Arduino (ATMega328) is required!
I'm releasing this now, hoping you can start experimenting with it and help development to get to a stable, official release asap.
Setting things up:
- Install Arduino IDE 1.6.5
- Add support for ESP8266 to Arduino, see https://github.com/esp8266/Arduino (Installing with Boards Manager)
- Get the code form my fork https://github.com/Yveaux/Arduino/archive/master.zip and extract the zip
- Edit libraries/MySensors/MyConfig.h when you use e.g. a different datarate, channel or base radio ID.
- Point your Arduino configuration to the extracted dir (File -> Preferences -> Sketchbook location)
- Restart the Arduino IDE
Compiling the gateway:
- Open the WiFi gateway in the Arduino IDE (File -> Sketchbook -> Libraries -> MySensors -> Esp8266Gateway
- Save it, to allow editing
- Enter your SSID and WiFi password in the 'ssid' and 'pass' variables
- Select the ESP8266 board you're targeting in Tools -> Board. I use an ESP12 module, which is a 'Generic ESP8266 Module' board target
- Verify your sketch. It should compile without errors.
Connecting the radio:
- Make sure to use an ESP8266 module which breaks out pins GPIO 4, 12, 13, 14, 15 (e.g. ESP12 module)
- Connect the radio as described in the header of the gateway code.
- Connect the other signals as described in the header of the gateway code.
- I mounted two switches (for reset & bootload) which your ESP8266 may already be equipped with (e.g. the NodeMCU boards have them most of the time)
- I use an FTDI USB->Serial converter to connect the ESP8266 to my PC, which outputs levels at 3.3V. This is very important as the ESP8266 cannot officially handle 5V signals, and cheap USB->Serial converters often output at 5V levels. When in doubt, please check before connecting!
- Power both the ESP8266 and the nRF24L01+ from a separate 3.3V power supply. The 3.3V supply from many USB->Serial converters is often too weak.
- Decouple the power supply with a large capacitor (e.g. 1000uF) and 100nF, to buffer the input and suppress any noise.
Downloading your sketch:
-
Start wit a low upload speed (e.g. 9600baud). It will take ages to download, but I sometimes have issues downloading at high speeds.
-
Press reset + bootload buttons.
-
Keep bootload pressed while releasing reset
-
After a few seconds release bootload.
-
The ESP8266 is now in bootload mode, and ready to download your code.
-
Choose Upload in the Arduino IDE
-
After some time (a lot of dots) upload should finish and your code starts. The serial monitor (115200 baud) shows the progress:
ESP8266 MySensors Gateway Connecting to SSID ...........Connected! IP: 192.168.1.119 0;0;3;0;9;gateway started, id=0, parent=0, distance=0 0;0;3;0;9;read: 123-123-0 s=1,c=1,t=24,pt=5,l=4,sg=0:2810347 123;1;1;0;24;2810347
-
This text will be preceded by some garbage from the bootloader (it outputs at a lower baudrate)
-
The IP address of the WiFI gateway will currently be obtained from a DHCP server.
Now connect a telnet session (e.g. putty) to the IP address mentioned in the serial output (192.168.1.119 in this case), port 5003 and send some serial commands!