Feature

Keeping Cosy

Temperature & Humidity Datalogger

Johann Wyss

Issue 15, September 2018

What does a maker do to keep track of the ambient temp and humidity in their PLA filament storage cabinet? They whip up a clever datalogger using common parts.

OK so this unit isn’t going to keep you warm, but it’ll help you monitor the environmental conditions. Developed by Johann Wyss to monitor his PLA filament storage container, complete with a tidy case. We caught up with him to find out more.

inside
Complete with push button to show Min/Max readings.
push button
Johann prefers to 3D print a case rather than having exposed circuit boards.

We have seen lots of Temp / Humidity displays made with Arduino. Tell us what’s unique about yours?

I have opted to make mine using the most easily available components possible, You can walk into any store selling electronics components and purchase everything you need to make this device ie the 1602 LCD and the DHT 11 temp and humidity sensor.

I’m guessing the 3D printed enclosure also makes this somewhat unique, I often see electronics projects just as exposed circuit boards. I personally rather build everything into an enclosure, which is what originally got me interested in 3D printing / rapid prototyping technology.

fritzing

It’s definitely great to see it fully finished. While it’s not always needed for a prototype, it helps complete something that you’re going to use long term. It looks great! Did you look at anything else for measurement, or were you settled on the DHT11?

Yeah, I picked the DHT11 sensor as it was readily available at Jaycar or Altronics meaning the project would be easy for anyone to acquire the parts locally. It also had an existing library meaning it was pretty much easily available to everyone.

With that said it is fairly slow and isn’t all that accurate, However, given the device is only needed to monitor the humidity and temperature inside my PLA filament storage container it is more than sufficient.

Yes - the cost of a more precise sensor isn’t often justified for these types of projects. The DHT11 is “near enough”. Did you test your design on breadboard initially, before moving to the Veroboard?

I did, as with all my projects I made sure it all worked before soldering it down onto perfboard. This gave me the chance to rectify a few issues I had with the initial design. For example, the DHT11 seemed to be unstable when powered from a DC supply and not the USB. To solve this I used 2 capacitors on the 5v rail. A 47uF electrolytic to ensure a constant stable voltage in parallel with a 0.1uF ceramic capacitor to ensure there was minimal noise. The Arduino Nano would normally have these, however, for some reason, they were insufficient in this project or perhaps the DHT11 is a little more sensitive.

Awesome! How have you tackled the datalogging aspect, including capture and display of the min / max data?

Originally I used an interrupt and a timer which would increment a register every period x. Once the register reached value it would take a reading etc. However, I ran into an issue with the interrupt and the DHT11 library which made me rethink it.

The final code simply uses a counter which I increment every cycle of the main loop. Once the counter reaches or exceeds 200 the program enters the read phase via an if statement. In this phase, the DHT11 sensor value is read and a timer variable incremented.

The 3D Printed Case

oscilloscope
An oscilloscope was used to time each loop of the program. Here, dt (Delta) is 2.495 seconds.
3d case

So many of us build projects and either have them sitting about with the PCBs exposed or stuffed into an oversized Jiffy box, for example.

In issue #011 we featured Johann's 3D Printed Bluetooth Speaker, which looked just as polished as this project. What we admire about Johann's projects is that he makes them complete with well designed 3D printed cases.

As you will read later in this feature, Johann has designed a 3D printed case that can be re-purposed for future projects. Providing that the circuit can fit onto a 50mm × 70mm perfboard, it just slides into the case without any modification. The only part to 3D print is the smaller rear panel for sensors and other connectors that the circuit requires. Clever!

The program then checks the current value from the DHT11 and compares it against the recorded min and max values. If the value is lower or higher respectively the value is replaced with the current value. In order to ensure the data is kept relevant, I needed a way to reset the data. I opted to simply reset the min and max values every 24 hours.

Since I was having difficulty getting the timers to work with the DHT11 library the easiest way I could think of to keep track of time was a counter. If I incremented a counter every loop of the program I could easily convert that to units of time.

I used the inbuilt LED pin 13 as an indicator along with the serial monitor to figure out each loop took approximately 2.5 seconds to execute. To verify this I used my oscilloscope connected to pin 13 to verify 100%, the time it took for the program to complete one cycle. You can see this on the screenshot provided (left).

So knowing the time the program took to complete a cycle all I had to do was increment a variable by that amount in this case 2.495.

There are 86400 seconds in 24 hours therefore to reset the min and max values I opted for an if statement which would reset the values in min and max if the counter was or exceeded 86400.

Whilst it does not account for any discrepancy etc. it is more than suitable for this simple project.

For the datalogging side, it uses the serial plotter built into Arduino to display the historical data from the DHT11 sensor.

Sounds like a great solution overall. Your 3D printed case makes for a neat and polished final unit - did it take many iterations to get the design perfected?

This time it did take quite a bit of “iterative tinkering” to get what I wanted out of the design. My first case quite foolishly was only 2 pieces. This means there was a significant amount of support material which was difficult to remove from the small enclosure. To minimize the waste I cut the enclosure into two and designed a lip on one half to slot into the other. This made the enclosure 3 individual pieces to 3D print but significantly easier to assemble.

I opted to make the enclosure as re-usable as possible, as such it is designed to fit the cheap and readily available 50mm × 70mm perfboard and the common 1602 LCD meaning that the enclosure can easily be modified for other projects.

That’s a great idea - since you could certainly use that base platform for many projects. Are there any extra features you find yourself wanting or is what you have just enough?

I really regret not using the Nokia 5110 LCD and making the device battery operated. It would easily boost the usability of the device and make it a much more useful item.

That’s not a bad idea! Perhaps for the v2.0! What was the simplest, and the hardest part of building your datalogger?

The simplest part of the project was the programming in Arduino IDE. Using the LCD library and the DHT library made the program very easy to write. The hardest was designing the enclosure, having multiple parts all interlock together isn’t a trivial task. It took significantly longer to design the case than it did to design the circuit, build the circuit and write the program combined.

That’s often the case with making enclosures for simple projects! But it’s worth the effort and looks great! If you started from scratch, would you change the approach, or was it about as successful as you wanted it to be?

If I had the chance to redo this project I would not have used the 1602 LCD. While it is very simple to use, it requires 5V, which limits the power supply options quite significantly. Making it impractical for battery operation etc. Starting again I would use the Nokia 5110 LCD which can easily operate at the voltages of a lithium cell, I would also switch the Arduino Nano with an ATmega168 DIP IC again significantly reducing the power demands allowing the device to be easily powered directly by a lithium cell.

It does what I needed it to do, but having it battery powered would make it much more useful.

It would certainly add some portability, depending on your required application. What is the biggest thing you’ve learnt, having developed your project?

I think the best take home from this project was the use of interrupts in a project using serial print functions etc. It can cause significant issues which can be insanely complex to solve. Making it less than ideal in projects using time-sensitive communication protocols. Although I didn’t learn how to get them to work nicely together I did learn what to expect and where to look for a solution.

The journey is often as important as the end result with DIY! What amazing new project are you working on now?

I’m still working on a linear lab bench power supply I started well over a year ago with marginal success. I have also started a fairly simple but somewhat awesome project which is certainly useful to electronics beginners which I intend to send to you in the near future.

Fantastic, we look forward to seeing what you come up with!

Johann Wyss

Johann Wyss

Electrical fitter and Electrical / Electronics Engineering Student from QLD, Australia.