Smart environmental monitoring system for buildings
SDG2 Innovative project 2020-2021
RoomPi is a smart environmental monitoring system for use inside buildings. It is developed ontop Raspberry Pi 2B hardware.
The system makes use of the following sensors and actuators, as well as other devices:
- Sensors
- DHT11 (temperature and humidity)
- BH1750 (luxmeter light intensity)
- CCS811 (equivalent CO2)
- Actuators
- HD44780 (2-line dot matrix character display)
- SN74HC595 (8 bit shift register for LED strip)
- Active buzzer
- Control
- 3 buttons
- Others
- LM117 voltage regulator
The project makes use of the following libraries:
- wiringPi
- pthread
- rt
- libcurl
When compiling you must specify the libraries used:
gcc src/*.c src/sensors/*.c src/actuators/*. src/libs/*.c src/controllers/*.c -lpthread -lrt -lwiringPi -lcurl -o "roompi-bin"
For cross compilation from Eclipse you will need to install the Raspbian armhf toolchain.
Web subsystem (Docker)
The web subsystem comprises the following elements:
- InfluxDB Database
- Grafana dashboard
- DB Manager Chronograf
- Configuration application written in Flask
These all run as containerized instances which are orchestrated by the Docker service.
To configure and launch the instances you must install Docker and docker-compose in the host machine and edit the .env
file where the desired username and password for Grafana and InfluxDB are specified.
Then you can bring up all instances by executing the following command from the root directory of the project
docker-compose up -d
You can stop all services by executing the next command (to remove the persistent volumes created in the process append -v
to the command)
docker-compose down -d
The containers are configured to restart automatically in case they fail as well as start up automatically when the OS boots.
If working directly on the project's source code, you must take into account the following dependencies and libraries:
The C compiler must compile for the arm32v7 architecture used by the BCM2836 IC. To accomplish this you need to install the following dependencies on Linux:
sudo apt-get install -y libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev build-essential bison flex libssl-dev gcc-arm-linux-gnueabihf
To make use of the mentioned libraries in the project you must compile and install them beforehand. To dowload the various libraries you need have git
installed.
- wiringPi
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
- libcurl
sudo apt-get install -y autotools-dev autoconf libtool
git clone https://github.com/curl/curl
cd curl/
autoreconf -fi
./configure --without-ssl
sudo make install
To work on the custom web app used to configure the system, you need to install the following dependencies
- Python 3.8
sudo apt-get install -y checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev build-essential
cd /opt
sudo wget https://python.org/ftp/python/3.8.7/Python-3.8.7.tgz
sudo tar xzf Python-3.8.7.tgz
cd Python-3.8.7
sudo ./configure --enable-optimizations
sudo make altinstall # para evitar reemplazar el binario Python del sistema
python3.8 -V
It is highly recommended that you use a Python virtual environment when developing the project. Python's package manager pip is installed automatically in the virtual environment. Navigate instide the flask-config-roompi
directory and run:
- venv
python3.8 -m venv venv
source venv/bin/activate
- Flask and other dependencies
pip install -r requirements.txt