mysensors / MySensors

MySensors library and examples
https://www.mysensors.org
1.32k stars 895 forks source link

Please support ESP32 #968

Closed micropet closed 6 years ago

micropet commented 7 years ago

Hello,

I have been using the ESP32 fork from tekka007 for months. https://github.com/tekka007/MySensors/commits/ESP32HW The software runs very stable on about 20 ESP32 boards.

I would be happy, if the ESP32 extension flows into the official sources.

Greetings Peter

tekka007 commented 7 years ago

@micropet thanks for your feedback. PR for dev: see #865.

knopserl commented 6 years ago

question to @micropet and @tekka007: I'm also using ESP32 variants as gateway but also mainly for sensor nodes (because of e-Paper). The gateway definitly works fine and my first sensor nodes (I've tried two variants, w/ and w/o NodeManager) and I have the impression, that the sleep mode does not really work as expected in both cases. For the non NodeManager sample, I used the BatteryPoweredSensor as template and in all cases, the sleep time seem not work. I have tried 30sec and 1min but the repots/loop intervals seem to be always a few seconds.

below is the serial log of the BatteryPoweredSensor and the intervals in the loop are about 3-5 seconds. Both sensor nodes are connected to a GW and there is working data exchange. I have added a Serial.println and it's running through the loop but with very short intervals (not what is defined as sleep time)

How is the sleep mode implemented for the ESP32 (or ESP8266), are the light sleep or deep sleeo modes supported? The deep sleep would do a warm start and that would be most likely visible in the logfile?


| \/ | / | | |\/| | | | \ \ / \ ` \/ |/ | `/ | | | | | || || | / | | \ \ | | \ \ || ||_, |____/ \|| ||/\/|_| |/ |/ 2.3.1-alpha

33 MCO:BGN:INIT NODE,CP=RLNNF---,VER=2.3.1-alpha 48 TSM:INIT 49 TSF:WUR:MS=1 61 TSM:INIT:TSP OK 63 TSM:INIT:STATID=11 64 TSF:SID:OK,ID=11 66 TSM:FPAR 67 TSM:FPAR:STATP=0 69 MCO:BGN:STP 77 MCO:BGN:INIT OK,TSP=0 79 TSM:ID 896 Battery Voltage: 3.01 V Battery percent: 89 % 80 !TSF:SND:TNR 86 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255 90 !MCO:SLP:TNR 92 TSM:ID:OK 93 TSM:UPL 7094 !TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1 9101 TSM:UPL 14102 !TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=NACK:1 14108 MCO:SLP:MS=15984 14110 TSF:TDI:TSL 14111 MCO:SLP:WUP=-2 14113 TSF:TRI:TSB 876 Battery Voltage: 2.95 V Battery percent: 87 % 14115 !TSF:SND:TNR 14121 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255 14126 !MCO:SLP:TNR 16109 TSM:UPL 23110 !TSF:MSG:SEND,11-11-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=2,st=NACK:1 24128 MCO:SLP:MS=20000 24129 TSF:TDI:TSL 24131 MCO:SLP:WUP=-2 24133 TSF:TRI:TSB 876

mfalkvidd commented 6 years ago

@knopserl both esp32 and esp8266 will return MY_SLEEP_NOT_POSSIBLE when calling sleep and return immediately.

knopserl commented 6 years ago

@mfalkvidd thanks for clarification. So the code for sleep was not ported/atapted for theESP MCU's right. That is some work which need to be done or I have to find a solution by myself using the ESP deep sleep features right? So ESP support is currently only for projects which don't need to sleep like the gateways but not (yet) for battery powered projects.

mfalkvidd commented 6 years ago

@knopserl the light sleep mode f the esp32 consumes 0.8 mA (according to the datasheet) which means about 3 months battery life on 2xAA. That's less than 10% battery life compared to an atmega328-based node, so I'm not sure it makes sense to implement sleep using light sleep.

As you mentioned, the deep sleep will require a reboot at wakeup, which means the sleep function would not return. Such a radical change in sleep behavior would probably confuse a lot of users, and would require refactoring the structure of the sketches.

I'd say this rules out battery-powered nodes based on esp32. But if someone is eager enough to get it working and prepared to maintain document and it, we'd probably be able to merge code that supports sleep on esp32.