Reading DHT22 temperature sensor

In this article we’ll be showing how to implement a small QML based application which utilizes C++ class for high-speed GPIO polling to handle DHT22 sensor output.
It has been tested on the Raspberry Pi 3 running Boot2Qt image version 5.12.3 and I have used Ubuntu 18.04 as a development machine with installed Raspberry Pi SDK.
More details about how to build Raspberry Pi image and install SDK you can find by the next links:

1. Creating Raspberry Pi 3 image using Boot2Qt project
2. How to Set Up a Cross-Compilation Development Environment on Ubuntu 18.04 for Raspberry Pi 2/3

Wiring up DHT22 temperature/humidity sensor

This diagram should help you work out where each pin needs to go on the Raspberry Pi.

  • • Pin 1 is VCC (Power Supply 3.3 – 5V)
  • • Pin 2 is DATA (The data signal)
  • • Pin 3 is NULL (Do not connect)
  • • Pin 4 is GND (Ground)

She has always been a good wife and the price cialis I understood her urges. The herbal drugs are free viagra without prescription manufactured using the stems, leaves & roots of rare species of plants. The continue reading here now wholesale viagra from canada is Tadalafil. cialis is an excellent product for the problem of erectile dysfunction. The drug needs to viagra shops be consumed only once every day.
Simply ignore pin 3, its not used. You will want to place a 10 KOhm resistor between VCC and the data pin, to act as a medium-strength pull up on the data line.
This diagram shows how we will connect for the testing sketch. Connect data to GPIO pin 26, you can change it later to any pin.

dht22_connections

 

Implementing QML-based application

A small QML based application utilizes C++ class for high-speed GPIO polling to handle DHT22 sensor output.
A project consist of two parts: QML code and C++ stuff which is represented by three classes.
The QML stuff is responsible for setting up the GPIO pin number for polling:

dht22_1

and displaying the current temperature and humidity:

dht22_2

The first C++ class “DhtManager” is exposing the data to QML code and connecting
QML code with C++ class methods. A “DhtWorker” class provides reading Dht sensor
in the separated thread. And the last class is “RpiGpioBasic” which controls
the directions and states of GPIO pins using a registry access (mmaping into /dev/mem).

It has been tested on the Raspberry Pi 3 running Boot2Qt image version 5.12.3.

RPI3_Termometer

The source code could be found at the git repository here…