(8) Nano Weather station
An Arduino Nano weather station: air pressure, ambient temperature and relative humidity
by Floris Wouterlood – Leiden, The Netherlands – February 2, 2017
Summary – Numerous electronic sensors are available on the market that can be combined with an Arduino microcontroller board to measure environmental parameters of importance. Here we discuss a weather station that displays three prominent environmental parameters: air pressure, air temperature and relative humidity. The station is equipped with a DHT11 sensor (humidity), a BMP280 sensor (barometric pressure and temperature) and an Arduino Nano for processing. Measuring data is one thing, displaying them is another. Two types of displays are described: a 1.8 inch TFT color display with a SPI interface and a 20×4 LCD display. Wiring diagrams and prototypes for both types of display are shown.
It is nice to be aware of the conditions of the environment inside and outside our home. We feel happy when the temperature and humidity are in the comfortable zone range. The barometric pressure has a more general meaning as its movement up and down is indicative for the weather outside and not so much for the condition inside the home. Nevertheless, ambient temperature, humidity and barometric pressure are the most popular environmental indicators. In the good old days these parameters were measured with separate analogous instruments: thermometer, hygrometer and barometer. In the local science museum one may encounter a classical barometer consisting of an inverted glass tube filled with mercury. Mercury thermometers and barometers are pretty accurate while, by contrast, the cheap hair hygrometer of old was notoriously inaccurate.
Figure 1. Concept and components of my Arduino weather station project: sensors, microcontroller, display.
In the electronic age of today the market is flooded with cheap, efficient sensors that can be used to measure a plethora of environmental parameters. Instead of experimenting with one sensor at a time I wanted for the purpose of constructing a weather station to apply combinations of several sensors. This can be challenging given the abundance of communication protocols through which sensors communicate with the measurement and display electronics. The final goal here was to construct a weather station based on a single Arduino platform that uses a modern air pressure sensor, a temperature sensor and a sensor that measures the relative humidity (fig.1).
Sensor for temperature and barometric pressure: the BMP280
A rather sophisticated sensor that very accurately measures air pressure and simultaneously determines air temperature with reasonable accuracy has been made available recently by Bosch: the BMP280. The advantage of this sensor is that it uses I2C and SPI serial communication protocols that are supported by the Arduino family of microcontroller boards. Air pressure measurement of the BMP280 is reportedly so good and fast (~1 hPa; sampling rate max 182 readings per second) that this sensor can be implemented in altimeters, e.g. in drones or robots. The accuracy of the temperature measurement in the BMP280 is in the order of magnitude of one degree Celsius. Because the BMP280 replaces the BMP180 with which I had good experiences, I considered it an attractive device to start experimenting with. The BMP280 is available as a breakout device for the Arduino platform and is being marketed by various companies.
Figure 2. Close-ups of the BMP breakout board and the DHT11 sensor, with pin assignment. The CSB (chip select) and SDO (serial data output) pins of the BMP 280 are necessary when SPI based communication is applied. Note that the BMP280 is a 3.3V device. The DHT11 is a 5V device; data is communicated via pin 2. Pin 3 is not connected. The DHT11 can be purchased from several companies as a 3-pin breakout device.
Sensor for relative humidity: the DHT11.
The DHT11 is a cheap digital humidity and temperature sensor that is on the market for quite some time. The small perforated casing houses a conductive humidity sensor that sniffs the moisture, and a thermistor that determines the temperature of the air flowing through the openings in the case. The sensor is slow and the accuracy of its measurements is rather low (temperature: two degrees Celsius; relative humidity 5% in 20-80% environments). As I consider an inaccuracy of 5% in relative humidity acceptable I implemented this device instead of its more accurate (and more expensive) family member DHT22. DHT11s can be purchased in bulk at very economical price. In other projects where I needed readings of the relative humidity I connected several DHT11’s to an Arduino and averaged the acquired temperature and humidity data. In the present design temperature measurement of the DHT11 is neglected because the BMP280 performs much better in this respect.
The question I asked myself was whether it is possible to read both sensors simultaneously with a single Arduino microcontroller and with one sketch: the BMP280 via I2C communication and the DHT11 via instructions associated with the DHTLib library. Then there is the question whether sufficient pins on the Arduino (and enough memory space) remain available to drive a TFT display with its complicated instruction set.
Parts used to build a prototype
1 x Arduino Nano
3 x breadboard
1 x 3.3V led (any color)
1 x 220 Ω resistor
1 x BMP280 pressure-temp sensor breakout
1 x DHT 11 humidity-temp sensor
1 x 10KΩ resistor
1 x 10 kΩ potentiometer
many jumper wires
TFT display weather station: 1.8′ color TFT display (SPI) (8-pin breakout)
LCD display weather station prototype: 20×4 LCD display (16-pin breakout)
Two prototypes of the weather station were planned: one with a 1.8′ color TFT screen (TFT prototype) and one with a LCD display (LCD-prototype).
The TFT display used here is a Adafruit ST7735 clone color TFT display. Like the original it is a breakout board with 8 pins that communicates via a SPI interface. Resolution is width120 pixels and height 160 pixels. The controller is compatible with the Adafruit ST7735 and it understands instructions supplied via the Adafruit_GFX and Adafruit ST7735 libraries. The difference is that the clone is a strictly 3.3V display while the Adafruit has a 3.3-5VC level shifter on board. The display needs five dedicated pins on the Arduino to properly function: pins D8, D9, D10, D11, D13. Furthermore it needs to be supplied with 3.3V for the electronics, while screen light intensity is adapted via changing voltage on pin LED on the TFT breakout board with a 10 kΩ potentiometer (GND, 5V; wiper connected with pin LED).
A wiring diagram for this prototype is shown in figure 3. Note that the wiring diagram contains an external led (LED; here: yellow; can be any available color). This is a control led whose pin is set HIGH for 500 msec in the sketch at the end of every loop cycle.
Figure 3. Wiring scheme of my Arduino weather station: sensors, microcontroller and display. This is the wiring for the TFT prototype: wiring includes that for the 1.8 inch color TFT display. . Notice cycle control led (marked LED).
The type of data displayed (three parameters) does not need much extra additional information except perhaps and introduction text. For this type of data display a 20×4 LCD may suffice.
Figure 4. Wiring scheme of my Arduino weather station: sensors, microcontroller and display. This is the wiring for the TFT prototype: wiring including the 20×4 LCD display breakout board. Notice cycle control led (marked LED).
I therefore built with existing stock (a standard 16-pin 20×4 white characters on a blue background LCD breakout board) a LCD prototype. A classical LCD breakout consumes an extra pin on the Arduino compared with the SPI-TFT breakout: pins D2, D3, D4, D5, D11 and D12. The LCD needs 3.3V on pin ‘A’ (15th pin on the breakout) and a variable voltage via the wiper of a 10 kΩ potentiometer to adjust the contrast between characters and background. The wiring of the LCD prototype weather station is shown in figure 4.
Both prototypes were constructed using the listed parts. I favor building prototypes in blocks to keep control of the project. Building block by block makes testing easier as well. For instance I made an external 10 kΩ potentiometer with the aid of a leftover tape cassette case (fig. 5). Also the stand on which the breadboard with the Arduino Nano and the TFT display are positioned consists of a recycled cassette tape case, the lid of which supports the breadboard. The sensors were placed on a separate breadboard, also for the sake of working area tidiness.
Arduino pin consideration
Because the TFT breakout occupies pins D8, D9, D10 and D11, and the LCD uses pins D2, D3, D4, D5, D11 and D12 while the BMP280 needs pins A4 and A4, the pins of the Arduino considered to be ‘free’ was restricted to pins D6, D7, D13 and several analogous pins. Pin 13 has an internal pull-up and gave problems in implementation in sketches. This resulted in the selection of pins D6 and D7 for connection with, respectively, the cycle indicating led and the data pin of the DHT11 sensor. In the current wiring the led is connected to the Arduino’s pin 6 and the DHT11 sensor data pin to Arduino pin 7, but this selection is interchangeable.
Figure 5. The actual prototype of the TFT weather station: data display on the 1.8 inch SPI color TFT screen.
Figure 6. Zooming in on the 1.8 TFT weather station: sensor, microcontroller and display. With a color TFT data can be presented more attractively than with a cool LCD display.
Figure 7. Prototype of a weather station with data display a 20×4 LCD screen. The inset shows the data on the LCD display at higher magnification and without light reflected by the LCD’s transparent protective cover.
These are the two sketches:
• one sketch for the TFT version of the weather station
• one sketch for the LCD version
Name of the (zipped) file: arduino_weather_station_project_ino_s.zip
These sketches also provide Serial Monitor output of barometric pressure, temperature and relative humidity.
Testing and use
After building and testing the weather station prototypes, a process that progressed hand in hand with writing and testing the Arduino sketches, I now have two stable prototypes working: a TFT and a LCD version. It is now possible to consider manufacturing a definitive, ‘production’ Arduino weather station. Because with some effort all components can be placed on one breadboard a small form factor can be achieved. The final challenge in this project is to find a suitable, elegant casing for the electronics and the display. As data can be much more attractively displayed on TFT screens compared with the cool, no-nonsense LCD screens the next step in my ‘Arduino Weather Station research’ is to investigate whether and how bigger TFT screens can be implemented, for instance 3.5 inch diameter 320×480 color TFT screens.
Sources of information