Zonnestroompanelen in Nederland

duurzaamheid achter de meter

(12) Multi temperature-humidity sensing

Multi temperature-humidity sensing with an Arduino Nano displayed on a 3.5″ color TFT screen

by Floris Wouterlood – Leiden, The Netherlands – March 8, 2016

Summary

This paper describes data acquisition with an Arduino Nano from eight DS18B20 temperature sensors and four DHT11 relative humidity sensors. The data are displayed on a 3.5″ 320×480 pixel color TFT screen.

Introduction

As a home owner living in a country with a moderate, often moist climate I am interested in the continuously changing relative humidity conditions and in the daily change in temperatures inside and outside my home. Monitoring various temperatures became more interesting when I acquired a solar thermal water heater together with several solar panels that each have their (micro)inverter. The temperature of a solar device is directly related to how successful it is running. Think about hot ‘solar’ water for your shower! Failure of such a device reveals itself by a flat temperature or a temperature that stays close to the ambient room temperature. Keeping an eye on temperatures may thus save energy.

Recently I started an attempt to reduce central heating energy use through playing with the unit’s hot water circulating water thermostat. For this I needed multiple temperature sensors at various strategic positions. An additional condition was that data should be displayed neatly arranged and immediately visible in an aesthetic manner.

With an Arduino microcontroller board equipped with temperature and relative humidity sensors my aim should be attainable. The condition to display all data permanently and visible at a single glance is better provided by a 320×480 pixel color TFT display than with a 16×2 or 20×4 character monochrome LCD display. This was a decisive factor to go for a TFT display.

The ‘Arduino’ marketplace supplies us with many cheap temperature and humidity sensors. For the relative humidity data acquisition I selected the DHT11 sensor and I decided to use this device in pairs to cope with their inaccuracy. While a DHT11 measures also temperature next to humidity they do so with a miserable accuracy range of two degrees Celsius. A much more accurate temperature sensor (tenth of degrees Celsius) is Maxim’s Dallas DS18B20. Its clever design allows multiple sensors running on a single bus. This is a very valuable feature given the fact that a TFT screen ‘consumes’ many digital pins on an Arduino board.

As TFT displays are typically marketed as shields, the Arduino Uno Mega would be the typical platform of choice. However, for the purpose of building an ultra compact monitoring device and also to challenge myself I started a project aiming at the creation of a multi-temperature- and humidity display with a 320×480 color TFT screen using the Arduino Nano as its microcontroller platform. The Nano’s attractiveness lies in its reduced dimensions which makes it a microcontroller board that can be hidden behind a big TFT display in a small assembly mounted in a modest, attractive casing.

Hardware

  • Arduino Nano microcontroller board;
  • 320×480 TFT display shield ILI9341 compatible;
  • 8 Dallas DS18B20 one-bus temperature probes taped to various pipes and devices;
  • 4 DHT11 relative humidity probes (purchased as three-pin breakouts; two pairs, each pair in a ‘pod’);
  • Resistors: 10kΩ pull up for the DHT, 4.6 kΩ for the DS18B20;
  • Power supply: 5V to the Nano via an USB power supply.

DHT11 ‘pod’

Two DHT11 breakout boards were mounted back to back, with an insulating foil in between, in a plastic vial (figure 1). The pins were soldered on a piece of cut-out prototyping soldering board. Pins 1 (VCC) and 3 (GND) of the pair were connected while the DATA pins (pin 2) remained separated. An assembled pod has four wires: VCC, GND and for each of the DHT11s a separate DATA wire.

 re 1. Self made pod containing two DHT11 humidity sensors back to back.

Dallas DS18B20 probes

These sensors can be purchased as individual parts or as ‘ready to use’ wire thermometers. I bought the parts and constructed my own sensors (figure 2) by soldering a color-coded wire to each pin of the sensor (red: Voo; black: GND; white: DQ) and protecting the soldered connections with a crimp sock. DS18B20s operate at 5V.

 figure 2. Maxim’s Dallas DS18B20 is a small and versatile temperature sensor.

320×480 TFT color display

I bought a nameless 3.5 inch color TFT LCD shield for the Arduino UNO (figure 3). Doing so is risky because there is no uniformity in TFT controllers, and nameless displays usually arrive without any documentation or software drivers. This particular display had two advantages: 1) it appeared compatible with the mcufriend.kbv library, 2) background lighting is very uniform, which makes this screen particularly attractive. Note that ordering this screen was a gamble. If gambling and experimenting are is not your favorite occupations an Adafruit 3.5″ 320×480 pixel color TFT touchscreen breakout with its lavish documentation and company support is recommended.

The TFT shield plugs nicely into an Arduino Uno but then covers non-connected pins that are necessary for getting sensor data. Wire connectivity between the microcontroller board and the TFT screen uses 16 wires, and an additional four wires are necessary for the SD slot to function. The total amounts to 20 wires capturing almost all available pins on an Arduino Nano! In my configuration I needed next to TFT connectivity another four pins on the microcontroller board to connect the four DHT11s, plus one pin for the one-wire DS18B20 connectivity. To free pins I sacrificed the SD connectivity. Pin connectivity between TFT display shield and the Nano is shown in figure 3.

 figure 3. Nameless 320×480 3.5″ TFT color display shield. A: back of the shield, B: connectivity scheme with the Arduino Nano.

