This repository is aimed at developing a functional DIY Air Quality sensor based on AirGradient: https://www.airgradient.com/open-airgradient/instructions/diy/ except using a Raspberry Pi Zero with python instead of a D1 Mini Pro with Arduino/C++
Also containerized with docker for easy replication
- Raspberry Pi Zero - Microprocessor
- SCD30 - Measures Temperature, Humidity, and CO2
- OLED Display - Displays Values
- PMS5003 - Measures Particulate Matter Concentrations
![Screen Shot 2023-08-22 at 4 41 33 PM](https://private-user-images.githubusercontent.com/72172361/262506786-709a9a90-fb5a-48a6-914a-ca861066eecc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzIxMzMsIm5iZiI6MTczOTA3MTgzMywicGF0aCI6Ii83MjE3MjM2MS8yNjI1MDY3ODYtNzA5YTlhOTAtZmI1YS00OGE2LTkxNGEtY2E4NjEwNjZlZWNjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAzMzAzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkyMTFiN2JiOWIzYjVkNDExMjU4NzQ3YzhmMzAyOWIwNGNjM2FiZDVlNGNlMDYyMTZkODFjMzc3MjU4MDgyNGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Ep0jvOlP6AKVB-bP1koVNcfRAhJMs_WhA9cK-7H91n8)
-
I2C and UART must be enabled to work correctly:
sudo raspi-config
Enabling I2C:
Navigate To Interface Options:
Enter I2C Options:
Select Yes:
Enabling UART:
Enter Serial Port Options Within Interface Option Menu:
Select No:
Select Yes:
Select Finish:
- Install docker:
sudo apt install docker.io
- Check if docker is functioning:
sudo docker run hello-world
- Clone repository to get Dockerfile and configuration files:
git clone https://github.com/NAU-IoT/AirGradientOnPi.git
- Change into directory:
cd AirGradientOnPi
- OPTIONAL: To change the docker containers time zone, edit line 15 in the Dockerfile. A list of acceptable time zones can be found at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- Build docker image in AirGradientOnPi directory, this will take a while:
docker build -t airquality .
- Create a directory in a convenient location to store the docker volume. For example:
mkdir -p Data/AirQuality
- Create a volume to store data inside the directory created in the previous step:
docker volume create --driver local \
--opt type=none \
--opt device=/SOME/LOCAL/DIRECTORY \
--opt o=bind \
YOUR_VOLUME_NAME
- Execute docker container in AirGradientOnPi directory:
docker run --privileged -v YOUR_VOLUME_NAME:/Data -t -i -d --restart unless-stopped airquality
- Verify container is running:
docker ps
- Done!
- To enter the container:
- This can be done to check log files or modify the container without rebuilding/restarting
docker exec -it CONTAINER_ID /bin/bash
- If error:
Got permission denied while trying to connect to the Docker daemon socket at unix ... connect: permission denied
- Run command, then log out and ssh back into system:
sudo usermod -aG docker $USER
- Run command, then log out and ssh back into system:
-
Install Dependencies:
- Install OLED Library:
sudo pip install adafruit-circuitpython-ssd1306
- Install SCD30 library:
sudo pip install adafruit-circuitpython-scd30
- Install Python Imaging Library:
sudo pip install Pillow
- Install PM25 Library:
sudo pip install adafruit-circuitpython-pm25
- Install OLED Library:
-
Clone This Repository:
git clone https://github.com/NAU-IoT/AirGradientOnPi.git
-
Change into directory:
cd AirGradientOnPi
-
Execute script:
sudo python3 AirQuality.py
-
Done!