Use The Particle Squared Sensor to Monitor Your Air Quality With Google Docs

Jared Wolff · 2019.4.8· 4 Minute Read · particle · air quality

Main image

Air quality.

You probably think about it more now that our clean air has turned into a permanent haze across the sky.


I’ve previously written about the subject. This post is a straight-to-the-point version which will get you up and running quick!

Gather the Goods

The Circuit Board and Components

Get everything together that you’ll need for this project.

This includes:

  • A Particle Mesh board (Argon, Boron, Xenon). You can get them almost anywhere. Buying direct always works too. Note: if you’re just starting out, the Argon is your best bet.
  • Particle^2 Air Quality Sensor.
  • Honeywell HPMA115S0 Particle Sensor.
  • Cable for HPMA115S0 Sensor. ( The last three you can get here. )

The Leg Bones Connect to The ..

Put everything together in the short few steps below:

  1. Attach the Particle to the Particle^2 board Attach the Particle to the Particle Squared

  2. Connect the HPM Particle sensor to the Particle^2 using the cable Connect the HPM Particle Sensor

  3. Plug in USB! Connect USB

Configure Google Docs Script

  1. Create a new Google Sheet
  2. Then click the Tools menu and click Script Editor Script editor
  3. Create a new script
  4. Insert the below code into the script:

    //this is a function that fires when the webapp receives a POST request
    function doPost(e) {
     //Return if null
     if( e == undefined ) {
       Logger.log(“no data”);
       return HtmlService.createHtmlOutput(“need data”);
     //Parse the JSON data
     var event = JSON.parse(e.postData.contents);
     var data = JSON.parse(;
     //Get the last row without data
     var sheet = SpreadsheetApp.getActiveSheet();
     var lastRow = Math.max(sheet.getLastRow(),1);
     //Get current timestamp
     var timestamp = new Date();
     //Insert the data into the sheet
     sheet.getRange(lastRow + 1, 1).setValue(event.published_at);
     sheet.getRange(lastRow + 1, 2).setValue(data.temperature);
     sheet.getRange(lastRow + 1, 3).setValue(data.humidity);
     sheet.getRange(lastRow + 1, 4).setValue(data.pm10);
     sheet.getRange(lastRow + 1, 5).setValue(data.pm25);
     sheet.getRange(lastRow + 1, 6).setValue(data.tvoc);
     sheet.getRange(lastRow + 1, 7).setValue(data.c02);
     return HtmlService.createHtmlOutput(“post request received”);

Configure Webhook

Google Docs Webhook

  1. Go to Publish and click Deploy as Web App
  2. Set Execute the app as yourself
  3. Then set Who has access to the app to Anyone, even anonymous. (Important: if you’re working with. mission critical data, you may want a more robust and custom solution. This allows anyone, if they have your web hook link to post data to that page!)
  4. Change the Project Version to new and deploy!
  5. Copy the Current App URL that the output provides.

Configure Particle Cloud

Configure Particle Cloud

  1. In the console, go to the Integrations section and Create a New Webhook
  2. Fill in the name of the event that get’s forwarded from the code (in this case it’s blob)
  3. Enter the Current App URL from the last step in the URL Box
  4. Set the request type to POST
  5. Set the request format to JSON
  6. Target the device you’ll be using (or leave it as is if you only have one device)
  7. Click save

Beam me up

Particle Visual Code

It’s time to program your board. Follow the steps below:

  1. Setup your Particle Account and Particle Mesh device. Use the Quickstart if you haven’t done this before.
  2. Download Particle Workbench and install if you haven’t already. Instructions here.
  3. Get the code here.
  4. Once the code is downloaded, open it with Visual Code (that you installed in Step 1)
  5. Login to Particle if you haven’t already (The fastest way is to hit Command + Shift + P to open the command window. Then start typing login)
  6. Publish to Particle Cloud - Again this uses the command window. Use the same Command + Shift + P as above and type Cloud Flash.
  7. Once you’ve found the Cloud Flash option, press enter.
  8. Your board should be programmed shortly. You can watch the LEDs for changes during this time. Once it’s glowing blue, you’re good to go!

Last Step (I promise)

  1. In the Google sheet you can create a header in the first row with all the labels. Google Sheets View
  2. You should notice by now that new data is showing up in the sheet (if you set everything up correctly). Go back to the previous steps if you don’t see it.
  3. You can graph the data by selecting a full column and creating a new chart from it. Graphs in Google Sheets
  4. You can graph everything in one or in separate like I’ve done above. Here’s an example from my setup.

If everything is working and you have some pretty graphs, congrats!! If you’re ready to move on to the next step using an IoT service like Adafruit’s check out my full guide here.

The Ultimate Guide to Particle Mesh Cover

Get Ready for the Ultimate Guide

Signup to get updates on The Ultimate Guide to Particle Mesh. Early subscribers get a discount when it becomes available!

Sign me up!

You may also like

Ultimate How-to: Bluetooth Swift With Hardware in 20 Minutes

In a previous tutorial, you learned how to add Bluetooth to a Particle Xenon application. That way you could control the onboard RGB LED from a test app like nRF Connect or Light…

How to Un-brick Particle Mesh Using J-link

If you anything like me, you break stuff. (Like.. all the time.) This quick tutorial is about how to un-brick a Particle Mesh board using J-Link. This method may seem scary. It…

2 Best Ways to Get Particle Mesh Working With Blynk

Writing an app takes time. It takes even more time to write one that works with hardware. Luckily there’s a solution to this problem. Enter Blynk. It’s an app that connects to your…