MoonModules / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi! MoonModules adds features on top of upstream.
https://mm.kno.wled.ge
European Union Public License 1.2
228 stars 70 forks source link

Add MCU temperature info #44

Closed dosipod closed 1 year ago

dosipod commented 1 year ago

This is already tested thanks to @lost-hope , It would be nice if the MCU temperature output is available or published via MQTT https://discord.com/channels/473448917040758787/757254961640898622/1105586635195809932 One use case is to switch all our MCUS powers to 3.3v to reduce heat and I do not like to walk around the building to do thermal imagery . In all cases that may be useful to indicate possible hw or wiring issues or even could help to see if MCU is stressed . It is also available with others like Tasmota so could be common to open source .

lost-hope commented 1 year ago

I made a quick usermod to add that measurement on esp32 and also send it out every second per mqtt https://github.com/lost-hope/WLED/tree/mcu_temp/usermods/mcu_temp havent found a way for the newer ESP32 boards yet

dosipod commented 1 year ago

Looks good , cloned your repo but not sure if that is up to date with latest MM as i see connection issues ,with the test unit , i want to try to distribute to multiple units , might setup the timing to 3000ms but will keep some on 1000ms to see if there is impact . image image

softhack007 commented 1 year ago

Nice idea - i also have that on my (long) list 👍 Actually i put it aside, as I could not get meaningfull values from temprature_sens_read(). Well that was a year ago, maybe I just had old esp32 modules at the time.

@lost-hope: Did it work for you on the 16MB "WROOM-32E" made by serg74?

Reading the temp sensors of new MCUs seems to be trouble, at least on -S2 there is a framework bug, leading to bad readings when wifi is active.

lost-hope commented 1 year ago

The main issues with the internal sensors is, that they are really inacurate. i tested it with a twilightlords esp32 (ESP32-WROOM-32E) and it shows 56°C at boot.

i will let is run for a bit to see if the reported value seems logical (it is the temp of the mcu and we can only feel/measure on the tin can, which has no direct contact to the mcu

and regarding the sending interval, i set it at 1s for testing, but i think, that even 10s is too often for temperature, which is normally a pretty slow changing value.

dosipod commented 1 year ago

Yeah i setup the interval to 3000 ms and seems the unit is okay and i will add few units to ha to see , one of the guys is saying we will know if the air condition in room is off from temperature difference which is the accuracy that we could work with . Some of the MCUs will not show the correct temperature even with thermal image because of the metal housing . I tested one without that and temperature seems close .

image

dosipod commented 1 year ago

After few hours , room temperature effect on MCU , So yeah a poor man temperature sensor with the right formula image

softhack007 commented 1 year ago

(old news) the ESP32 temperature sensor is not supported any more in "V4" builds with esp-idf 4.x.y / arduino-esp32 v2.0.x

This would mean the temp sensor function is only usable in "WLED standard" builds based on esp-idf 3.x.y / arduino-esp32 v1.0.6.

The new temperature API should work on -S3.

softhack007 commented 1 year ago

correction: I can still make a "V4" build with temprature_sens_read(). So it was not removed completely, even when espressif says so.

dosipod commented 1 year ago

image Graph for 20 hours , It might be worth to note could be a big difference between MCU temperature and board temperature but that is something I could not plot accurately but some of the guys confused both .

softhack007 commented 1 year ago

@lost-hope just saw that arduino-esp32 has a function for this, that is also availeable on -S3/-s2/-c3. Just that the -s2 version tends to crash randomly...

https://github.com/espressif/arduino-esp32/blob/72c41d09538663ebef80d29eb986cd5bc3395c2d/cores/esp32/esp32-hal-misc.c#L57-L77.

Looks like the function exists in the old 1.0x core, too.

lost-hope commented 1 year ago

just updated it in my branch. But in my opinion it should be added to the normal mm code, instead of a usermod. just hide the field for 8266 and S2 (if this function is the cause of the crashes)

softhack007 commented 1 year ago

Implemented with https://github.com/MoonModules/WLED/pull/51