A simple humidity sensor using the Adafruit Feather RP2040, monochrome eInk Display FeatherWing, and HTU31D humidity sensor, written in CircuitPython.
The hardware components comprising the humidity sensory are listed below.
Programming will require a USB-C cable and a computer.
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.
- 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 andfont/font5x8.bin
to the board’s root directory.
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 sudo usermod --append --groups dialout $USER Now restart for the change to take effect. |
-
Install just by following the instructions in the installation section.
-
Clone this project’s repository.
git clone https://github.com/jwillikers/humidity-sensor-circuitpython.git
-
Change to the project’s root directory.
cd humidity-sensor-circuitpython
-
Install just by following the instructions in the installation section.
-
Hold down the button marked bootsel on the Feather RP2040 while plugging it in to your computer with a USB-C cable.
-
To download and install CircuitPython, run
just install-circuitpython
.just install-circuitpython
-
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
-
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. -
Run
just init
to initialize the venv.just init
-
Mount the Feather RP2040 if needed.
udisksctl mount --block-device /dev/sda1
-
Run
just install
to install everything to the Feather.just install
It’s recommended to use the provided pre-commit checks when developing.
-
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
-
To update dependencies, run
just update
.just update
-
Use
just --list
to list other available tasks.just --list
Contributions in the form of issues, feedback, and even pull requests are welcome. Make sure to adhere to the project’s Code of Conduct.
This project is built on the hard work of countless open source contributors. Several of these projects are enumerated below.
Refer to the project’s Code of Conduct for details.
The font bitmap, font/font5x8.bin, is © 2021 ladyada for Adafruit Industries and licensed under the MIT license.
© 2021-2024 Jordan Williams