Skip to content
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

Is it possible to add the internal temperature sensor support? #2116

Closed
lu-zero opened this issue Sep 8, 2024 · 3 comments · Fixed by #2875
Closed

Is it possible to add the internal temperature sensor support? #2116

lu-zero opened this issue Sep 8, 2024 · 3 comments · Fixed by #2875
Labels
help wanted Extra attention is needed

Comments

@lu-zero
Copy link

lu-zero commented Sep 8, 2024

not esp32 has support for it https://docs.espressif.com/projects/esp-idf/en/stable/esp32c3/api-reference/peripherals/temp_sensor.html

Twin issue for the esp-idf-hal crate esp-rs/esp-idf-hal#333

@MabezDev
Copy link
Member

It's for sure possible, a PR would be most welcome :).

@lu-zero
Copy link
Author

lu-zero commented Sep 25, 2024

I'd need lots of guidance first, I do not know enough of the esp-idf and esp-hal to commit to it yet ^^;

@Hackswell
Copy link

Hackswell commented Oct 6, 2024

Just some notes/thoughts. For anyone wanting to implement. Might make a good "beginner" task, since turning on is just a few bit flips, and you just read the lowest byte and follow a set algorithm.

  • T(°C) = 0.4386 ∗ VALUE–27.88 ∗ offset–20.52

Basic low-level bit-flipping and definitions for the TSENSor are here:

  • esp-pacs/esp32c3/src/apb_saradc/tsens_ctrl.rs
  • esp-pacs/esp32c3/src/apb_saradc/tsens_ctrl2.rs

Hardware ports/memory are already defined in:

  • esp-pacs/esp32c3/svd/esp32c3.base.svd

Would need to add the "tsens" peripheral here, I think

  • esp-hal/esp-hal/src/system.rs
    and possibly here? Not sure:
  • esp-hal/esp-hal/src/analog/adc/riscv.rs

Would it be better to add the higher level implementation here, since it's connected to the ADC peripheral? But then it might get "hidden" and hard to find.

  • esp-hal/esp-hal/src/analog/adc/esp32.rs

Or would it be better to implement this in

  • esp-hal/esp-hal/src/analog/tsens/esp32.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants