-
Notifications
You must be signed in to change notification settings - Fork 221
esp32/esp: read internal temperature sensor #192
Conversation
Add a function to the esp module to read the internal temperature sensor via temprature_sens_read(), located in librtc.a
Great! I'll have a look as soon as possible ... I agree that this is probably an thinks unless most of the different platforms have something similar available in which case perhaps we should add a |
stm32 port has this as I didn't notice any of the other platforms having similar functionality, and the ESP32 interface is different to this one, so not sure how relevant that is! |
If I understand correctly, the temperature sensor is read using the SAR ADC1. However, it's not listed as one of the ADC channels (like in the STM32), so it's not part of the ADC driver in the ESP-IDF. I don't think the organization of micropython has to exactly mirror the ESP-IDF. It's probably a question of where a micropython user would look to find this peripheral. There's also a hall effect sensor that's read using the ADC but not part of the ADC driver. When implemented, it's placement should be related to the placement of the temperature sensor. Should these two sensors be methods of the |
FWIW I think |
Yeah, I agree. I wanted to check if 'most' other ports had an equivalent, in which case we should standardize something under 'machine' but it looks like not so I think 'esp' is fine. |
@mogenson it looks like the Regarding the placement of the function: to maintain compatibility with the ESP8266 I think it would be best to create a new |
@dpgeorge So far the |
Hmmm, I see what you mean, it's really truly undocumented in the sense that it isn't even in a header file. Based on comments here espressif/esp-idf#146 I think we should avoid using it as it isn't documented and is spelled wrong ... perhaps we'd be better off reproducing the test_tsens.c code or pleading with Espressif to implement and document this function for us! Also that code seems to be in two bits: firstly powering up the sensor, then reading it out. Our API should probably reflect this. |
Agreed. @mogenson If you really want to use the sensor at this stage then it's possible to control the registers directly via the |
Hi Michael, thanks for your contribution though and yes, you're going about it the right way. Hopefully the underlying API issues will be resolved soon and we can revisit this then (see #187 where it says "We have a task for adding an API for temperature sensor, which will likely be addressed for the next major version") |
Add a function to the
esp
module to read the ESP32's internal temperature sensor. This usestemprature_sens_read()
[1] from thelibrtc.a
library linked from the ESP-IDF.I stuffed this into the
esp
module because it doesn't seem significant enough to warrant a new class in themachine
module. Additionally, it could be seen as a property of the ESP32 module, like flash size.This pull request is primarily a means for me to learn how micropython interacts with the ESP-IDF. Let me know if anything has not been implemented properly.
[1] misspelling is present in the ESP-IDF