Code Monkey home page Code Monkey logo

esp32temp's Introduction

esp32temp

Temperature measurement with ESP32 and DS18b20 sensor(s)

How to build it

This example has been tested on a freshly installed Debian 12 system. It should not be too hard to adapt for other distros out there.

First install OS dependencies for building the bits and pieces, and then install Rust itself.

sudo apt -y install build-essential curl git libssl-dev libudev-dev pkg-config python3-venv

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
chmod 755 rustup.sh
./rustup.sh

. $HOME/.cargo/env
rustup toolchain add nightly

Then install a bunch of tools for cross compiling, flashing etc.

# optional & useful
cargo install cargo-binutils cargo-embed cargo-flash cargo-generate cargo-update probe-run

cargo install espmonitor espup ldproxy flip-link
cargo install cargo-espflash --version 3.0.0-rc.2
cargo install espflash --version 3.0.0-rc.2
espup install

Now actually obtain the source code and build out firmware.

mkdir $HOME/git && cd $HOME/git
git clone https://github.com/sjm42/esp32temp.git
cd esp32temp

cargo build -r

Flash it on the chip!

cargo run -r

Occasionally, we run these spells to keep our tools up to date.

rustup update
espup update
cargo install-update -a

Support for ESP32 and ESP32-C3

By default, the source code and configs are made for supporting ESP32. Support for ESP32-C3 is easy to do with 3 changes.

  • in .cargo/config.toml change the target xtensa-esp32-espidf to riscv32imc-esp-espidf i.e. comment out the first one and remove the comment mark from the other
  • in rust-toolchain.toml comment out the channel="esp" line and remove the comment chars on two lines below the "for ESP32-C3" comment lines.
  • optionally in Cargo.toml change default = ["esp32s"] to default = ["esp32c3"] in the [feature] section.

Support for other ESP32 boards?

It should be easy to support almost any ESP32 versions with WiFi. Just check the pin assignments inside src/bin/esp32temp.rs starting after line 80 (at the time of writing). There we have an assignment to Boxed array onew_pins that will hold the pins we are probing for sensors. Those assignments are behind feature gates aka conditional compilation and we can easily add more of them to support new hardware variants.

Just add more features into Cargo.toml and assign the usable gpio pins accordingly and there you go.

esp32temp's People

Contributors

sjm42 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.