-->
Page 1 of 10

Local, multi ESP8266 Network

PostPosted: Fri Jun 10, 2016 9:02 pm
by John L
Apologies if same/similar question has been asked before, I could not find adequate answers by searching the forum.
By the way, great implementation of BASIC on ESP8266.

I am looking at setting up a local network of multiple ESP8266 nodes for lets say similar to home automation.
Network to consist of sensor (input switches, temperature, humidity, light, etc) and control (relay switches, light dimmers, etc) nodes.

I guess the question is, Is it possible for ESP8266 Basic nodes to communicate with each other directly or via a "Master" polling ESP8266 Basic node doing the polling. If yes, a link to suitable documentation or a brief example. How many nodes could be practically networked, only few bytes of data would need to be exchanged at fairly low data rate?

I would prefer to keep complicated WIFI central AP routers etc. out of it.

Re: Local, multi ESP8266 Network

PostPosted: Sat Jun 11, 2016 12:29 pm
by Electroguard
Nodes can communicate directly using UDP, but there is no existing automation network documentation for you to follow. The closest thing at the moment is the Help page of the Switched Relay Module which has udp networking built-in and can be addressed by node name and sent network commands using cicciocb's udb network utility or a udp processing script.

The Switched Relay node has input capability as well as output, so until (if) other nodes are developed (PIR etc) you could use the Switched Relay flashing button as user input to control another node(s) while you develop others based around the same core code.

The code was developed to be re-usable without requiring any specific individual tailoring, so the same script can be installed on multiple nodes which can coexist together without needing to configure IP addresses etc. By default each node will automatically assume a default name of 'Node' + nnn, where nnn is its dhcp address, but you can assign each node whatever useful name you prefer. It's then just a matter of sending relevent commands to any appropriate node name, eg: Relay01 ON, LightsLounge OFF, Router Reboot.
I included facility for Group and Global Names also, to offer facility to eg: turn all Lights Off, or make all PIRs blink to show their locations etc.
You can also make any node blink out its IP address by pressing the local button (short press for just the last byte, long press for full address).

All the mechanisms were working on V2 but I don't know what the situation is on V3.

Re: Local, multi ESP8266 Network

PostPosted: Sat Jun 11, 2016 6:42 pm
by John L
Thanks Electroguard,

UDP implementation sounds good enough as a vehicle for what I am thinking about and I can expand on further detailed requirements.

How do WiFi RF channels work in this situation without an access point (AP), issue of radio congestion/collisions if multiple nodes transmit at the same time?
Does UDP communication support automatic handshaking, error checking and retries or should that be implemented separately at the application software level?

Regards
John

Re: Local, multi ESP8266 Network

PostPosted: Sun Jun 12, 2016 4:36 pm
by Electroguard
The straight answer to your questions is that I don't know, because ESP_Basic was a constantly moving target which I struggled to keep up with, and which then changed direction before I was able to get a functional udp network of nodes up and running. I had it almost done on V2, but then the goalposts were moved with V3 causing it to no longer be suitable for the script I'd been developing for my 512K Sonoff relay modules. I've ordered some 4Mb Electrodragon relay modules from china, but the required enthusiasm may take longer to replace.

I don't know what your requirements are, so can't say if the udp networking would be suitable for your needs, but if you are not expecting excessive network demands then it should probably be ok.

UDP is a connectionless non-handshake broadcast method of data transfer. All nodes have a receive port open and receive all broadcasts from all other nodes on that same subnet, and it is down to each node to decide if the transmission is meant for it, or not.

I've created an 'EasyNet' common framework that allows nodes to communicate without any unique network configuration. There's no need to know individual IP addresses, because each node listens to broadcasts for its own name, and if recognised, actions any accompanying command/parameters meant for it. It is down to any sending nodes to request acknowledgements if required, and re-transmit any unacknowledged broadcasts. Receiving nodes return acknowledgements with... 'udpreply message'

CiccioCB has created a very useful UDP_debugger.exe utility which you can download from here...
https://github.com/cicciocb/UDP_tester/archive/master.zip

You can download the Switched Relay script which contains the EasyNet framework from here...
http://www.esp8266.com/viewtopic.php?f=41&t=10327#p48805

Click on the top-left ? button to show the Help page which shows the commands it recognises - basically you want to send it appropriate commands from the UDP_debugger utility to check the udp network functionality for yourself, ie: 'node1 blinkip'.

The intention was that PIR and multi-i/o trigger nodes would send event trigger msgs such as 'Zone3 Alert' or 'Frontdoor Visitor' to corresponding relay and IR and voice announcer nodes etc, which would recognise and respond to them as appropriate. But various ESP_Basic growing pains and too many unanswered questions delayed me from getting that far before the switch to V3, and I'm reluctant to return to that situation. I've already done an MP3 Player node as an interim step to a Voice Msg Announcer node, and I've got a couple of external PIR activated solar garden lights ready to be turned into ESP_Basic trigger nodes, so I expect I'll continue with the project again once most of the V3 bugs are ironed out and it remains stable for at least a week, but I won't be considering that for some weeks yet.
If you want any more detail I can post you an EasyNet Demonstrator script I had been working on which contains a lot more info, but be aware that it is a V2 script that probably won't run on V3 which I won't be converting or upgrading.

My plan was (is) to have a second wifi router network just for my 'system' nodes BTW, which has no need of internet connection, and will not impact on the my original internet wifi network computers or vice versa.