It had come to my attention that there was a growing damp spot on my kitchen ceiling – after ripping through some drywall and inspecting for leaks, the prognosis was bathroom humidity issues due to faulty grout in the shower. In my most optimistic take on the situation, I reasoned a fun project could be to make a humidity sensing solution to monitor for humidity problems (after a fix was put in place). And so I began designing!
My main design goal is to place humidity sensors in the walls while the drywall is off, and leave them sealed in there. Therefore, I want them to be cheap enough that I don’t care to get them back again. Bonus points if they look sufficiently creepy for any future homeowners performing renos.
With my economic goals in mind, I quickly found the cheapest radio solution I could – the nrf2401 -the exact one I purchased is available here: kuman 10pcs nRF24L01+ 2.4GHz Antenna Wireless Transceiver RF Transceiver Module Arduino Raspberry Pi Compatible K19.
These devices perform basic ISM 2.4Ghz band packet-based communications, and have a number of useful features. One receiver can receive from up to 6 transmitters simultaneously. Note – this device does not use any TCP/IP stack!
Note – the ESP8266 may have been a better solution overall, as it has an on-board micro. I have not yet evaluated it!
The next step was to decide on a microprocessor and humidity sensor. I decided to stick to the Atmel family of microcontrollers, due to my familiarity with them, allowing me to get something working as quickly as I am able. I opted for the ATTiny series due to their minimalist features and low power consumption. In terms of minimizing time to get something working, I already have an Olimex AVR-ISP-MK2 capable of flashing them. You can get yours here:
Olimex AVR-ISP-MK2 USB Compatible AVR programmer with ICSP PDI TPI Support
Ultimately I settled on the ATTiny87 as it had the following features:
- Programmable via AVRISP 6-pin interface
- Features I2C Master peripheral – necessary for talking to some humidity sensors
- Features SPI Master peripheral – necessary for talking to nRF radio
- Features analog input – useful if I opt for an analog-based humidity sensor
- It can run directly from a coin cell battery
I purchased mine from digikey – they are also available via amazon at: ATTINY87-SU 1 Lot/5PCS
For the humidity sensor, I settled on the Silicon Labs Si7006, as it was the cheapest I2C-based humidity sensor that I could find on digikey.
Circuit, PCB Design for Transmitter
With the major components selected, I plugged my design into KiCAD and got a basic PCB layed out:
I have open-sourced the design files, the KiCAD project is available here: https://github.com/trdenton/humsensor/tree/master/tx_pcb
You can also order the PCBs directly from PCBWay here: https://www.pcbway.com/project/shareproject/W04152ASD12_humxmit_v2.html
You can see (most of ) the parts populated here (note – the white wires are for power and ground connections during testing).
BOM is as follows:
|Part||Digikey part # / spec|
|R1,R2,R3,R5||generic 10k, 1206 size|
|R4||generic 220R, 1206 size|
|C1,C2,C3||generic 0.1uF, 1206 size|
Software Implementation – Transmitter
The current status of the project is as such:
- Software load for transmitter board is communicating with the nRF24L01+, sending arbitrary data
- I2C peripheral is configured for the ATTiny87
- Have not tested reading the Si7006 sensor yet
Source code for the transmitter is available here – still a work-in-progress: https://github.com/trdenton/humsensor/tree/master/hum_sw/humtx
The repository contains a Makefile with the following targets:
- Compiles the source code to target .hex file
- Uploads the hex file via avrdude
Circuit for Receiver
Software for Receiver
The software for the receiver is currently a work in progress – it’s goal is to receive from multiple transmitters, and log the data back to a PC via serial port. Eventually, this data will get put into a historical database.
You can check out the current software here: https://github.com/trdenton/humsensor/tree/master/hum_sw/humrx
Stay tuned for the following tedium action-packed items!
- Test reading the Si7006 device
- Test wireless range v. TX power for nRF24L01 – it should transmit through a sheet of drywall
- Enable low-power mode on the ATTiny87 for optimum battery life
- Populate another board,
- Write a program that can log the receiver’s readings to a database