1 of 33

Air quality monitoring

WORKSHOP KIT

Start

Configure and automate a simple air quality monitor

2 of 33

Next

Meet the team:

Instructor 1 Instructor 2 Instructor 3

3 of 33

Building a useful robot doesn’t have to require complicated code or expensive equipment.

With a Raspberry Pi, some basic hardware, and Viam, you can monitor your indoor air quality from anywhere in the world!

4 of 33

What are the basic aspects of a robot?

Sensing: to gather data from the environment

​

Actuation: to take actions based on that data

​

Control: process the data, make decisions, and initiate commands

5 of 33

What is Viam?

An engineering platform for data, AI, and automation that makes it easy to work with any physical device

6 of 33

How does Viam simplify software?

Viam’s APIs let you work with type of hardware using consistent methods, simplifying development across models.

​

And program your robot in the language of your choice with Viam’s SDKs.

​

7 of 33

What You’ll Build

A robot consists of....

​

    • Sensor(s)

​

​

    • Actuator(s)

​

​

    • Control system

​

​

8 of 33

What You’ll Build

A robot consists of....

​

    • Sensor(s)
      • PMS7003 air quality sensor

​

    • Actuator(s)
      • Smart plug

​

    • Control system
      • Monitor air quality particulate to trigger a smart plug when values rise above a certain threshold

9 of 33

Why build this project with Viam?

You can....

​

    • Manage your device remotely from the cloud

​

    • Configure and test hardware easily in the Viam app

​

    • Write code tailored to your project needs
      • Particulate sensor levels
      • Smart plug (or other) actuation

​

10 of 33

Let’s confirm everyone completed the pre-work!

​

    • Laptop with IDE, Python3, Raspberry Pi imager
    • Sign up for a free Viam app account
    • Smartphone to download and use the Kasa mobile app

​

Next

Check in: Pre-work

11 of 33

    • microSD card 32 GB and reader
    • Raspberry Pi 5 and 5V power supply
    • PMS7003 air quality sensor with G7 transfer board
    • Kasa smart plug
    • 20” box fan
    • 20" x 20" x 1" MERV 13 electrostatic air filter
    • Jumper wires
    • Optional: 3D-printed clips (or duct tape) and Pi case

Next

Get out your materials!

12 of 33

Let's start building!

Follow along reference:

​

codelabs.viam.com/guide/workshop-air-monitoring/index.html

Step 4

13 of 33

Set up the Raspberry Pi

​

Install Raspberry Pi OS

​

​

​

​

Wire the moisture sensor to chip according to the diagram:

14 of 33

Set up the Raspberry Pi

​

Set hostname

​

Set username and password

​

Configure wireless LAN

​

Set locale settings

​

​

​

​

Wire the moisture sensor to chip according to the diagram:

15 of 33

Set up the Raspberry Pi

​

Enable SSH

​

Use password authentication

​

​

​

​

​

Wire the moisture sensor to chip according to the diagram:

16 of 33

Welcome to your board!

A board is the signal wire hub of a robot that provides access to general purpose input/output (GPIO) pins: a collection of pins that can receive electrical signals.

​

You can control the flow of electricity to these pins to change their state between “high” (active) and “low” (inactive), and wire them to send digital signals to and from other hardware.

17 of 33

18 of 33

preview!

19 of 33

Set up the air monitoring sensor

​

GPIO 4 (3V) to VCC (Power)

GPIO 6 (GND) to GND (Ground)

GPIO 8 (TX) to RX (receiver)

GPIO 10 (RX) to TX (transmitter)

​

​

​

Wire the moisture sensor to chip according to the diagram:

20 of 33

Set up the air filter

​

Make sure the airflow arrow points toward the fan

​

​

Wire the moisture sensor to chip according to the diagram:

21 of 33

Set up the smart plug

​

Identify the IP address using `python-kasa` from the command line

​

​

Wire the moisture sensor to chip according to the diagram:

22 of 33

Set up the Raspberry Pi

​

Install Raspberry Pi OS

​

Connect with SSH

​

Enable communication protocols

​

​

Wire the moisture sensor to chip according to the diagram:

23 of 33

Let's start configuring!

24 of 33

Configure the machine

​

Log in to app.viam.com

​

Add a machine

​

Install `viam-server` on the Raspberry Pi

​

​

Wire the moisture sensor to chip according to the diagram:

25 of 33

Add the Raspberry Pi

​

Add component > board > Pi5

​

​

Wire the moisture sensor to chip according to the diagram:

26 of 33

Add the air sensor

​

Add component > sensor > air:pms7003

​

​

Wire the moisture sensor to chip according to the diagram:

27 of 33

Add the smart plug

​

Add component > generic > kasa:switch

​

Configure the plug IP address

​

​

Wire the moisture sensor to chip according to the diagram:

28 of 33

Testing components:

CONTROL

Test your air sensor in the CONTROL tab by verifying the GetReadings function returns values

29 of 33

Testing components:

CONTROL

Test your smart plug in the CONTROL tab by sending a DoCommand()

30 of 33

Let's try some code!

31 of 33

Use a control logic module

​

Use `control-air-quality` module

​

Configure module

​

​

​

Wire the moisture sensor to chip according to the diagram:

32 of 33

Congrats on building your air quality monitor!

🗣️ Now what?

33 of 33

Additional Viam resources

​

  • Docs: https://docs.viam.com/

​

  • Community: http://discord.gg/viam

​

  • Hands-on: https://codelabs.viam.com/

​

​

What will you build next?