Introduction: PyonAir - an Open Source Air Pollution Monitor

About: Engineering PhD Student

The PyonAir is a low-cost system for monitoring local air pollution levels - specifically, particulate matter. Based around the Pycom LoPy4 board and Grove-compatible hardware, the system can transmit data over both LoRa and WiFi.

I undertook this project at the University of Southampton, working in a team of researchers. My primary responsibility was the design and development of the PCB. This was my first time using Eagle so it was definitely a learning experience!

The aim of the PyonAir project is to deploy a network of low-cost, IoT pollution monitors that will allow us to gather crucial information about the distribution and causes of air pollution. Whilst there are many pollution monitors on the market, most only offer "Air Quality Index", rather than raw PM data - especially at affordable prices. By making the project open-source, with easy setup instructions, we hope to make the PyonAir device accessible to anyone who is interested in air quality, either personally or professionally. For example, this device can be used to collect data for student projects, PhDs and independent parties, making vital research that has a reputation for soaring costs much more attainable. The project may also be used for outreach purposes, communicating with members of the public about their local air quality and the steps that can be taken to improve it.

Our goals of simplicity and ease of use inspired our decision to use the Grove system as the backbone of our design. The wide range of compatible modules will allow users of the system to customise the PyonAir device to their needs, without being forced to redesign the fundamental hardware. Meanwhile, Pycom's LoPy4 offers multiple options for wireless communication in a single, neat package.

In this instructable, I will be describing the design journey and steps to manufacture the PCB, followed by instructions on how to assemble the full PyonAir unit.

Supplies

