In this project was implemented a simple Temperature and Humidity station using Raspberry PI Zero 2W, an LCD and DHT11.
In order to run both in Linux system and Raspberry PI, it was created conditional compilation
explicit in Code Structure and implemented in PeripheralFactory
. So while using Linux
is used the ConsoleDisplay
implementation, and in RPI0 is used LCDDisplay
. Also, to have the Weather
data is implemented RandomWeatherGeneratorTask
and in RPI0 DHT11Sensor
.
The program uses mean 7%CPU in the RaspOS - Raspberry PI Zero 2W. Could use less if implemented time interruptions to some delays.
- pigpio (Usually comes pre-installed on pi boards)
- pthreads:
sudo apt-get install libpthread-stubs0-dev
- Make DHT11 Workers.
- spdlog:
pacman -S spdlog
or in apt based systemsudo apt install libspdlog-dev
- Simple and Fast Logging Library
There's an interface
that dictates the way all the data will be set on display: the TextBasedDisplay
There's an interface
that dictates the way the weather is acquired. The data will be scoped in a single
struct named WeatherInfo
. The WeatherTask
will be running in its own thread, acquiring the data and writing it to
the WeatherInfo
struct. Race conditions are not treated since the program will be running in a controlled system.