Skip to content

A portable humidity sensor using an RP2040 Feather and eInk display

License

Notifications You must be signed in to change notification settings

jwillikers/humidity-sensor-circuitpython

Repository files navigation

Humidity Sensor CircuitPython

pre-commit Ruff

A simple humidity sensor using the Adafruit Feather RP2040, monochrome eInk Display FeatherWing, and HTU31D humidity sensor, written in CircuitPython.

Humidity Sensor

Humidity Sensor Demo

How it Works

The humidity sensor samples the relative humidity and temperature once every second. After five minutes, it finds the median of these values and updates the readings shown on the display. A median is simple and accounts for outliers, making the displayed readings more consistent than one-off samples. When the humidity sensor starts up, it immediately displays the value of a single reading from sensor. This avoids undue delays for users.

Shortcomings

Efficiency

The battery life is abysmal. The 105 mAh battery fails to sustain this power-hungry machine for more than several hours. I’m hoping to get closer to a week’s worth of life out of a single battery life. Improvements to energy efficiency include the following.

Power Optimizations
  • ❏ Lower the clock speed.

  • ❏ Store sensor readings with Direct Memory Access, aka DMA, to avoid waking the microcontroller as frequently. Unfortunately, I don’t believe this functionality is available in CircuitPython at this time.

  • ❏ Put the RP2040 into deep sleep, waking only to refresh the screen. If values must be stored in non-volatile memory, consider using an FRAM breakout instead of the onboard EEPROM.

  • ❏ Increase the interval between updates of the screen.

  • ❏ Cut the line to the LED on the humidity sensor breakout.

Deployment

The required libraries are deployed with pipkin. The required font bitmap used by this project is from the Adafruit CircuitPython framebuf example. Simply install the code.py file and font/font5x8.bin to the board’s root directory.

Getting Started

The instructions here setup the software for the Feather RP2040. It is assumed that you are on and familiar with Linux and using CircuitPython on microcontrollers.

💡

To access the serial connection to the Feather RP2040 without requiring superuser privileges, add your user to the dialout group.

sudo usermod --append --groups dialout $USER

Now restart for the change to take effect.

  1. Install just by following the instructions in the installation section.

  2. Clone this project’s repository.

    git clone https://github.com/jwillikers/humidity-sensor-circuitpython.git
  3. Change to the project’s root directory.

    cd humidity-sensor-circuitpython
  4. Install just by following the instructions in the installation section.

  5. Hold down the button marked bootsel on the Feather RP2040 while plugging it in to your computer with a USB-C cable.

  6. To download and install CircuitPython, run just install-circuitpython.

    just install-circuitpython
  7. Now copy over the U2F bootloader to the RP2040.

    cp ~/Downloads/adafruit-circuitpython-adafruit_feather_rp2040-en_US-7.2.5.uf2 /run/media/$USER/RPI-RP2
  8. Wait for the file to finish copying, after which the Feather RP2040’s onboard storage should automatically be mounted. This is mounted at /run/media/jordan/CIRCUITPY on my machine.

  9. Run just init to initialize the venv.

    just init
  10. Mount the Feather RP2040 if needed.

    udisksctl mount --block-device /dev/sda1
  11. Run just install to install everything to the Feather.

    just install

Development

It’s recommended to use the provided pre-commit checks when developing.

  1. Run just init-dev to initialize the virtual environment for development. This will install all of the necessary dependencies and the pre-commit hooks.

    just init-dev
  2. To update dependencies, run just update.

    just update
  3. Use just --list to list other available tasks.

    just --list

Documentation

CircuitPython Documentation

Contributing

Contributions in the form of issues, feedback, and even pull requests are welcome. Make sure to adhere to the project’s Code of Conduct.

Open Source Software

This project is built on the hard work of countless open source contributors. Several of these projects are enumerated below.

Code of Conduct

Refer to the project’s Code of Conduct for details.

License

The font bitmap, font/font5x8.bin, is © 2021 ladyada for Adafruit Industries and licensed under the MIT license.

This repository is licensed under the GPLv3, a copy of which is provided here.

© 2021-2024 Jordan Williams

Authors