K110 mini weather station

In this project, we are building a board for measuring the temperature, the humidity and the atmospheric pressure with the help of the Arduino nano platform. We measure temperature and atmospheric pressure with the BMP280 sensor, and humidity with the DHT22 sensor. The indications are displaying at nine 7-segments digits.

Project description

The DHT22 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and spits out a digital signal on the data pin (no analogue input pins needed). It’s simple to use but requires careful timing to grab data. It uses its own serial protocol. You can only get new data from it once every 2 seconds. The DHT22 has four pins. The first pin on the left is connected to 3-5V power, the second pin to your data input pin and the rightmost pin to the ground.

Bosch has stepped up their game with their new BMP280 sensor, an environmental sensor with temperature and barometric pressure. This sensor is great for all sorts of weather sensing and can even be used in both I2C and SPI. For simple, easy wiring, go with I2C. If you want to connect a bunch of sensors without worrying about I2C address collisions, go with SPI. This precision sensor is the best low-cost, precision sensing solution for measuring barometric pressure with ±1 hPa absolute accuracy, and temperature with ±1.0°C accuracy.

The display is driven by the MAX7221 integrated circuit which communicates with the Arduino Nano via SPI protocol. The MAX7221 serial data at DIN sent in 16-bit packets, and is shifted into the internal 16-bit shift register with each rising edge of CLK. The MAX7221 CS must be low to clock data in or out. The data is then latched into either the digit or control registers on the rising edge of CS.

The microcontroller sends the 16-bit packet serially to the MAX7221 driver. Data bits are labelled D0-D15 (see Table 1), D8-D11 contain the register’s address, D0-D7 contain the data and D12-D15 are “don’t care” bits. The first received is D15, the most significant bit. The MAX7221 has fourteen digit and control registers. Each register contains 8-bit data and has its own address. Digit registers are addressed directly so that individual digits can be updated. The control registers consist of decode mode, display intensity, scan limit (number of scanned digits), shutdown and display test (all LED’s on).

At the MAX7221, the decode-mode register sets BCD code B or no-decode operation for each digit. Its address is 0x09. Each bit in the register’s data corresponds to one digit. A logic high selects code B decoding, while a logic low bypasses the decoder for this digit. (see the datasheet for more details). The MAX7221 allows display brightness to be controlled with an external resistor RSET connected between V+ and ISET (see the datasheet for more details).

Circuit description

The schematics are easy to understand and are shown below. It consists of five parts. The power supply, the Arduino Nano board, the sensors, the display driver and the led display. The power supply is a switching type for the 5V output and simple regulator for 9V output. The display is powered with 5V and the Arduino board with 9V. For measuring the humidity it uses the DHT22 sensor, and for measuring the temperature and the atmospheric pressure, it uses the BMP280 sensor. Both the sensors are powered by 3.3 Volts. The display consists of nine seven-segment red digits which is driven by the MAX7221 IC. The Arduino Nano communicates with MAX7221 via SPI protocol.


This project is based on 10 x14.5 cm double side PCB board. We place on it all the components, the seven segment red digits, the regulators 7809 and LT1076-5, the DHT22 and BMP280 sensors, the 100uH inductor, the Schottky diode, the transistor, the resistors, capacitors and DC connector. It is recommended the Arduino Nano board and the IC MAX7221 they are placed on bases. The board is power supplied by 12–15V adapter.

After we have assembled the board we plug the 12V or 15V adapter. With a multimeter, we measure the voltage outputs from the board’s power supply. If this is okay we place the MAX7221 IC and the Arduino board. With the board plugged with a 12V or 15V adapter, we connect the Arduino board through a USB cable to our PC computer. From the Arduino IDE we select the right USB port and the right board and then we upload the following sketch (In the Arduino language the programs are called sketches). After we have uploaded the sketch, we disconnect the USB cable. The board, powered from the adapter, must display the temperature in degrees Celsius on the two upper left digits, the humidity on the upper two right digits and the atmospheric pressure in mbar or hPa  units on five lower digits.

Installing Libraries

Before uploading the code you need to install three libraries in your Arduino IDE. The DHT sensor library, Adafruit_Sensor and Adafruit_BMP280_Library. Follow the next steps to install those libraries

DHT library

