• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


pilight nano usb over Wifi for routers without USB port
#5
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

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
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


Attached Files
.jpg   esp_circuit.jpg (Size: 190.72 KB / Downloads: 36)
.jpg   stripboard_espremoved.jpg (Size: 308.36 KB / Downloads: 32)
.jpg   stripboard.jpg (Size: 242.21 KB / Downloads: 31)
.jpg   uart_stick.jpg (Size: 127.63 KB / Downloads: 28)
 
Reply
  


Messages In This Thread
RE: pilight nano usb over Wifi for routers without USB port - by frenchie71 - 12-11-2016, 03:51 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  pilight DIY PCB Kits curlymo 63 35,521 10-22-2019, 02:09 AM
Last Post: pusky
  pilight 8.0 / wiringx / receive ATTINY-TX wupperpi 5 1,511 01-18-2018, 02:24 PM
Last Post: wupperpi
  pilight, Raspberry Pi and sensors for sale kid2000 0 1,536 04-07-2017, 05:04 PM
Last Post: kid2000
  433Mhz Wifi Gateway ripper121 5 3,624 03-13-2017, 10:25 AM
Last Post: ripper121
  parts for pilight rikeshe 4 2,087 12-10-2016, 09:02 PM
Last Post: rikeshe
  Arduino nano with CC1101 ? Bootscreen 5 3,309 11-04-2016, 03:38 PM
Last Post: curlymo
  No pilight-[debug/raw/learn] signals received bassabaws 8 7,177 04-14-2016, 11:35 PM
Last Post: wo_rasp
  Experiences with the pilight DIY PCB Kits troccolo 112 38,710 03-05-2016, 11:21 AM
Last Post: curlymo
  Use existing wall switch with correct status in pilight? kylex 0 1,446 01-13-2016, 01:27 AM
Last Post: kylex
  For Sale own-made pilight shield. Luppie 3 3,026 10-31-2015, 11:23 AM
Last Post: Luppie

Forum Jump:


Browsing: 1 Guest(s)