Components:

  • LoPy4: Main board (https://pycom.io/product/lopy4/)
  • PyonAirPCB: Easy connection to Grove sensors
  • Plantower PMS5003: Air pollution sensor (https://shop.pimoroni.com/products/pms5003-particu...
  • Sensirion SPS30: Air pollution sensor (https://www.mouser.co.uk/ProductDetail/Sensirion/SPS30?qs=lc2O%252bfHJPVbEPY0RBeZmPA==)
  • SHT35 sensor: Temperature & humidity sensor (https://www.seeedstudio.com/Grove-I2C-High-Accurac...
  • Real Time Clock: Backup clock unit (https://s-u-pm-sensor.gitbook.io/pyonair/hardware/...
  • GPS module: GPS receiver for time & location (https://www.seeedstudio.com/Grove-GPS-Module.html)
  • Grove cables: https://www.seeedstudio.com/Grove-Universal-4-Pin...
  • Pycom antenna: LoRa capability (https://pycom.io/product/lora-868mhz-915mhz-sigfox...
  • MicroSD card
  • Power supply: Primary power supply (Recommended: https://cpc.farnell.com/pro-elec/pel00398/ac-dc-po...
  • Case: IP66 115x90x65 mm weatherproof ABS box (https://www.ebay.co.uk/itm/173630987055?ul_noapp=t...

Tools:

Step 1: About the PCB

Grove connectors are an increasingly popular standard in the hobbyist electronics ecosystem. The plug-and-play connectors make attaching and swapping a wide range of modules easy and fast, with no need to resolder joints.

Meanwhile, Pycom's LoPy4 board was selected as the main microcontroller for the PyonAir as it offers 4 wireless communication modes: LoRa, Sigfox, WiFi & Bluetooth and is programmed using MicroPython.

Arduino and Raspberry Pi already support Grove connector shields but none had yet been released for the Pycom system. Therefore, we designed our own expansion board PCB, which fits onto the LoPy4 board. The PCB contains:

  • 2 I2C sockets (Temperature sensor & RTC)
  • 3 UART sockets (2x PM sensor & GPS)
  • Pins for USB data
  • A transistor circuits for controlling power to the PM sensors
  • A transistor circuit for controlling power to the GPS receiver
  • Micro SD slot
  • User button
  • Power input connectors (Barrel, JST or screw terminal)
  • Voltage regulator

Step 2: PCB V1-V3

PCB V1

My first attempt at the PCB was based on a "shim" concept, where a thin PCB would fit between the LoPy board and a Pycom expansion board, such as the Pytrack (see CAD drawing). As such, there were no mounting holes and the board was very basic, featuring only connectors and a pair of transistors for turning the PM sensors on or off.

To be honest, there was a lot wrong with this board:

  • The tracks were way too thin
  • No ground plane
  • Weird transistor orientations
  • Unused space
  • The version label was written in a track layer, not silkscreen

PCB V2

By V2, it had become apparent that we needed the PyonAir to operate without an expansion board, so power inputs, a UART terminal and an SD slot were added to the design.

Issues:

  • Tracks crossed mounting hole zones
  • No LoPy orientation guide
  • Incorrect DC barrel jack orientation

PCB V3

Relatively minor alterations were made between V2 & V3 - mostly corrections to the issues above.

Step 3: PCB V4

V4 featured a complete redesign of the entire PCB, in which the following changes were made:

  • Almost every component can be soldered by hand or pre-assembled using PCBA
  • Mounting holes at corners
  • Components grouped into "Permanent", "Power" and "User" zones
  • Labels for:
    • Input voltage range
    • Documentation link
    • LoPy LED location
  • 2 SD holder options
  • Test pads
  • DC barrel jack can be mounted on top or underneath the board
  • Better routing
  • More efficiently packed components
  • Longer female header rows were added, so a user would be able to use 4x 8-pin headers, instead of 2 pairs of 8-pin and 6-pin headers, making it slightly cheaper.

Step 4: PCB V5

The final version!

These last few adjustments were made to V5 before it was submitted for PCBA manufacture by Seeed Studio:

  • Even tidier routing
  • Improved label positioning
  • Updated website link
  • Silkscreen pads for labelling PCBs during testing
  • More rounded corners (to better fit in the selected enclosure)
  • Adjusted length of PCB to fit enclosure rails

Step 5: How to Make Your Own: PCBA

If you're planning to manufacture less than 5 PCBs, see "How to make your own: Hand Soldering" (next step) instead.

PCBA Ordering from Seeed Studio

  1. Log in or create an account at https://www.seeedstudio.com/fusion.html
  2. Click on 'Order Now'.
  3. Upload Gerber files.
  4. Adjust settings (PCB quantity & surface finish: HASL Lead-Free).
  5. Add assembly drawing & pick and place file.
  6. Select PCBA quantity.
  7. Add BOM. (N.B.: If you want to avoid soldering it yourself and don't mind the longer wait, you can add the TSRN 1-2450 voltage regulator to the BOM.
  8. Add to cart & order!

Please visit: https://s-u-pm-sensor.gitbook.io/pyonair/extra-inf... for the required files.


Soldering the voltage regulator

The only part that requires soldering when using Seeed's PCBA service is the TSRN 1-2450 voltage regulator. As mentioned above, you can include this in the assembly BOM but it may add a lot more time to the order.

If you're happy to solder it by hand, simply add the regulator to the place indicated by the silkscreen, making sure the orientation is correct. The white dot on the silkscreen should line up with the white dot on the regulator (see pic).

Step 6: How to Make Your Own: Hand Soldering

If you're planning to manufacture a large number of PCBs, see "How to make your own: PCBA" (previous step) instead.

Ordering PCBs

You can purchase PCBs from many websites, including Seeed Studio, with some able to deliver in under a week. We used Seeed Fusion, but these steps should be very similar to other sites.

  1. Log in or create an account at https://www.seeedstudio.com/fusion.html
  2. Click on 'Order Now'.
  3. Upload Gerber Files.
  4. Adjust settings (PCB quantity & Surface finish: HASL Lead-Free)
  5. Add to cart and order!

Please visit: https://s-u-pm-sensor.gitbook.io/pyonair/extra-inf... for the required files.

Ordering parts

As the board has additional pads for SMD/through-hole mounting options, you don't need to populate every part. If you're soldering by hand, it's easiest to avoid all SMDs by populating the board according to the table shown in the pictures.

N.B. If you're confident with a soldering iron, it's more space-efficient and cheaper to use a surface mount Micro SD slot instead of the 8-pin header + breakout board.

Step 7: How to Make Your Own: Assembly

Grove cable modifications

In order to connect your PM sensors to the grove connectors, you'll need to splice the sensor cables onto the grove cables, as shown in the picture above. You can do this using either crimps or solder and heat-shrink. Depending on the sensor you use, you'll need to make sure the pinout matches the inputs to the PCB.


Assembly steps

  1. Choose which one of the power inputs you wish to use (barrel jack / JST / screw terminal) and connect the appropriate supply.
  2. Use a multimeter to check the V_IN and 5V test pads on the back of the PCB.
  3. When you're happy that the board is correctly powered, remove the power supply. (If not try alternative power supply)
  4. Plug the LoPy4 into the 16-pin headers, ensuring the LED is at the top (as shown on the silkscreen). The bottom 4 holes in the headers are unused.
  5. Connect each of the Grove devices into the matching sockets on the PCB.
  6. Plug in the micro SD card.
  7. Reconnect the power supply. The LEDs on the LoPy4 and GPS should both turn on.
  8. Use a multimeter to check the remaining test pads on the back of the PCB.
  9. Your PyonAir should now be ready to program!

N.B. Make sure you empty the SD card and format it as FAT32 before plugging it into the board.

WARNING: Only ever connect one power source at a time. Connecting multiple supplies at the same time could short out a battery or mains power!

Step 8: How to Make Your Own: Software

For our software development, we used Atom and pymakr. Both of these are open-source and should work on most computers. We recommend installing these before downloading the code for the LoPy4 board.

Pycom recommends updating the firmware of their devices before attempting to use them. Full instructions on how to do so can be found here: https://docs.pycom.io/pytrackpysense/installation...

Installation

  1. To get your PM sensor device up and running, download the latest version of our code from GitHub: https://github.com/pyonair/PyonAir-pycom Make sure you extract all of the files to a convenient location on your PC or laptop and avoid renaming any of the files.
  2. Open Atom and close any current files by right-clicking the top level folder and clicking "Remove Project Folder" in the menu that appears.
  3. Go to File > Open Folder and select the "lopy" folder. All of the contained files and folders should appear in the "Project" pane on the left in Atom.
  4. Plug the PyonAir PCB into your PC or laptop using an FTDI-USB cable and the RX, TX and GND pins on the header to the right of the board.
  5. The board should show up in Atom and connect automatically.
  6. To upload the code, simply click the "Upload" button in the bottom pane. The process may take a few minutes, depending on how many files need to be removed and installed. Once the upload has succeeded, press Ctrl + c on your keyboard to stop the code, then unplug the FTDI-USB cable.

Configuration

When you set up a new device for the first time or if you want to change any settings, you will need to configure it over WiFi.

  1. Remove your air pollution monitor from any cases such that you can access the user button.
  2. Prepare a phone or computer that is able to connect to local WiFi networks.
  3. Power the PyonAir device.
  4. When setting up the device for the first time, it should automatically switch itself into configuration mode, indicated by blue LED flashing. Otherwise, press and hold the user button on the Grove socket PCB (labelled CONFIG) for 3 seconds. The RGB LED should turn solid blue.
  5. Connect to the PyonAir device's WiFi. (This will be named 'NewPyonAir' or whatever you previously named the device.) The password is 'newpyonair'.
  6. Enter http://192.168.4.10/ into your web browser. The configuration page should appear.
  7. Fill all required fields on the page and click 'Save' when finished. (You will need to provide connection details to LoRa and WiFi, assign a unique ID to each sensor, and specify your preferences regarding data acquisition.)
  8. The PyonAir device should now reboot and will use the settings you provided.

To connect your device to LoRa, register it via The Things Network. Create a new device with the Device EUI shown in the configuration page, and copy the Application EUI and App Key from TTN to the configurations.

Pybytes is Pycom's online IoT hub, through which you can update firmware, perform OTA updates and visualise data from connected devices. First, you'll need to log in or create an account here: https://pyauth.pybytes.pycom.io/login then follow the steps to register a new device.

Testing

The easiest way to test that your air pollution monitor is working correctly is using an FTDI-USB cable and the RX, TX & GND pin headers on the Grove Socket PCB. Connecting the device in this way allows you to view all of the messages and readings in Atom.

The RGB LED on the LoPy board shows the status of the board:

  • Initialising = Amber
  • Initialisation succeeded = Green light blinks twice
  • Cannot access SD card = Red light blinking immediately after boot
  • Other issue = Red light flashing during initialisation
  • Runtime errors = Red blinking

By default, data from the PyonAir will be sent to the University of Southampton's server. You can edit the code before deploying the device to redirect it to a location of your choice.

Step 9: How to Make Your Own: Deployment

Now that your air pollution monitor is fully configured, you should be ready to deploy the device!


Case advice

The case we selected for our devices was: https://www.ebay.co.uk/itm/173630987055?ul_noapp=t... However, feel free to purchase a different case or design your own. SolidWorks files for most of the hardware we used are provided in the Extra Info section, to help with designing custom cases. One proposed method of arranging the sensors and cutting holes in the case is also shown in the picture above.

Just remember that your case should:

  • Protect the electronics from water and dust
  • Allow mounting of the device on-site
  • Allow air to reach the PM sensor(s)
  • Prevent the electronics from overheating
  • Hold the electronics securely inside the case


Locationadvice

An ideal deployment location will fulfil the following criteria:

  • In a region of interest for air pollution
  • Out of direct sunlight
  • Within range of a LoRa gateway
  • Within range of WiFi
  • Close to a power source
  • Secure mounting points
  • Able to receive GPS signals

Step 10: Files & Credits

All the files you should need to make your own full PyonAir can be found at: https://s-u-pm-sensor.gitbook.io/pyonair/extra-inf... (Zip files can't be uploaded to Instructables, sorry!) The Gitbook also includes additional information about the hardware and software.


Credits

Project supervised by Dr Steven J Ossont, Dr Phil Basford & Florentin Bulot

Code by Daneil Hausner & Peter Varga

Circuit design & instructions by Hazel Mitchell

PCB Design Challenge

Participated in the
PCB Design Challenge