---
title: "Discussion on \"ESP32 Standard Library Embedded Rust: Analog Temperature Sensing using the ADC\" | Hashnode"
description: "Discussion on \"ESP32 Standard Library Embedded Rust: Analog Temperature Sensing using the ADC\". This blog post is the sixth of a multi-part series of posts where I explore various peripherals in the ESP32C3 using standard library embedded Rust and the esp-idf-hal. Please be aware that certain co"
url: "https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [ESP32 Standard Library Embedded Rust: Analog Temperature Sensing using the ADC](https://blog.theembeddedrustacean.com/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc?utm_source=hashnode&utm_medium=feed)

This blog post is the sixth of a multi-part series of posts where I explore various peripherals in the ESP32C3 using standard library embedded Rust and the esp-idf-hal. Please be aware that certain co

Aug 18, 2023 · 9 min read · blog.theembeddedrustacean.com  
Updated Jul 1  
Read the article

-   [#rust](https://hashnode.com/tag/rust)
-   [#tutorial](https://hashnode.com/tag/tutorial)
-   [#iot](https://hashnode.com/tag/iot)
-   [#embedded-systems](https://hashnode.com/tag/embedded-systems)
-   [#beginnersguide](https://hashnode.com/tag/beginnersguide)

## Written by

[Omar Hiari](https://hashnode.com/@omarhiari)

@omarhiari

  
[View profile](https://hashnode.com/@omarhiari)

I am an 📟 Embedded Engineer with years of experience in both industry 🏭 and academia 🏫. Passionate Mentor 👨‍💼 and Instructor 👨‍🏫. Rustacean 🦀

## Responses 1

Markdown supported · ⌘↵ to post

[Christian Foucher](https://hashnode.com/@Valda60)

[Aug 24, 2023](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c/comment/64e730762a4db2f7752735bb)

Hello Omar, Do you know what happens when the adc.read function returns 0 ? Temperature computation will do a floating division by 0 (=+INF). I have tested on Wokwi, it seems OK (Temperature -273.15 Celcius). Rust follows the IEEE 754 rules.

[Omar Hiari](https://hashnode.com/@omarhiari)

[Aug 24, 2023](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c/comment/64e730762a4db2f7752735bb#reply-64e733962a4db2f775273654)

Thanks for pointing it out. I actually haven't tested for that case, however, it seems that dividing by zero in floating point (f32 or f64) does not panic in Rust. Instead, it results in a NaN (Not a Number) and continues operation. Here's where I found some insight:

[users.rust-lang.org/t/how-should-i-handle-f64-div…](https://users.rust-lang.org/t/how-should-i-handle-f64-division-by-zero-panic-elegantly/32485)

[internals.rust-lang.org/t/should-x-0-be-an-error/…](https://internals.rust-lang.org/t/should-x-0-be-an-error/2252)

[Christian Foucher](https://hashnode.com/@Valda60)

[Aug 25, 2023](https://hashnode.com/posts/esp32-standard-library-embedded-rust-analog-temperature-sensing-using-the-adc/64df0bf057b35200b444521c/comment/64e730762a4db2f7752735bb#reply-64e8ad5cf659a80ea33ed576)

[Omar Hiari](https://hashnode.com/@omarhiari) [play.rust-lang.org](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d62f808a88b8798568ad0323173f36e2)
