# Storage humidity and temperature monitor

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/054/229/medium800/adafruit_products_board.jpg?1526907145)

There are many things that should be stored at a more or less specific relative humidity. If not, they will dry out or get moldy. There are solutions for this, such as [Bodeva](https://www.bovedainc.com/). These packets absorb or release moisture to maintain equilibrium at a specific relative humidity. The problem is that these things wear out over time and stop working. But how do you know? You can put indicator paper in the container, but unless it’s clear you have to open it to check, and that messes up the equilibrium.

The answer? Technology, naturally. Goals for this project:

1. Audible alert if the relative humidity is too high or too low
2. Low power, last months on a single battery charge
3. No larger than a small jar

&nbsp;

## Parts List

This project uses the following parts:

### Part: Adafruit Trinket M0
quantity: 1
 Adafruit Trinket M0 - for use with CircuitPython and the Arduino IDE
[Adafruit Trinket M0](https://www.adafruit.com/product/3500)

### Part: TPL5110 Breakout
quantity: 1
Adafruit TPL5110 Low Power Timer Breakout
[TPL5110 Breakout](https://www.adafruit.com/product/3435)

### Part: Si7021 Breakout Board
quantity: 1
Adafruit Si7021 Temperature and Humidity Sensor Breakout Board
[Si7021 Breakout Board](https://www.adafruit.com/product/3251)

### Part: Piezo Buzzer
quantity: 1
Piezo Buzzer - PS1240
[Piezo Buzzer](https://www.adafruit.com/product/160)

### Part: Battery Connector
quantity: 1
JST-PH 2-Pin SMT Right Angle Breakout Board
[Battery Connector](https://www.adafruit.com/product/1862)

### Part: LiPo Battery
quantity: 1
Lithium Ion Polymer Battery - 3.7v 500mAh
[LiPo Battery](https://www.adafruit.com/product/1578)

### Part: LiPo Charger
quantity: 1
Adafruit Micro Lipo - USB LiIon/LiPoly charger - v1
[LiPo Charger](https://www.adafruit.com/product/1304)

# Storage humidity and temperature monitor

## Hardware

When this need arose, I was playing around with the new SAMD21 boards. The Trinket M0 was one such board. Tiny yet capable enough to do plenty of useful things. It exposes an I2C interface so connecting sensors is easy. And I just needed one: a relative humidity sensor and I knew just the sensor for the job.

For my smart home sensor nodes, I am using the Si7021 temperature and relative humidity sensor. Adafruit has this on a breakout board which makes it easy to use. The breakout also has the benefit of being breadboardable while you are prototyping.&nbsp; My need was for a relative humidity sensor, but having a temperature sensor bundled in could be useful for some applications.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/217/medium800/adafruit_products_humidity_monitor.png?1526846033)

Additionally I needed some way of alerting when humidity is out of range. For this I used a plain piezo buzzer that my code can control the pitch of.&nbsp;

Humidity change in a closed environment should be slow, and those humidity control packs last quite a while, so I felt no need to have it checked frequently. Taking a humidity reading every couple hours is plenty. This also means less power being used over a period of time, so battery power is easier to deal with. I decided to use a 500 mAh lipo battery as it was about the same size as the space I was building for and would tuck under the circuit board. My deployed units have been working for 6 months on the initial charge.

To make this work I used the TPL5110 breakout that will power up the Trinket every so often (up to about every 2 hours). When the job is done a single output tells the TPL5110 to power down the Trinket and start the timer again. This makes the code much simpler: no loop, no sleeping, just check the humidity and shut down if it’s good. If not, alert until it is, then shut down.

# Storage humidity and temperature monitor

## Software

If you are unfamiliar with programming the Trinket M0 with the Arduino IDE, you can get familiar with this board with the [Introduction to the Adafruit Trinket M0 tutorial](../../../../adafruit-trinket-m0-circuitpython-arduino?view=all "Adafruit Trinket M0 tutorial").

The code is pretty much as simple as the hardware. The falling/rising tone arrays contain a sequence of frequencies that are played in sequence by the `chirp()` function. Which set of tones is played is decided based on the argument to `chirp()`.

The `check_rh()` function reads the sensor and compares the humidity with the target, allowing for +/- 5% variability. If the reading is low, -1 is returned, +1 if it's high, and 0 if it's in range.

The `warn_if_out_of_range()` is passed the initial reading comparison result, and immediately returns if the reading was in range. If it was out of range it sounds the appropriate alarm, waits briefly, and checks again. This repeats until the reading is back in range (or the battery goes empty).

Being an Arduino sketch, there are the usual `setup()`and `loop()` functions. `setup()` initializing things and calls `warn_if_out_of_range()`.&nbsp;`loop()` simply toggles the shutdown signal to the TPL5110 to put the system to sleep.

The result is that the system wakes up, and if the reading is in range goes immediately back to sleep. Otherwise it stays awake periodically sounding the alarm until it goes back in range.

The current code only looks at the relative humidity. The Si7021 can also provide temperature readings which could be useful if desired.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Humidity_Alarm/Humidity_Alarm.ino

# Storage humidity and temperature monitor

## Building

I made a prototype board to test out the design. Pictures below show the sequence of build steps. This [can be assembled on a breadboard](https://www.adafruit.com/product/239 "breadboard")&nbsp;or [protoboard](https://www.adafruit.com/product/1608) easily, and the circuit board shown is available from [Aisler](https://aisler.net/p/NBXELLPG).

You will need to solder the supplied male header pieces on the sides of the breakouts. This may best be done with the header trimmed to the proper number of pins and pressed into a breadboard then placing the breakout board on top. You may wish to refer to the tutorial [Collin's Lab: Soldering](../../../../collins-lab-soldering?view=all "Collin's Lab: Soldering").

![](https://cdn-learn.adafruit.com/assets/assets/000/054/218/medium800/adafruit_products_board.jpg?1526849073 The board from the top.)

![](https://cdn-learn.adafruit.com/assets/assets/000/054/220/medium800/adafruit_products_Si7021.jpg?1526849127 The Si7021 breakout with the female header strip.)

![](https://cdn-learn.adafruit.com/assets/assets/000/054/219/medium800/adafruit_products_mounted_underboard.jpg?1526849105 The sensor mounted below the board.)

![](https://cdn-learn.adafruit.com/assets/assets/000/054/221/medium800/adafruit_products_cutting_the_lid.jpg?1526849513 Cutting a hole in the lid for mounting the sensor.)

The sensor is placed inside the jar and, for my build, long headers are used to go through the lid of the jar to the electronics on top of the lid.

A four conductor wire could also be used between the board in the jar and the board outside.&nbsp;

Be sure to seal the lid connection so humidity cannot get inside. Also, do not let metal lid edges touch bare wires which could cause an electrical short circuit.

![](https://cdn-learn.adafruit.com/assets/assets/000/054/222/medium800/adafruit_products_sensor_in_lid.jpg?1526849575 The sensor mounted in the lid.)

![](https://cdn-learn.adafruit.com/assets/assets/000/054/223/medium800/adafruit_products_mounted_under_lid.jpg?1526849620 Mounted sensor from below.)

![](https://cdn-learn.adafruit.com/assets/assets/000/054/224/medium800/adafruit_products_done1.jpg?1526849672 Finished build.)

The design has proven itself and prototype units have been working reliably for 6 months on the initial battery charge. A more productized version 2 is currently being designed.


## Featured Products

### Adafruit Trinket M0 - for use with CircuitPython & Arduino IDE

[Adafruit Trinket M0 - for use with CircuitPython & Arduino IDE](https://www.adafruit.com/product/3500)
The&nbsp;Adafruit Trinket M0 may be small, but do not be fooled by its size! It's a tiny microcontroller board, built around the Atmel ATSAMD21, a little chip with _a lot_ of power. We wanted to design a microcontroller board that was small enough to fit into any project, and low...

In Stock
[Buy Now](https://www.adafruit.com/product/3500)
[Related Guides to the Product](https://learn.adafruit.com/products/3500/guides)
### Adafruit TPL5110 Low Power Timer Breakout

[Adafruit TPL5110 Low Power Timer Breakout](https://www.adafruit.com/product/3435)
With some development boards, low power usage is an afterthought. Especially when price and usability is the main selling point. So what should you do when it's time to turn around and make that project of yours run on a battery or solar? Sure you&nbsp;_could_&nbsp;try to hot-air...

In Stock
[Buy Now](https://www.adafruit.com/product/3435)
[Related Guides to the Product](https://learn.adafruit.com/products/3435/guides)
### Adafruit Si7021 Temperature & Humidity Sensor Breakout Board

[Adafruit Si7021 Temperature & Humidity Sensor Breakout Board](https://www.adafruit.com/product/3251)
It's summer and you're sweating and your hair's all frizzy and all you really want to know is why the weatherman said this morning that today's relative humidity would max out at a perfectly reasonable 42% when it feels more like 77%. Enter the&nbsp; **Si7021 Temperature +...**

In Stock
[Buy Now](https://www.adafruit.com/product/3251)
[Related Guides to the Product](https://learn.adafruit.com/products/3251/guides)
### Piezo Buzzer

[Piezo Buzzer](https://www.adafruit.com/product/160)
Piezo buzzers are used for making beeps, tones and alerts. This one is petite but loud! Drive it with 3-30V peak-to-peak square wave. To use, connect one pin to ground (either one) and the other pin to a square wave out from a timer or microcontroller. For the loudest tones, stay around 4 KHz,...

In Stock
[Buy Now](https://www.adafruit.com/product/160)
[Related Guides to the Product](https://learn.adafruit.com/products/160/guides)
### JST-PH 2-Pin SMT Right Angle Breakout Board

[JST-PH 2-Pin SMT Right Angle Breakout Board](https://www.adafruit.com/product/1862)
A simple 2-pin connector soldered onto a breadboard-friendly breakout. This is compatible with the "JST PH 2-pin" connector. Mates perfectly with all our 1-cell [LiPoly](//www.adafruit.com/search?q=lipoly) and [LiIon batteries](//www.adafruit.com/search?q=liion)...

In Stock
[Buy Now](https://www.adafruit.com/product/1862)
[Related Guides to the Product](https://learn.adafruit.com/products/1862/guides)
### Lithium Ion Polymer Battery - 3.7v 500mAh

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
### Adafruit Micro Lipo - USB LiIon/LiPoly charger

[Adafruit Micro Lipo - USB LiIon/LiPoly charger](https://www.adafruit.com/product/1304)
Oh so adorable, this is the tiniest little lipo charger, so handy you can keep it any project box! Its also easy to use. Simply plug in the gold plated contacts into any USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There are...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1304)
[Related Guides to the Product](https://learn.adafruit.com/products/1304/guides)
### Adafruit Perma-Proto Quarter-sized Breadboard PCB - Single

[Adafruit Perma-Proto Quarter-sized Breadboard PCB - Single](https://www.adafruit.com/product/1608)
Customers have asked us to carry basic perf-board, but we never liked the look of most basic perf: it's always crummy quality, with pads that flake off and no labeling. Then we thought about how people **actually** prototype - usually starting with a solderless breadboard and...

In Stock
[Buy Now](https://www.adafruit.com/product/1608)
[Related Guides to the Product](https://learn.adafruit.com/products/1608/guides)

## Related Guides

- [Adafruit Si7021 Temperature + Humidity Sensor](https://learn.adafruit.com/adafruit-si7021-temperature-plus-humidity-sensor.md)
- [Adafruit Trinket M0](https://learn.adafruit.com/adafruit-trinket-m0-circuitpython-arduino.md)
- [Chameleon Scarf](https://learn.adafruit.com/chameleon-scarf.md)
- [3D Printed Flora Band](https://learn.adafruit.com/3d-printed-flora-band.md)
- [Trinket / Gemma IR Control](https://learn.adafruit.com/trinket-gemma-ir-remote-control.md)
- [Breadboards for Beginners](https://learn.adafruit.com/breadboards-for-beginners.md)
- [Flora+NeoPixel LED Skateboard Upgrade](https://learn.adafruit.com/flora-neopixel-led-skateboard-upgrade.md)
- [Cosplay Glow Fur Raver Bandolier](https://learn.adafruit.com/cosplay-glow-fur-raver-bandolier.md)
- [Adafruit MicroLipo and MiniLipo Battery Chargers](https://learn.adafruit.com/adafruit-microlipo-and-minilipo-battery-chargers.md)
- [Steven Universe Wearable, Fusable Gem](https://learn.adafruit.com/steven-universe-wearable-fusable-gem.md)
- [How to Program SAMD Bootloaders](https://learn.adafruit.com/how-to-program-samd-bootloaders.md)
- [AdaBox 014](https://learn.adafruit.com/adabox014.md)
- [Custom Controllers for MakeCode Arcade](https://learn.adafruit.com/custom-controllers-for-makecode-arcade.md)
- [Make a Snow Globe with Circuit Playground Express & MakeCode](https://learn.adafruit.com/make-a-snowglobe-with-circuit-playground-makecode.md)
- [Han Solo Blaster Cosplay](https://learn.adafruit.com/han-solo-blaster-cosplay.md)
- [Mini VOTE Keyboard](https://learn.adafruit.com/vote-keyboard.md)