From probe locations to the display: cable wiring.

Gear whose operating temperatures I wanted to monitor is mostly located in the loft, approximately 10 meters away from my tiny hobby office. The loft currently hosts five DS18B20 probes at various locations. An 8-wire twisted pair cable (cable #1) obtained from a computer store (plain network cable without connectors) was drawn from my office to the loft. Of the 8 available wires, only three were used: one 5V line (orange wire), one GND line (blue wire) and one wire for the DS18B20 data bus (white-blue striped wire). One advantage for the DS18B20 one-wire concept is that considerable cable distances are supported. I assume that twisted-pair cable favors signal separation as it does in fast computer networks.

A wiring diagram is shown in figure 4. ‘Attic’ temperature probes were taped onto the hot water and return pipes of the central heating (CH) unit (probes 01 and 02), on casings of solar energy grid tie inverters (probes 03 and 08), one sensor was left hanging loose (probe 04, ambient loft air temperature), and one was taped onto the hot tap water pipe coming out of the storage tank of the solar water heating system (probe 06) (as close as possible to the hot interior of the tank).

In addition I ran a twisted pair cable (cable #2) in my office to a distribution box from which wires run via a drilled hole in a window frame to a DHT11 pod mounted outside. This pod (fIgure 1) holds a pair of DHT 11s and it is mounted in a weather-shielded, shady spot. Immediately next to this ‘outside’ pod I installed one DS18B20 temperature sensor to measure the temperature outside the home. Of the eight available wires in the connecting cable I used five: orange (5V), blue (GND), white-brown striped (DHT11-1-DATA), white-orange striped (DHT11-2-DATA), and white-blue striped (DS18B20 data).

Both cables were connected to a junction box on the wall in my office and from here a common final cable (#3) runs to the Arduino Nano. Because I wanted to measure the relative humidity and air temperature in my office, the junction box was decorated with an add ional DHT11 ‘pod’ and apart from that with a DS18B20 probe (probe 07). The data pin of probe 07 was connected to the white-blue-striped wires whilst the two DATA wires from the pair of DHT11’s inside the pod were connected to the wires green and the white-green-striped wires of cable #3. In summary the color codes wires in the common final cable #3 that leads to the Nano correspond with the following sensors:

  • orange                                   5V “power supply bus”

  • white-orange-striped —-  DHT11-1-DATA (#1 – pair measuring external humidity)
  • blue ————————   GND
  • white-blue-striped ——-   all Dallas DS18B20 temperature sensors (one wire)
  • brown ———————    not used
  • white brown striped  —-   DHT11-2-DATA (#2 -pair measuring external humidity)
  • green  ———————   DHT11-3-DATA (#1 – pair measuring internal humidity)
  • white-green-striped —–   DHT11-4-DATA (#2 – pair measuring internal humidity

Pins on the Nano

Pin connectivity between the Arduino Nano and the sensors and display are illustrated in figure 5A. The pin layout is mostly standard TFT shield connectivity (i.e., as if placed on an Arduino UNO). The only difference here is that the wires belonging to the SD part of the shield are not connected since I needed five pins to connect sensors to. The tradeoff of assigning these pins to the humidity and temperature sensors is that the SD functionality of the TFT shield is not available.

 figure 4. Cable connectivity from the attic and outside via a ‘decorated’ junction box to the Arduino Nano.

The DHT11 DATA wires were connected to Nano pins D10, D11, D12 and A5 (which can be programmed to function as pin D19, see sketch). Intuitively one would connect the four DHT11s with pins D10 through D13, but using the D13 pin caused errors in the sensor reading (“nan”). Reading DS18B20’s via Nano pin D13 was without problems  if a pull up resistance of 2kΩ-3kΩ was placed between 5V and pin 13. Usually a DS18B20 requires a 4.7 kΩ pull up resistor, but pin 13 has a built-in 1,000 Ω resistance to accomodate led-blinking. If necessary a 10K pot meter may be used here.

figure 5. A: connectivity of the Arduino Nano, B: Results of the data acquisition on the TFT display.

 Results

The result of the entire project is shown in figure 5B. The seven temperature sensors and four humidity sensors provide a clean and continuous data stream concerning temperatures and relative humidities on various spots inside and outside the home. The 3.5 inch TFT display has even space to accommodate more readings. It is tempting to add more DS18B20 sensors to the one-wire bus to measure temperatures of more solar inverters. keeping an eye on casing temperatures of solar tie grid inverters is very convenient because an inverter produces heat and, conversely, if an inverter malfunctions its temperature goes down to the ambient temperature. The sensor can be considered a good ‘health’ indicator for solar inverters!

What next?

The next challenge is to log the acquired data. One way to do so could be via data transfer to another Arduino equipped with a logging shield. Another option is to send data via the home computer network to a network storage unit for later analysis. However, the sketch controlling the TFT display and the data acquisition contains code that draws heavily on the Nano’s ATmega328 storage space and the available dynamic memory. The sketch consumes 74% of available program storage space (23k out of 30k) while global variables take 1,364 bytes of 2,048 available bytes of dynamic memory. The most urgent action for the moment may be compression of the sketch to reduce the use of memory storage in the Nano as much as possible.

Where to get the sketch?

Here: The name is attic_graphic_v_01.zip (zipped file)