Arduino Temperature / Humidity Sensor

The projects I do tend to fall in one of two buckets – either proof-of-concept (so I can learn new stuff) or items that have some sort of functional use. The need for this project came about when my wife was prodding me about the humidity in the house and whether our humidifier was doing it’s job correctly. Most people would just go out and buy a temp / humidity sensor and be done with it. However, if you have a look around here, you will see that I don’t fit that mold. Instead, I decided to build an accurate temp / humidity sensor with a Sensiron SHT11 to read the values, a RBBB Arduino kit to process everything and an Adafruit 128×32 OLED to display the results – all wrapped up in… LEGO! Read on for more…

Admittedly, I would not normally spend the money required to outright build this gizmo (approx $95 incl shipping for all parts). Instead, I was able to acquire the parts for a fraction of this price. As a result, the purpose of this build is twofold. 1) Create a sensor that can be used in my house on an ongoing basis; 2) Review the parts to provide insight for those considering using them for similar or other projects.

There were a few goals that I wanted to achieve with this project. Make it small and compact, easy to use, and conserve as little power as possible. Getting it into a small package was aided by the RBBB. I could have gone a step further by just making a standalone Atmega, but the LEGO shell was my starting place and everything fit fine within the space it had. For power conservation, I used the sleep abilities of the chip and tied it to Interrupt2 tied to the toggle switch. Pushing the switch ‘in’ would trigger the interrupt and wake the unit. I also have power for the OLED and the SHT11 sensor shut down just before it goes to sleep, and back on immediately after it wakes. To do this, I used 2 digital pins set to HIGH / LOW as needed. I am running the unit off 2x 3V 2032 cells in series, which are put through a 3.3v regulator to power the board and components. When running with all components powered it pulls 12mA. In sleep mode it pulls 0.6mA. I’d like to get it lower, but think that my use of the regulator is partially killing it due to the voltage drop out.

The key to the accurate humidity / temp readings is the Sensiron SHT11 sensor. It’s tiny – really tiny. There are 4 connections: 3.3V- 5V, GND, Data, CLK. In order to protect the sensor, it has been mounted to the side of the unit inside a clear plastic housing. The housing has a hole in the side to allow air to flow freely, but limits the any water that might find its way in there (because you never know when it might rain inside the house

Since everything is so small, I used very fine 30 gauge silver plated copper wire for this. It worked quite well for what I needed to do here.

Before migrating all the components into the project, I set everything up on a breadboard and used the Uno to test the sketches. Interestingly, I found getting the 5-way switch working the most challenging. It has a common anode I am using as both an Interrupt link (Pin2) as well as toggle switch for scrolling the OLED.

Below showing the completed RBBB kit. Initially, this came with an earlier Bootloader, but I updated to the Uno one with ease.

The next step was to start fitting the components into the case. The first parts to go in were the switch and red/green status LED. The LED was a pull from an old portable DVD player. After that was done, one side was cut to make room for the length of the RBBB kit. Being a die-hard LEGO fan and spending most of my life building, I was always against bastardizing LEGO for things like this – until I discovered Arduino / micro-controllers. Sorry AFOL’s. The 3rd pic shows the bits all soldered together using that nice 30Ga wire. The 4th shows a test fit with the RBBB inserted. I made the mistake of completing the RBBB kit as per instructions only to realize that I did not want the rows of breadboard pins as would not need them.. So, out came the solder sucker and I removed them (hence the burn marks you see in other pics). In the last picture, you can see a side view showing the SHT11 sensor.. Did I mention this thing is tiny!?

The Verdict:

Adafruit 128×32 OLED: If you are looking for a crisp display with a small footprint, then this is the unit for you. Don’t expect to be able to read this thing from afar. However, up close, the display is clear, and crisp. Because it does not have a backlight, and each pixel is self- illuminated, it has low power consumption and is easy to read. Out of the box, the display is slow to render for anything where rapid updates are necessary. However, the driver can easily be modified to use the Arduino SPI hardware to speed up its response. For this purpose, its not really necessary as I am not drawing rapid graphics or animating. If you are doing that, then you want to do this easy mod. Just remember that you must then also use the dedicated hardware SPI pins.

Sensiron SHT11: Did I mention the sensor is small? Ok, I know I did – so it’s small. This is great for integrating it into small projects like this. Sensiron claims the unit has a high degree of accuracy (+/- 0.4’C and +/-3% RH). When pitching the results against other temperature gauges in our house, I had different readings on all of them. When I tested the readings against a classic mercury unit, it was off by about 1 degree. It also responded well to rapid temperature changes at about a 1-2 hz rate. Not super fast, but good enough for measuring changes in room temperature. I did some tests where I set the update frequency to less than 500 Ms and it still took about 1+ seconds to return a result – so it seems that the sensor requires this time to produce and return an accurate reading.

Modern Device RBBB Kit: If you are looking for a small Arduino footprint, then this is a nice unit. It is not the smallest out there, but good enough for most small projects. For the price of about $13 plus shipping you can get a full setup in either 3.3v or 5v, the board, parts and an Atmega 328P with bootloader. The only caveat is that it comes with the Diecimila Bootloader, but you can change it to whatever you like easily. Yes, I could have put together a standalone kit with a little more soldering, but considering time and cost, it is not really worth it.

5 Comments Already

Hi There, nice project. I have recently completed the code for Arduino using a similar (though cheaper, less accurate and bigger) sensor the DHT-11.

Your code is a bit mangled with HTML formatting now included, this makes it a little hard to read and understand it. Perhaps you could link to the files for download? That way interested people could examine it for themselves.

I am really interesting to it and may be could yo help me for the need I will explain here.

I am interesting to also have a Arduino temperature / humidity evaluator but in a fixed mode.
As it must have three specifications I explain it to you :
1) I need to have a Arduino that is able to read temperature and humidity (you just made it )
2) As I need to be able to extract both ;
a) hot air from my attic and
b) hot and humid air from my bath room
this Arduino with temperature and humidity detection (explained on the point 1) ) must be able to activate a big computer fan
3) it could be appreciate if it could be connected to a computer (or a ethernet router) that can then read the temperature and humidity and be able to specify (through a webpage) the limitatin of temperature and / or humidity that must start the air extraction
4) “cherry on the cake” the Arduino could be also powered even by pppoe

