An open API service indexing awesome lists of open source software.

https://github.com/petrcernyy/iot-sensors

IoT temperature and humidity monitoring system
https://github.com/petrcernyy/iot-sensors

esp32 mqtt nodejs qt6 raspberry yocto

Last synced: 2 months ago
JSON representation

IoT temperature and humidity monitoring system

Awesome Lists containing this project

README

          

# IoT Temperature and humidity Monitoring System

This project consists of an IoT system for monitoring temperature and humidity using ESP32 and Raspberry Pi. The project includes:

- **ESP32 Firmware**: A firmware to gather temperature and humidity data and send it via MQTT.
- **Node.js Web Application**: A backend and frontend web application to visualize data and control settings.
- **Yocto Layer**: Custom Yocto layer to compile a distribution for the Raspberry Pi.
- **Qt Application**: A graphical interface running on Raspberry Pi, providing real-time temperature and humidity display.

The ESP32 measures the temperature and humidity and communicates over MQTT with the Raspberry Pi, which acts as a server. The Raspberry Pi also hosts the Node.js web application and tunnels its localhost to allow remote access.

### Components

1. **ESP32 Firmware**
- Collects temperature data.
- Publishes data to the MQTT broker running on the Raspberry Pi.

2. **Node.js Web Application**
- Hosts a frontend to display temperature and humidity data and configure settings.
- Enables adding new sensor. When a sensor is first connected it will display a add button for creating a new room
- Displays graph of temperature and humidity
- Works also on phone
![Nodejs Web application](./images/nodejsweb.png)

3. **Yocto Layer**
- Builds a custom distribution for the Raspberry Pi.
- Installs necessary packages for MQTT, the Node.js web server, and the Qt application.

4. **Qt Application**
- Displays the temperature and humidity data in real time on the Raspberry Pi.
![Qt application](./images/qtapp.png)

## Setup Instructions

### Prerequisites

1. ESP32-s2 development board
2. SHT30 temperature and humidity sensor
3. Raspberry Pi with a display

### Step 1: Clone the repository

1. Clone the git repository

`https://github.com/petrcernyy/iot-sensors.git`

### Step 2: Setup ESP32 Firmware

1. Open the directory with firmware

`cd esp32_sensor_fw`

2. Change the SSID and PASSWORD for wifi connection. Also change the ip of your MQTT broker inside ./main/iot_sensor.c

```
#define EXAMPLE_ESP_WIFI_SSID "SSID"
#define EXAMPLE_ESP_WIFI_PASS "PASS"

#define MQTT_ADDRESS "mqtt://xxx.xxx.x.xx:xxxx"
```

3. Set target and build/flash

`idf.py set-target esp32-s2`\
`idf.py build`\
`idf.py flash`

### Step 3: Compile yocto distribution

1. Copy your files inside your yocto directory

2. Create a new build

`source poky/oe-init-build-env build-app`

3. Add layers

`bitbake-layers add-layer ../meta-openembedded/meta-oe`\
`bitbake-layers add-layer ../meta-openembedded/meta-python`\
`bitbake-layers add-layer ../meta-openembedded/meta-networking`\
`bitbake-layers add-layer ../meta-openembedded/meta-networking`\
`bitbake-layers add-layer ../meta-qt6`\
`bitbake-layers add-layer ../meta-raspberrypi`\
`bitbake-layers add-layer ../meta-qt6helloworld`

4. Enable building of recipes inside local.conf

`sudo vim conf/local.conf`

Locate line\
`MACHINE ??= "qemux86-64`

and change it to \
`MACHINE = "raspberrypi4-64"`

then add this line

`IMAGE_INSTALL_append += " qml qtsvg appuntitled mosquitto mosquitto-clients express socketio mqtt localtunnel"`

5. Build the distribution

`bitbake core-image-sato`

6. Flash the image to sdcard

Navigate to

`cd tmp/deploy/images/raspberrypi4-64`

Here locate file core-image-sato-raspberrypi4-64-xxxxxxxxxx-rootfs.wiz.bz2 and use program balenaEtcher for flashing

### Step 4: Raspberry

1. After booting open the terminal and connect to wifi using connman

2. Run the MQTT broker mosquitto

3. The copy the files for the nodejs web app to the raspberry

4. You can run the web app using node command

`node app.js`

4. Then in another terminal you can tunnel the localhost using localtunnel so it can be access remotely

5. Run the Qt app

`cd ./usr/bin/appuntitled`