New protocol for battery powered devices.

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

New protocol for battery powered devices.

#1 Post by happytm » 05 Jun 2020, 05:42

I have been looking for cheap and simple ways to reduce power consumption for my battery powered ESP8266 & ESP32 devices for quite long time.I tried lot of different hardware modification and software protocols like IR, RF, LORA & ESPNow. There are always complexities in hardware implementation
due to lack of GPIO pins on ESP8266 or simply hardware is too expensive. So I decided to leverage built in feature called probe request in ESP software to create a simple standalone IOT sensor network in star topology.

I have been testing this code for at least last 2 month with one ESP8266 Gateway and 8 ESP8266 remote battery powered devices and they are working fine without any issues.The remote devices take only 50 to 75 milliseconds to send sensor data to gateway and go back to sleep. which is way faster than any other protocol I tried. If for some reason if you want to control the remote devices via MQTT there is duplex mode option selection in remote device code. Duplex mode require around 140 milliseconds to communicate between Gateway and remote device in two way fashion. The gateway device have MQTT broker built in so there is no need to connect to any MQTT broker.There is also person locator code built in based on MAC ID.

This is the simplest and least expensive way I know to implement low power standalone IOT sensor network.

I would like to request one of the developer who understand ESPEasy plugins to take a look at the code linked below and try to implement as a controller plugin if possible.:

ESP8266 Gateway code ( With built in MQTT broker - no need to connect to any MQTT broker):

https://github.com/happytm/BatteryNode/ ... SP8266.ino

ESP32 Gateway code ( With built in MQTT client - connection may be needed to MQTT broker):

https://github.com/happytm/BatteryNode/ ... yESP32.ino

ESP8266 Remote code (this is for battery powered devices.These devices are not connected directly to home router or internet. They are only communicating with the gateway without connecting to gateway. For standalone local network connection to internet is not required):

https://github.com/happytm/BatteryNode/ ... sp8266.ino

Thanks.

martinus
Normal user
Posts: 129
Joined: 15 Feb 2020, 16:57

Re: New protocol for battery powered devices.

#2 Post by martinus » 26 Jun 2020, 10:51

happytm wrote: 05 Jun 2020, 05:42 I have been looking for cheap and simple ways to reduce power consumption for my battery powered ESP8266 & ESP32 devices for quite long time.
I haven't seen any request on alternative protocols for battery operated ESP devices, not for my ESPNOW experiments, nor your 'probe-request' approach.
So it looks like it would be a total waste of time in trying to get any of this into the official development branch.

I guess the currently available protocols suits everyone besides the two of us atm.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: New protocol for battery powered devices.

#3 Post by TD-er » 26 Jun 2020, 22:23

Well, that's not entirely true.

I am working on adding an ESP-now layer to ESPEasy.
Right now it already does support forwarding MQTT-messages over multiple hops to some node that's connected to the network (and a broker)
It also supports the discovery similar to what's used in the p2p protocol and a time sync which can keep the nodes time in sync withing 1 ms accuracy.

In the end it will support everything supported in the p2p protocol, but then over ESP-now and a lot more.

Main target is to support battery powered nodes and to cover areas without WiFi coverage, but also to allow processing sensor data over multiple nodes which do need a very accurate timing to trigger all sensors. (more on that later)

It is a work-in-progress.

martinus
Normal user
Posts: 129
Joined: 15 Feb 2020, 16:57

Re: New protocol for battery powered devices.

#4 Post by martinus » 27 Jun 2020, 09:12

TD-er wrote: 26 Jun 2020, 22:23 Well, that's not entirely true.
I am working on adding an ESP-now layer to ESPEasy.
It is a work-in-progress.
Good to hear that ESPNOW will be part of the stock firmware. That will likely add to the level of adoption from end users.

Ton_vN
Normal user
Posts: 300
Joined: 21 Oct 2016, 15:20
Location: Hengelo (Ov)/ NL
Contact:

Re: New protocol for battery powered devices.

#5 Post by Ton_vN » 28 Jun 2020, 10:06

@TDer
Main target is to support battery powered nodes and to cover areas without WiFi coverage,
sounds quite interesting for those people living 'in the countryside'.

Resulting in kind of meshed network?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: New protocol for battery powered devices.

#6 Post by TD-er » 28 Jun 2020, 10:47

Right now it is working as some kind of mesh where one or more nodes may be able to reach a WiFi access point and can connect to a MQTT broker.
In my test setup here I've been able to perform 6 hops and distance between hops ranges from 20 - 50 meter. (depending on the environment of course)

But I intend to make it as flexible as possible so it should be completely hybrid.
Nodes should be able to communicate to each other either with or without WiFi access point and if one of them can forward the messages then the messages should be sent there.
Right now I only have a MQTT controller forwarder feature, but I also intend to make LoRaWAN forwarder, so you can have a set of nodes of which a limited set is equipped with a LoRaWAN radio.
This to keep the costs as low as possible and also you don't need to define a plugin to collect the data like with MQTT import and Dummy plugins.