As I still never start to use Arduino do you thing this could be realized ?

Hi, it seems that what you described is possible with the Arduino and some additional hardware. You indicated pppoe (Point to Point Protocol over Ethernet). I think you meant to say PoE (Power over Ethernet). You can power an arduino and most components using a PoE-enabled Ethernet shield. However, you would have to look at the total current demand of your project (specifically your fan) and see what can be supported by the switch you would be using for your network (since it will be providing the PoE power as well). Also, you would have to determine if a computer fan would provide sufficient draw to move the air out of your attic. Most bathroom fans are 60+ CFM, and I don’t think computer fans are this powerful (lower voltage and speed). Good luck with your project!

I’m considering putting an arduino in the master bath to monitor humidity levels and throw a relay switch that I’ll wire the main bathroom fan to. Then, when humidity levels are back down to a more “normal” level reset the relay to turn the fan off so we can leave the fan running after we’ve left the room, but not have to come back to turn it off.

Nice writeup! I’m a software guy at heart who’s just recently started playing with Arduino and hardware and your writeups are very well done. Keep ‘em up!

Hi, congratulations for your work!
I have the SHT11 humidity and temperature sensor and the arduino uno board so i tried to compile your code.
However, the compiler does not find the libraries that you mention.. Where can I find these libraries?? As far as the avr/sleep and the avr/power, would I use the library avr? Also, I am not going to use the OLED display.. Do you have a simplier code to suggest? I just want to see the results of humidity and temperature on the serial monitor of arduino. My final target is to switch on a dehumidifier via a relay board but i can’t go on unless I take the right results from the sensor. Your help would be very important to me, because I have to finish my final year project. Thank you in advance.

PlastiBots is giving away a copy of Building Robots with LEGO Mindstorms NXT authored by yours truely! Contest ends March 31st. Enter for your chance to win. You email will only be used for this contest entry. Don't forget to share for more chances to win! (Pssst, the share link will show after you submit your entry)

Contest Rules & Disclaimer

1) Available to Continental US and Canadian users. Sorry, International users.
2) 1 winner will be randomly selected. 1 prize will be given away at the end of the contest.
3) The more you share, the more chances you have to win.
4) Spambots or any type of auto submission attempts will be monitored and entries removed.
5) The winner will be contacted via email. Full name and shipping address will b required to ship the prize.
6) Only the winner will be notified.
7) Contest ends March 31st.
8) Your email is being collected only for the purpose of this contest. It will not be used for any other purpose and will only be used to contact you should you be chosen as the winner.