12-11-2016, 03:51 PM
(This post was last modified: 12-11-2016, 03:54 PM by frenchie71.)
OK, so here are first test results - Step 1 was to use existing components and solutions in order to PoC the principle (i.e. see if it is possible to use a pilight nano over Wifi). The test installation consists of:
- an ESP8266 module
- an Arduino mini
- an RXB8 433 MHz receiver
- dual power supply (7805-5V and 1117-3.3V)
Initially I thought I'd do a simple ser2net on the esp8266 but thinking it over there would have been so many things to figure out in the future (how would you flash the arduino once it's in circuit, how would you give people a possibility to change the SSID without hardcoding it etc.). After having looked around a bit I found a really excellent Serial over Wifi Implementation on github called esp-link. This software has a built in Webserver which allows you to put in all necessary parameters. In order to do so, it spawns a Wifi access point after boot which you connect to, you then open the web page on http://192.168.4.1 and put in SSID etc. It also supports flashing the Arduino over the air (OTA). Really cool.
OK let's walk this through. There are ready made images for installation. For our first tests they will do. We do not want to change software yet. We do need the packages and then we need to flash them to the ESP8266. I followed the howto in esp-link documentaion on github
We now have a functional esp-link on the esp8266 module. Once you hook it up to power it will spawn an access point and you can connect to it with your web browser.
I have used a standard UART in order to program the esp, but afterwards I found that there are nice USB sticks which contain the UART and a socket for the esp module (the esp8266 module I used is not breadboard-friendly). I'll post photos in a later reply.
The second attachment shows the circuit diagram which I built on a stripboard. Once the esp8266 is connected to the Arduino mini, we can actually flash the Arduino mini OTA! Alternatively you can of course flash it using UART and then put it into circuit (in the example the esp has an IP address of 192.168.10.10 - you need to put in yours of course)
I couldn't get avrdude to program the mini, so I used the provided avrflash utility that came with esp-link and worked like a charm:
and - voila, we have a fully operational pilight nano over Wifi.
Now we need to tell pilight-daemon how to talk to it. In order to do so we use a software called socat which is capable of linking a network socket to a file. socat is available as a package for OpenWRT. So on the router:
Of course you need to match the device name in /etc/pilight/config.json
I have tested this with a receiver only. Haven't done any tests with senders yet. A couple of questions remain open such as the behavior of socat when the socket goes away (as we are using TCP, the socket becomes invalid once the ESP module disconnects. May be an alternative to use a watchdog loop or switch to UDP...)
fotos attached
- an ESP8266 module
- an Arduino mini
- an RXB8 433 MHz receiver
- dual power supply (7805-5V and 1117-3.3V)
Initially I thought I'd do a simple ser2net on the esp8266 but thinking it over there would have been so many things to figure out in the future (how would you flash the arduino once it's in circuit, how would you give people a possibility to change the SSID without hardcoding it etc.). After having looked around a bit I found a really excellent Serial over Wifi Implementation on github called esp-link. This software has a built in Webserver which allows you to put in all necessary parameters. In order to do so, it spawns a Wifi access point after boot which you connect to, you then open the web page on http://192.168.4.1 and put in SSID etc. It also supports flashing the Arduino over the air (OTA). Really cool.
OK let's walk this through. There are ready made images for installation. For our first tests they will do. We do not want to change software yet. We do need the packages and then we need to flash them to the ESP8266. I followed the howto in esp-link documentaion on github
Code:
# get the images from github
wget https://github.com/jeelabs/esp-link/releases/download/v2.2.3/esp-link-v2.2.3.tgz | tar xzf -
cd esp-link-v2.2.3
wget https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py
cd ..
# now let's get the esptool
git clone https://github.com/themadinventor/esptool.git
cd esptool
# install esptool
python setup.py install
cd ../esp-link-v2.2.3
# now let's burn the images to the ESP8266 module
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash -fs 32m -ff 80m 0x00000 boot_v1.5.bin 0x1000 user1.bin 0x3FE000 blank.bin
We now have a functional esp-link on the esp8266 module. Once you hook it up to power it will spawn an access point and you can connect to it with your web browser.
I have used a standard UART in order to program the esp, but afterwards I found that there are nice USB sticks which contain the UART and a socket for the esp module (the esp8266 module I used is not breadboard-friendly). I'll post photos in a later reply.
The second attachment shows the circuit diagram which I built on a stripboard. Once the esp8266 is connected to the Arduino mini, we can actually flash the Arduino mini OTA! Alternatively you can of course flash it using UART and then put it into circuit (in the example the esp has an IP address of 192.168.10.10 - you need to put in yours of course)
I couldn't get avrdude to program the mini, so I used the provided avrflash utility that came with esp-link and worked like a charm:
Code:
avrflash -v 192.168.10.10 pilight_usb_nano.hex
and - voila, we have a fully operational pilight nano over Wifi.
Now we need to tell pilight-daemon how to talk to it. In order to do so we use a software called socat which is capable of linking a network socket to a file. socat is available as a package for OpenWRT. So on the router:
Code:
# fork execute socat but be verbose
socat -d -d pty,link=/dev/ttyUSB3,raw,echo=0 tcp:192.168.10.10:23 &disown
# this links /dev/ttyUSB3 to /dev/pts/1 to 192.168.10.10:23
# now run the pilight Daemon
pilight-daemon -D
I have tested this with a receiver only. Haven't done any tests with senders yet. A couple of questions remain open such as the behavior of socat when the socket goes away (as we are using TCP, the socket becomes invalid once the ESP module disconnects. May be an alternative to use a watchdog loop or switch to UDP...)
fotos attached