1] Click here to download the DHT sensor library. You should have a .zip folder in your Downloads.
2] Unzip the .zip folder and you should get DHT-sensor-library-master folder
3] Rename your folder from DHT-sensor-library-master to DHT
4] Move the DHT library to your Arduino IDE installation libraries folder
5] Finally, re-open your Arduino IDE

Adafruit_Sensor library

1] Click here to download the Adafruit Sensor library. You should have a .zip folder in your Downloads.
2] Unzip the .zip folder and you should get Adafruit_Sensor-master folder
3] Rename your folder from Adafruit_Sensor-master to Adafruit_Sensor
4] Move the Adafruit_Sensor library to your Arduino IDE installation libraries folder
5] Finally, re-open your Arduino IDE


1] Click here to download the Adafruit_BMP280_Library. You should have a .zip folder in your Downloads.
2] Unzip the .zip folder and you should get Adafruit_BMP280_Library-1.0.2 folder
3] Rename your folder from Adafruit_BMP280_Library-1.0.2 to Adufruit_BMP280_Library
4] Move the Adafruit_BMP280_Library to your Arduino IDE installation libraries folder
5] Finally, re-open your Arduino IDE

Uploading the code

Copy the following code to your Arduino IDE to upload it to Arduino Nano

 #include <SPI.h>
 #include "DHT.h"
 #include  <Wire.h>
 #include  <Adafruit_Sensor>
 #include  <Adafruit_BMP280.h>
 #define CS_PIN_MAX7221 10
 #define DHTTYPE DHT22
 #define DHTPin 8
 #define LEFTdigit 7
 Adafruit_BMP280 bmp;
 char c=2;
 int i=0;
 void max7221Transfer(unsigned char address, unsigned char value){
     digitalWrite(CS_PIN_MAX7221, LOW);
     digitalWrite(CS_PIN_MAX7221, HIGH);
 void printTemperature(float temp){
     char t = (char)temp;
         max7221Transfer(0x07, t%10);
         max7221Transfer(0x08, t%10);
     }else if(t>-10 && t<0){
         max7221Transfer(0x07, (-t)%10);
         max7221Transfer(0x08, 0x0A);
         max7221Transfer(0x07, 0x0A);
         max7221Transfer(0x08, 0x0A);
 void printHumidity(float hum){
     unsigned char h = (unsigned char)hum;
     max7221Transfer(0x05, h%10);
     max7221Transfer(0x06, h%10);
 void printPressure(float pre){
     int p = (int)pre;
     max7221Transfer(0x01, p%10);
     max7221Transfer(0x02, (p%10)|0x80);
     max7221Transfer(0x03, p%10);
     max7221Transfer(0x04, p%10);
           digitalWrite(LEFTdigit, LOW);
           digitalWrite(LEFTdigit, HIGH);
 void setup() {
      pinMode(CS_PIN_MAX7221, OUTPUT);
      pinMode(LEFTdigit, OUTPUT);
      digitalWrite(LEFTdigit, LOW);
      digitalWrite(CS_PIN_MAX7221, HIGH);
      max7221Transfer(0x0C, 0x01); //Shutdown Register Format: Normal Operation
      max7221Transfer(0x0F, 0x01); //Display – Test Register Format: Display Test Mode
      max7221Transfer(0x0F, 0x00); //Display – Test Register Format: Normal Operation
      max7221Transfer(0x0B, 0x07); // Scan – Limit Register Format: Display digits 01234567
      max7221Transfer(0x09, 0xFF); //Decode – Mode Register Format: No decode for digits 7-0
      max7221Transfer(0x0A, 0x0F);
      for(byte n=0; n<10; n++){
          for(i=1; i<9; i++)
 void loop() {
     float hu = dht.readHumidity();
     float te = bmp.readTemperature();
     float pr = bmp.readPressure();

Plug the Arduino Nano to your computer while your board is powered up with a 12V or 15V adapter and follow these next instructions:

1] Select your board in Tools>Board menu (in our case it’s the Arduino Nano)
2] Select the right COM port
3] Press the Upload button in the Arduino IDE and wait a few seconds while the code compiles and uploads to your board.


Click here to download the Eagle pcb files
Click here to download the Arduino Nano sketch


R1…………….10K  1/4W
R2,R3……….330R  1/4W
R4,R5……….4.7K  1/4W
R6…………….1.5K 1/4W
S1………………BMP280 module (ebay)
J1……………….DC connector
DS0,..,DS8….red 7-segment digit, common cathode, 0.56 inch