And also there will be other very nice features possible like initial configuration, OTA upgrades and deployment of settings.
But that's future work (and partly work in progress).

martinus
Normal user
Posts: 129
Joined: 15 Feb 2020, 16:57

Re: New protocol for battery powered devices.

#7 Post by martinus » 29 Jun 2020, 16:47

After some tweaking on ESPEasy, this is the best i could achieve on the LSC "cold-boot circuit".
400 milliseconds to do setup, serial communications to the MCU, init boot message to verify channel, check status and send final message.
All done with rules. And 500 mSeconds before actual sleep:
ESPNOW_Current5.png
ESPNOW_Current5.png (42.5 KiB) Viewed 22482 times
Setup() now first calls a serial check on the tuya MCU to detect if we are running on a LSC device and if we have a common (not setup) event trigger.
It then uses a minimal custom boot routine so save some time on the normal boot sequence:

Code: Select all

void c_fast_boot(){
  c_fastBoot=true;
  WiFi.persistent(false);
  WiFi.setAutoReconnect(false);
  WiFi.disconnect();
  WiFi.mode(WIFI_OFF);
  SPIFFS.begin();
  LoadFromFile((char *)FILE_CONFIG, 0, (byte *)&Settings, sizeof(SettingsStruct));
  LoadFromFile((char *)FILE_SECURITY, 0, (byte *)&SecuritySettings, sizeof(SecurityStruct));
  Wire.setClock(Settings.I2C_clockSpeed);
  Wire.begin(Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
  activeRuleSets[0] = true; 
  PluginInit();
  String event = F("System#FastBoot");
  rulesProcessingFile("rules1.txt",event);
}
In case the sensor is started using the setup button, it will perform a normal boot sequence with all regular checks and connect to the configured Wifi AP.

@TD: Looking forward to the stock ESPNOW implementation to see if i can improve my experimental stuff based on your code.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: New protocol for battery powered devices.

#8 Post by TD-er » 29 Jun 2020, 19:03

I think scanning the SPIFFS file system also takes some time and the tasks and controllers are started with some artificial delay after boot.
So we can gain some time there.

I doubt my implementation will be faster, but it will be (hopefully) a bit more generic way to interact with the ESP nodes. (ESP32 and ESP8266 can also communicate with each other)

happytm
Normal user
Posts: 107
Joined: 15 Aug 2016, 17:53

Re: New protocol for battery powered devices.

#9 Post by happytm » 01 Aug 2020, 00:27

Well, that's not entirely true.

I am working on adding an ESP-now layer to ESPEasy.
Right now it already does support forwarding MQTT-messages over multiple hops to some node that's connected to the network (and a broker)
It also supports the discovery similar to what's used in the p2p protocol and a time sync which can keep the nodes time in sync withing 1 ms accuracy.

In the end it will support everything supported in the p2p protocol, but then over ESP-now and a lot more.

Main target is to support battery powered nodes and to cover areas without WiFi coverage, but also to allow processing sensor data over multiple nodes which do need a very accurate timing to trigger all sensors. (more on that later)

It is a work-in-progress.
Any progress on this ?

Thanks.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: New protocol for battery powered devices.

#10 Post by TD-er » 01 Aug 2020, 00:37

Not that much as in the last 4 weeks I've been working solely on other ESPEasy issues.
So next month I will be working again on the ESP-now layer.

cwhb2020
New user
Posts: 6
Joined: 23 Dec 2020, 15:39

Re: New protocol for battery powered devices.

#11 Post by cwhb2020 » 25 Dec 2020, 10:39

Hi TD-er,
i'm very much interested in having battery powered sensors running as long as possible.
And i have a couple of Wemos D1-Mini and ESP 8266-01 lying around unemployed in the drawer.
Is there already a GIT project which could be cloned for experimenting with nodes connected by ESP-now?

Kind regards,

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: New protocol for battery powered devices.

#12 Post by TD-er » 25 Dec 2020, 14:58

cwhb2020 wrote: 25 Dec 2020, 10:39 Hi TD-er,
i'm very much interested in having battery powered sensors running as long as possible.
And i have a couple of Wemos D1-Mini and ESP 8266-01 lying around unemployed in the drawer.
Is there already a GIT project which could be cloned for experimenting with nodes connected by ESP-now?

Kind regards,
I'm still working on it, so as of now the pending PR only allows to use the ESP-now layer for something resembling a mesh network to forward MQTT messages until it reaches a node connected to a broker.
The ESPEasy p2p protocol is not yet completely implemented in this ESPEasy-now layer so as of now you cannot share the sampled data to another node as we now do with the p2p.
So right now using the ESP-now layer in ESPEasy is taking more energy instead of less. But in the end it is intended to allow for sending data to another node and going back to sleep again as soon as possible. Sadly we're not there yet.

cwhb2020
New user
Posts: 6
Joined: 23 Dec 2020, 15:39

Re: New protocol for battery powered devices.

#13 Post by cwhb2020 » 25 Dec 2020, 17:14

I see, thanks a lot for your quick response anyway!

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests