This repository is part of an academic project focused on monitoring occupancy levels in a library across different floors and zones using Raspberry Pi Pico W units with ultrasonic sensors and an Arduino board. The data collected by the Pico units is sent to a central Arduino, which then posts the information to a local web server. The server runs on Node.js and stores occupancy data in MongoDB.
This project is made for the course "Project with Embedded Systems 2DT304".
This Repository contains the source code for the webserver.
Project Demo Video
Seif-Alamir Yousef & Ludvig Svensson
This Academic Report contains detailed information about the project.
Inside the /pico_Micropython
directory, you will find three distinct files corresponding to the different zones in the library:
pico_one.py
: Code for the entrance zone.pico_two.py
: Code for the second and third floor zone.pico_three.py
: Code for the ground floor zone.
These scripts are written in MicroPython and are responsible for measuring entries and exits using ultrasonic sensors attached to each Raspberry Pi Pico as well as handling Bluetooth communication.
The directory also contains the following file
trying_threads.py
: This file contains our try to use multithreading which didn't work out as we hoped. More on this can be found in the report.
The /Arduino
directory contains two versions of the code for the Arduino UNO R4 Wifi:
-
ArduinoCode.ino
: This script does not utilize FreeRTOS. It's designed to collect data from the three Picos and communicate with a local server via POST requests, updating the occupancy status accordingly. -
ArduinoFreeRTOS.ino
: This version incorporates FreeRTOS to manage multitasking. However, due to the multitasking complexity, it is currently limited to connecting and collecting data from only two Picos.
Use only one of them on the Arduino
To deploy the code on your microcontrollers, follow these steps:
-
Raspberry Pi Pico:
- Ensure each Pico is running MicroPython. Instructions can be found on the official Raspberry Pi website.
- Upload the respective
.py
files to each Pico device using Thonny or any other preferred MicroPython IDE.
-
Arduino UNO Rev 4:
- Open the desired
.ino
file in the Arduino IDE. - Compile and upload the code to your Arduino UNO Rev 4.
- Open the desired
Ensure the Arduino is programmed with the IP address of the device running the web server and the matching API_KEY
for successful POST requests to the server. Also, make sure the Arduino and the server are on the same network.