Giter VIP home page Giter VIP logo

airq's Introduction

airq

Air Quality

The project aims at building an air quality measurement station. The steps are mostly based on the blog post, but shall be extended/modified in two respects:

  • Explain the initial setup of a headless raspian on a new Raspberry Pi Zero W
  • Store the information in Google Cloud

As a result a moderate technically interested person should be able to replicate the steps under supervision when having all hardware available.

Raspberry Pi Zero W - Headless Setup

For making fast progress we will avoid connecting the Rasperry Pi with a keyboard and a monitor, but instead use a headless setup (headless basically means without keyboard and monitor). This setup presents us with two challenges if we use a fresh raspbian image for the SD card:

  • The Wifi connection is not enabled: The Raspberry Pi don't know how to connect to your WiFi.
  • SSH is not enabled: We will use SSH to connect to the Raspberry Pi and continue the setup.

The next steps are based on vorillaz' blog post and the Raspberry Pi installation documentation:

Buster Wifi Bug on Raspberry Pi Zero W

Due to issue 3184 the wifi configuration doesn't work on the newest release for some configurations. wpasupplicant needs to be downgraded. For the built-in Wifi module a downgrade finally was not required, but adjusting the wpa_supplicant.conf file did the trick. Before the network declaration add the following 3 lines:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=PL

Install pip

Rasbpian Lite doesn't include the pacNot all Python packages are available in the Raspbian archives, and those that are can sometimes be out-of-date. If you can't find a suitable version in the Raspbian archives, you can install packages from the Python Package Index (PyPI). To do so, use the pip tool.

pip is installed by default in Raspbian Desktop images (but not Raspbian Lite). You can install it with apt:

sudo apt-get install python3-pip

Prepare for Cloud connection

git clone https://github.com/matzie5/airq
cd airq

Make sure the required core packages are all installed

chmod +x initialsoftware.sh
./initialsoftware.sh

Create a security certificate

In order to communicate with Google Cloud, a security certificate must be generated and then registered with IoT core.

chmod +x generate_keys.sh
./generate_keys.sh

After the certificate has been created you can copy it to your localhost into the current folder:

scp [email protected]:/home/pi/.ssh/ec_public.pem .

Run the program

If you aren't in the /home/pi/airq directory on the Raspberry Pi, move there first

cd /home/pi/airq

Start the heart rate script by changing the following to match your project, registry and device

python airquality.py --project_id=myproject --registry_id=myregistry --device_id=mydevice

e.g.

python airquality.py --project_id=iot-airquality --registry_id=airquality --device_id=zienerAirQ

You should see the terminal window echo the airquality about every 10 seconds. With data flowing, you can skip to the next section.

Modify the program

In the standard configuration we are using the USB port to control the device. We can take a shortcut here and connect the device directly to the serial port on the GPIO pins. For this step we need to enable UART on the raspberry pi:

sudo echo "enable_uart=1" >> /boot/config.txt

sudo nano /boot/cmdline.txt
# Remove `console=serial0,115200`

# Restart for changes to take effect
sudo shutdown -r now

airq's People

Contributors

matzie5 avatar

Watchers

 avatar

Forkers

gman1988

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.