• 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
#1
Hi everybody,

this project contains so many cool things such as port to OpenWRT, pilight Nano USB etc. etc. etc.

While I spent a big part of this week-end to set up my router with OpenWRT and pilight I thought "hmmm... how would you do that on a router without USB port?"

I have been DIY'ing a couple of months ago with arduino minis (i.e. the arduino without UART) and the ESP8266 WIFI chip while pimping my old AR.Drone to use a real radio remote and remote-controlling my heating system with ebusd.

My first idea (which should work "off the shelf") was to maybe build a nano usb with an arduino mini and instead of a UART hook it up to an ESP8266 running ser2net which connects to the network using WIFI. On the client run something like socat to redirect a (virtual) comport to the net socket ser2net is listening on.

But then I thought - hey, why not port the pilight nano usb implementation directly to the ESP8266 and thus have a super mini thumbnail-like 433 MHz receiver connecting directly to WIFI?

Anybody interested in kicking this off? Any caveats you could think off or why it would possibly not work?

Just collecting ideas and want to see if there is demand before I start putting time into this... Anybody want to contribute?
 
Reply
#2
Works perfectly if you have the time to implement it.
 
Reply
#3
actually I might have some time over christmas. Just wanted to check if there is demand and/or maybe someone is willing to assist?
 
Reply
#4
I am, but not willing to lead this.
 
Reply
#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: 35)
.jpg   stripboard_espremoved.jpg (Size: 308.36 KB / Downloads: 31)
.jpg   stripboard.jpg (Size: 242.21 KB / Downloads: 30)
.jpg   uart_stick.jpg (Size: 127.63 KB / Downloads: 27)
 
Reply
#6
Really nice!

Would you be capable of writing a hardware module so we can talk to the wifi connected nano directly? The best thing would be to enhance the pilight-usb-nano with the esp code so we can attach wifi to the current nano and have pilight directly talk to it through regular wifi (if possible?) or another esp connected to a pi.
 
Reply
#7
I might do this at some point in time; however if I look at the required steps and what the final project could look like there are a couple of steps in between.

First step was to prove that it could be done talking to the nano over Wifi (check).

The next steps include (but are not limited to):

- figure out which protocol to use (probably UDP) - PoC connection issues with UDP
- run intensive tests on the existing platform (it would be nice if two or three more people could actually sign up to this and run tests)
- evaluate if we need another hardware module (e.g. netnano433.c) or if we just use the exisiting 433nano.c and extend it to net sockets

This last mentioned step hugely depends on whether we want to simplify module hardware to a maximum, i.e. provide a small matchbox-size device that would only have an ESP8266 plus sender and receiver or if we want to keep the Arduino in the design.

In order to take an educated choice on this issue I would really really love to have a couple of more opinions on this. Would people use it ? Is it worth porting the Arduino Code to ESP8266? The code is very timing-sensitive (surprise) and porting it will add new errors, new bugs etc.

If we find out that using UDP and socat works reliably and stable the whole remaining "workload" would be to modify the daemon startup (/etc/init.d/pilight) to launch socat depending on config.json - done!

If we would need a fault-tolerant network connect (i.e. have pilight try to reconnect to the wifi dongle if it had failed) then modifying the pilight code would be necessary (433nano.c or new module).

If people really want it and think it is cool to have a mini device of the size of a matchbox as a sensor then we might be looking into porting the pilight-usb code to esp8266, making it a new device.

If I look at my personal agenda which includes pilight as a fire and motion alarm detector that runs on my OpenWrt routers then I am fine with solutions 1 and 2. But I am ready to give something back to this project and think about solution 3 but we really really need a bit of feed-back from people using it.... plus a handful of folks being able to run tests and possibly re-flash an esp8266....
 
Reply
#8
I willing to test it ofc. Can you provide me with a link to the hardware you used?
 
Reply
#9
I'll need to look these up. Alternatively, if you PN me a mail address in the EU I can send you a ready flashed ESP plus a 3.3 V Controller. You would then only need to find an arduino mini and a 433 MHz Module (any 5V Tx/Rx like the ones you have in your shop will do)

The ESP is an ESP12 module
Arduino mini
a 3.3 V Module
7805
1n4148
plus a handful of resistors
433 MHz Receiver / Sender optional
 
Reply
#10
Does it matter if we use a mini or a nano?
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  pilight DIY PCB Kits curlymo 60 26,887 10-10-2019, 08:40 AM
Last Post: curlymo
  pilight 8.0 / wiringx / receive ATTINY-TX wupperpi 5 1,176 01-18-2018, 02:24 PM
Last Post: wupperpi
  pilight, Raspberry Pi and sensors for sale kid2000 0 1,360 04-07-2017, 05:04 PM
Last Post: kid2000
  433Mhz Wifi Gateway ripper121 5 3,220 03-13-2017, 10:25 AM
Last Post: ripper121
  parts for pilight rikeshe 4 1,817 12-10-2016, 09:02 PM
Last Post: rikeshe
  Arduino nano with CC1101 ? Bootscreen 5 2,961 11-04-2016, 03:38 PM
Last Post: curlymo
  No pilight-[debug/raw/learn] signals received bassabaws 8 6,662 04-14-2016, 11:35 PM
Last Post: wo_rasp
  Experiences with the pilight DIY PCB Kits troccolo 112 35,230 03-05-2016, 11:21 AM
Last Post: curlymo
  Use existing wall switch with correct status in pilight? kylex 0 1,270 01-13-2016, 01:27 AM
Last Post: kylex
  For Sale own-made pilight shield. Luppie 3 2,703 10-31-2015, 11:23 AM
Last Post: Luppie

Forum Jump:


Browsing: 1 Guest(s)