-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Controller: ESP-Now #73
Comments
Interesting project, as i understand ESPNOW is a connectionless protocol which looks like just UDP. And also it works in a lower logical level of the network, which is currently handled by the Linux operating system. (vendor specific action frame of 802.11) |
Well I have plans to add support for ESPnow to ESPeasy as fallback when there is no (known) network in reach. One thing that makes ESPnow really interesting is that it is much faster in delivering "the first byte" compared to WiFi. |
I think it should be other way around to make sensor truly low power. Instead of espnow as backup on remote low power sender sensor it should be primary sender protocol and if in case espnow fails on remote sender it can send MQTT message to public or private broker directly as shown below. All the remote sensor unit does not need espeasy software but some custom sketch to do the above.Only Master Unit (receiver for espnow messages from remote sensors) need to have espeasy software. The master unit with espeasy will behave like MQTT broker or it is like Mysensor Gateway. For low power normal mode if espnow is ok & working properly it will be like this. Link to code for sender & receiver (serial gateway connected to raspberry pi or as a MQTT gateway) units is at the link below. https://github.com/Wim3d/ESP-NOW/blob/master/Master_sender.ino Now only thing to do is add some receiver code in espeasy. Below is examples of receiver code.One is serial gateway like Mysensor protocol and one is MQTT gateway. https://github.com/Wim3d/ESP-NOW/blob/master/Slave_receiver.ino Thanks |
I agree that your suggestion is using the least power, but there's a rather big but here. But still it is a great solution for having a battery powered node to communicate with one that's always powered and let that one act as some kind of gateway. |
In normal home automation there are some sensors which needs to be outdoor (for example , 1 outdoor device for weather station and few indoors device for windows and doors or device measuring oil or water tank levels where sometime mains power is not available ). So most of the time ratio of wired to battery powered devices are less than 1:5.By implementing espnow protocol not only it helps with outdoor battery powered devices conserve power but it also help extend the range by creating small mesh network. I agree with you that this protocol is not suitable for larger network of devices.My plan is to use it as a farm sensors network using soil moisture & light sensors where mains power to sensors will be impractical at each sensor. |
Well for the more longer range and larger networks, I am working on something here :) |
Eagerly waiting for it. Thanks |
Here is an attempt to connect ESP device (sender) using ESP-Now protocol to linux machine(receiver): https://hackaday.io/project/161896-linux-espnow Thanks |
I am afraid in the RPI world ESPNOW through linux kernel wireless driver is a very-very early alpha stage thing, i guess that it will be always easier to attach an ESP-01 with serial to the RPI and join to the ESPNOW across it. Altough it is very interesting, but I read a few sentences in the hackaday ESPNOW description, which did not really win my liking:
|
I was just thinking out loud. You are right it is very alpha stage. Hopefully one day RPIEasy will serve as one controller receiving all data packets from all low battery powered espnow devices.You are right the best option right now is second esp device connected to pi via serial collecting all data from remote sensors (good thing is it's $ 2 extra).But if we figure out adhoc network for pi it will be simpler solution. The first issue you raised is solved somewhere else.According to link below Raspberry Pi's built in wifi can be put in monitor mode: HarringayMakerSpace/sonoff-adhoc#1 He is using fake MAC ID itself to send data between devices.Very cool hack. For small range indoor network there is another way: https://forum.arduino.cc/index.php?topic=10555.0 https://forum.arduino.cc/index.php?topic=228312.0 We don't need IR protocol for this one on software side (just serial ) and I have to work on increasing the IR range to make it useful.This could be used for monitor windows and door sensors indoor with button cell batteries.The key is to design IR led with very narrow beam to focus on IR receiver at Raspberry PI to extend the range.I think 15 to 20 feet could be achievable and that would be enough for most rooms for home automation. Thanks |
It sounds good, we will se. |
We discussed receiving IR signal over serial but following is sending IR from RPIEasy to some IR switches scattered around in the house. In order to test indoor IR network I have ordered these actuator devices: They are $3 each for quantity of 3 or more. bigclivedotcom had teardown & review of these devices a while back and they come with unnamed microcontroller and 5V power supply.It looks like they are hackable for any other uses (maybe replacing controller with ESP-8266 or Atmega328 with .96" Oled and whatever sensors required) : |
The microcontroller chip looks like Attiny84 and if that is the case then it is even better to upload custom sketch to it although the default program looks quite good to turn any old mains device into remote controlled one without any programming knowledge. |
I have just posted following proposal on OpenMQTTGateway: 1technophile/OpenMQTTGateway#421 1technophile/OpenMQTTGateway#196 Let's see if they respond. Thanks |
My attempt to use esp-now and adhoc network. It works ok. I am no coder so I had to bring together snippets of code from many sources. Please someone good at coding can improve it. I like the adhoc network better because data from remote sender unit can be received by any hardware like raspberry pi zero and it is faster than espnow. We can put raspberry pi in monitor mode as shown here: https://github.com/HarringayMakerSpace/sonoff-adhoc Thanks |
About this "adhoc" networking: On the other side ESP-NOW is based on IEEE802.11 Action Vendor frame standard and is a legit protocol, seems nice, i think that it has to be implemented. |
With RPIEasy i plan to use an ESP8266 through serial as a receiver, and another ESP8266 as a sender. I am trying to setup a generic sketch now. On the ESPEasy the ESPNow implementation will be tricky as: |
Very good news.Espeasy is not important here as ESP8266 connected via serial could serve as just transparent gateway collecting data and sending data to other ESPNow or Lora devices and that way there is less of complexities associated with Espeasy's wifi. If implemented with ESPNow we can have mesh network of sensor or actuator devices working together doing their own job and interacting with RPIEasy via ESP8266 gateway with ESPNow & Lora protocol.This also solves problem of hardware complexities associated with other protocols like RF and zigby. Option for Gateway software replacing ESPEasy could be ESPCoreRules firmware which is strip-down version of ESPEasy.He just published new big update and I have been testing it for couple of days by adding ESPNow to it and it is working fine. We can further strip it down by removing all wifi and mqtt code and we still have rules engine like ESPEasy which is main feature of ESPEasy. Link is below: SmartNodeRules/ESPCoreRules@8b2ab73 I am eagerly waiting for ESPNow. Thank you for all your efforts. |
Another nice feature on gateway could be this which we are lacking right now in RPIEasy: https://github.com/1technophile/OpenMQTTGateway/blob/development/main/ZgatewayIR.ino Thanks |
First experimental version of the ESPNow node firmware is available here: (defaults to Sender/receiver can be switched to serial gateway mode, 1 firmware for all task) |
Commit e51b007 introduces first approach for the RPIEasy serial-ESPNow controller |
Thank you. You were probably first in publishing major IOT framework on Raspbberry PI and now you are again first one to implement ESPNow protocol (beyond simple example) on ESP8266 as a practical ready to use IOT firmware.I hope this grow to be the best IOT platform. For me this will be fun for next week to test this firmware and report back. I will need some information on settings in global settings file. I am sure you will add some instructions in readme file. Thank you again. |
Thanx! As i said i am not a real programmer, but a problem solver. So i grabbed the old and simple ESPEasy R147 (the amazing work of team letscontrolit), then purged the WiFi and Webserver codes from it, and added a new Controller for ESPNow communication. I had to hack some core functions to make it work. /it's more hacking than programming :) / There are not so many changeable settings, i will write them to the README. I hope it will work with larger number of nodes, currently i've tested with one GW and one SenderAndReceiver endpoint. I know that some display problems may appear on the RPIEasy side in the ESPNow Management page, when replies did not arrives in time, error handling has to be much more sophisticated, consider it as an early beta. (in case -1 appears in fields, try to refresh the page) |
What is the minimum setup required? As far as I can read into code there is 1 ESP8266 (Serial Gateway?) which is connected to RPIEasy via serial and it is unit 0. All other ESP8266 devices are sending or receiving or both.Their unit number could be 1 to 8 (I want to setup 8 remote sensors).My question is how unit # 1 to 8 know serial gateway's MAC address to connect to it? I loaded all devices with stock 1 mb binary you provided but I do not see any activity on serial gateway's serial console except the setup information.I setup mode 3 on all remote devices and mode 1 on serial gateway. Am I doing something wrong here? I assume setup is like this: https://user-images.githubusercontent.com/36576353/60380551-9a95a580-9a15-11e9-8cc8-d736ffac79b1.png Please help me. Thanks |
Yes the setup is the same as the picture, you need one serial GW with a node ID 1-254, 0 will never be a good choice as 0 means "send to all units". The other units node number needs to be unique in the range 1-254.
|
What gpio pins on RPI and ESP8266 should I use to connect ESP8266 with RPI? I never used serial port of raspberry pi in the past. Thanks |
I recommend first to try it with a PC and USB <-> D1 Mini (or with an RPI and OTG USB cable) as enabling serial in a RPI Zero W needs a lot more actions and excercise... Than use command line 'raspi-config' tool: 5- Interfacing Options-P6 Serial- (Kernel logging disabled + serial port hardware enabled) For connection see: |
I've just noticed that you write mode 1, which is for "SENDING only mode". Gateway is Mode 0. But do not worry about it, RPIEasy ESPNow controller enforces Mode0 at Init stage on every startup through serial (if serial works of course). :) |
I think serial is working for me now but I get following message: 21:11:00 Event: Clock#Time=Fri,21:11 Getting closer. Thanks |
If you see "Serial ESPNow GW adapter is not compatible!" than no answer arrived on serial.
|
I've found a possible problem, if the logging level is not set to Debug, the communication is not handled, working on it. |
Yep, i just tested it on a Zero W, with Enable UART: Enabled, Internal Bluetooth: Disabled and after rebooting:
|
I was never able to make it work after many efforts. For me the process is still not clear. I had both esp8266 devices flashed with bin files you provide.The receiver esp device is connected to serial port of raspberry pi as you shown earlier. I guess I am not doing something right in RPIEasy setup. Anyway , how many milliseconds or microseconds a sender unit (esp8266) will take to send a simple 6 byte message & go to deep sleep in your estimate? Thanks. |
Please test the Raspberry serial first with another device to see that it works. At least with an USB CP2102 or FTDI from the Raspberry serial to your PC... Otherwise as i said before, with a proper Wemos D1 Mini, you can even connect it directly with a microUSB-USB cable to a Linux computer or directly to the Raspberry Pi with an OTG. So please put your ESP-01 away a little bit, until you find out where is the problem. The process can not be even simpler, if the serial connection works, RPIEasy sets the serially connected ESP gateway settings automatically, and the precompiled (remote) binary target node is "0" so it will broadcast to every unit when powered on. It still works to me, I've just flashed another 2 nodemcu, and even an ESP32 3 days ago. There were some compatibility issues with ESP32 but now it is solved, an ESP8266 gateway is now able to receive from an ESP32 without problem through ESPNow. |
Thank you. My mistake. My kernel logging was on and I disabled it and everything working fine now. Is there any test code to measure time it needs to send message on sender unit so we can estimate power consumption estimate? Thanks again. |
I'm very happy that it works. IEEE802.11 Action Vendor frame is at least 30 bytes without data + EasyESPNow sensor data is 14 bytes for a one value Task, such as a Switch Device. I know how LoRa data transmission is counted, but i have no clue about ESPNow, sorry. Maybe i can add some code to measure the ellapsed time and print it to serial before going to sleep. Be prepared that you will loose remote control when you enable deepsleep. :) Deepsleep loop can be cancelled by pulling the pin GPIO16(D0) to GND. |
As far as I know, the payload of ESP-now could be up-to 250 bytes, which kind of suggests it only has a MAC address as header. Transmission speed is hardly adding up to the transmission time, but initializing the radio might be. In comparison, connecting to a WiFi AP does take about 3.5 seconds if it has to scan all channels for the known SSID. If it still knows the last known channel and BSSID (MAC address of the AP), then connection time is about 900 - 1000 msec. |
I measured the sending of 14 bytes through ESPNow. It takes 80-120milliseconds, however it does not contain the wake up and init process, just the sending. So the 200msec may be correct. |
Please look at following post. He is using linux machine on receiving side. He claims lot faster communication using ESPNow. https://hackaday.io/project/161896-linux-espnow/log/162377-more-testing-with-rt-preemptb Thanks. |
It can be faster, if the receiving side has the WiFi radio set to no sleep. |
Thank you for your explanation. I wonder this could be implemented on raspberry pi as a receiver device? Thanks. |
In theory, everything is possible. But i do not think it will be a good solution, so I'm sure I won't be the one to develop this. For me, the serial gateway is the best and only acceptable solution for a Raspberry, as the other one:
|
I did not think about all implications behind this so now I understand your concerns. Thank you. |
I wanted to bring to your attention following links on this subject:
https://www.youtube.com/watch?v=6NsBN42B80Q
https://github.com/SensorsIot/ESP-Now-Tests/blob/master/EspNow_Slave_ESP8266/EspNow_Slave_ESP8266.ino
https://www.youtube.com/watch?v=ILnc9KQjHEQ
https://www.instructables.com/id/ESP-NOW-Home-Automation-Esp8266-Raspberry-Pi-MQTT/
https://github.com/HarringayMakerSpace/ESP-Now
https://github.com/HarringayMakerSpace/sonoff-adhoc
Also please keep eye on this project:
https://hackaday.io/project/161896-linux-espnow
It is interesting because with bunch of battery powered cheap esp8266 there is a possibility of creating low power home automation network without using high power consuming wifi or expensive lora modules. Andreas show in above video the power consumption is very low. If esp-now receiver (as a main controller powered by mains power) can be implemented in espeasy that will be lot better than their power hungry P2P network using UDP protocol.
Thanks
The text was updated successfully, but these errors were encountered: