Electronics Lab Component

In this section of the lab, students will assemble a basic circuit to connect a microcontroller to a PM2.5 air quality sensor and three feedback LEDs.

Learning Objectives:

  • Learn how a breadboard can be used to integrate electrical components for a prototype
  • Learn how to set up a LED feedback system using a simple circuit
  • Connect an external sensor to a microcontroller using a simple circuit
  • Connect the microcontroller to a laptop or PC through a serial terminal

The Breadboard

A breadboard is a set of electrically-connected rails laid out in horizontal and vertical grids. Breadboards are easy to interface with prototype electronics because they allow temporary connections to be made with standard electrical wires and components.

The Microcontroller

A microcontroller, as we will use the term in this lab, is an MCU (MicroController Unit) along with various other components, like ports, capacitors, resistors, voltage regulators, LEDs, etc. The actual “brain”; of a microcontroller is the MCU. The pins on the microcontroller allow the user to interface various controls, sensors, etc. to interact with the MCU.

Common microcontrollers used for prototyping include the Arduino and Sparkfun platforms. For this lab, we will be using an Adafruit ItsyBitsy M0 Express, whose MCU is an Atmel ATSAMD21. This is a fast, relatively new board, and supports firmware programmed using either C++ or Python.

The MCU’s behavior is determined by the “firmware”, code which is stored on the internal memory of the microcontroller. Generally speaking, this takes the form of a looping set of instructions that the microcontroller carries out when it is powered up. For this lab, the firmware has already been written, but students can examine the code at the Github repository here.

The firmware as waits until a successful serial connection has been made through the microUSB port, and then begins to stream data from the PM2.5 sensor. The number of seconds since the microcontroller was started up are included on each line, along with a raw PM2.5 concentration reading (in μg / m3).

Depending on what this raw reading is, the microcontroller will also turn ON or OFF digital pins to turn on feedback LEDs.

The Circuit

Students will be using jumper wires to interface the external sensor to the microcontroller. They will also create circuits between the microcontroller and three LEDs. The LEDs have their current limited by a single resistor to prevent them burning out. Note that LEDs must be plugged in in the proper direction: the flat side should be towards the GROUND side of the circuit, or they will not light up.

Using the information above about the Breadboard, it should be possible to build this circuit, connecting components either directly through the breadboard pins, or by connecting jumper wires. Follow the photos and the wiring diagram above to make sure everything has been connected properly.

Serial Connection

The microcontroller is programmed to stream data over the serial port – that is, the microUSB port – when it has been connected to a serial terminal program. There are many free serial terminal programs available, but we recommend using CoolTerm for this lab. You can download it here.

  1. Open CoolTerm. There is no need to install the program.

  1. Press “Options”, and press the dropdown “Port” button. Observe what ports are currently available on your computer.

  1. Now, connect the microcontroller to your laptop though a USB port.

Hint: The actual numbers of your ports may differ from the ones in this example. Choose whatever new port has appeared.

  1. Press “Re-Scan Serial Ports”; Observe what new port option appears.

Hint: To make the lab cooking exercise easier, it may be helpful to have the terminal program automatically add timestamps to the sensor readings. You can find a setting that will add timestamps under “Receive”; in the Settings menu.

  1. Change the Baudrate to 11520. Then, press OK.

6. You have now told the serial program what type of serial connection you need (11520 baude), and where the microcontroller is plugged in (in this case, COM10). But you need to connect the serial port to start getting data. So, press “Connect”; and wait for feedback from the sensor.

You should now see a new reading come in from the PM2.5 sensor each second. In clean air, this reading will be zero.

But when smoke or other particulate matter comes close to the sensor, the sensor value will change:

_ Important Note _: To write this data to a text file for later analysis, you must select “Connection > Capture to Text/Binary File”. This data will come through in a good format to paste into Microsoft Excel, or process with data analysis software like R or Python. Experiment with this before running your cooking experiment!

Bonus - Modify the code!

If you’re interested, here’s the code that’s running on the microcontroller, feel free to download, modify and test!

https://github.com/TaylorSharpeSS/MCGE_PM25

Design Lab Component

In this section of the lab, students will use CAD design software to design an enclosure for the PM2.5 sensor so that it can be used in a cooking experiment.

We will be using [Autodesk Fusion 360] (https://www.autodesk.com/products/fusion-360/students-teachers-educators), an integrated CAD (Computer Aided Design), CAM (Computer Aided Manufacturing), Render, Animation, and Simulation software for product designers. Student licenses are offered free to all students; if you do not have an Autodesk account, you will need to create one to download the software. The goal of this part of the lab is to give students hands-on experience with CAD and rapid prototyping tools, specifically 3D printers.

Each student will start with a Fusion 360 template file (download here), containing a 3D model of the PM2.5 sensor to be enclosed. By following the video instructions, a very basic enclosure can be produced without other prior knowledge of the software. However, extra points will be awarded for enclosure designs that use more advanced CAD techniques. Maybe this means a more modular attachment system; maybe it means work has been done to make the part more light-weight, or more efficient; maybe aesthetic elements have been added to make the product more interesting to use.

Fusion 360 training resources are available here. We suggest that students complete the “Getting Started for Absolute Beginners”; module, from Lesson 3 to Lesson 18 (roughly 5-minute videos per lesson).

For an example specific to this class, please prepare for the assignment by watching the guide here.

Enclosure Design requirements:

  • The fan air intake and the exhaust holes must be open to the atmosphere
  • The enclosure must allow the signal cable to run to the microcontroller

- The sensor must be oriented right-side up, rather than upside down, to prevent reading issues

  • The sensor must have a way to attach to the articulating arm that will hold it. For example -

Note: If you plan to deviate significantly from the version of the enclosure shown in the video, the first 9 minutes of_ this video and this video may be helpful to design parts that work well to manufacture via 3D printing.

Video 1: Introduction to Fusion 360 and the basic principles of CAD modeling:

Video 2: Suggested Preferences and Introduction to Fusion 360 Interface:

Video 3: Making the basic shell for the cap and base of the enclosure:

Video 4: Adding features to complete design criteria:

Video 5 (optional): More advanced modeling techniques to customize the PM2.5 enclosure:

Survey Design and Deployment

You each need to create a “mWater ID” login so that I can add you as an eunmerator to this survey. The online link won’t let you use all the features that you will use in the mWater app. Please email me your mWater ID so I can add you.

Note: When you create your mWater site - please make it PUBLIC - otherwise we can’t access the location information in our analysis.

Online survey link:

https://formlink.mwater.co/#/d1e90568cac8435f9f20d6a1946f8d58/dde75007463243db96006be72d2c6b4e?branding=mwater

Controlled Cooking Test

In this stage, we will apply a modified version of the Water Boiling Test developed by the Global Alliance for Clean Cookstoves and documented in the “ISO 19867-1:2018 Clean cookstoves and clean cooking solutions — Harmonized laboratory test protocols — Part 1: Standard test sequence for emissions and performance, safety and durability”.

For reference, see - https://www.cleancookingalliance.org/technology-and-fuels/testing/protocols.html

In this test, we are seeking to record mean PM 2.5 emissions attributable to a typical cooking enviornment in your home on your stove. For health and safety reasons, as well as fidelity to our research objective, you should NOT do anything differently than you normally would do when preparing a meal on your stove.

Our modified approach for this lab follows the following protocol (see the mWater form for additional data collection steps):

1 - Plan when you will be using your stove to prepare a meal. Prepare your recipe, ingredients and pots and pans ahead of time to avoid the risk of knocking things over.

1 - With your stove off, prepare your data collection apparatus. Your PM 2.5 sensor should be placed approximately 20 cm +/- 5 cm above your burner and 20 cm +/- 5 cm off the centerpoint of the the plume of the emissions path, but still underneath your hood (if you have one). Note: In the real tests, emission sensor placement is 1.5 m above the stove and 1 m away from the edge of the stove to simulate the emissions a person would be exposed to while cooking.

2 - Situate your computer and USB cords in a way that avoids any trip or burn hazards. Keep everything except your sensor out of the way of the burner and emissions plume. PAUSE and inspect your apparatus to review for safety.

3 - Fill out your mWater form including taking pictures of your test setup and recording the start date/time of your test. Start data logging on your computer.

4 - Start your meal preparation. Don’t rush yourself but also don’t dawdle - cook as you normally would.

5 - After you are finished using your stove, turn it off, stop data collection, and record the end time in mWater.

If feasible, try to do at least three of these meal preparation and emission recordings over a few days. We need to have enough data to identify signals and reduce noise in our analysis.

Data Analysis

After you have completed your data collection, cut and paste your data results into this Google sheet and add the additional notations requested:

https://docs.google.com/spreadsheets/d/1iaDrVn1l5xySyJyBaxEZ1e_Nb_CQSsrQnukNrDxF-vI/edit?usp=sharing

We will analyze our data in R collectively.

Here is a dashboard of all the mWater survey responses:

https://embed.mwater.co/#/dashboards/36ee2485702d40889a3d3c77cfad11d2?share=d193ffa29d6843c1a49d6d5d5d334757

survey_data = read.csv("https://api.mwater.co/v3/datagrids/48fcbcf0d40c47f2b08f24b4e7c2983d/download?client=03b34499dde3fc95a1c809226d8ad330&share=&extraFilters=%5B%5D&format=csv")

sensor_data = read.csv("https://docs.google.com/spreadsheets/d/1iaDrVn1l5xySyJyBaxEZ1e_Nb_CQSsrQnukNrDxF-vI/export?format=csv")

# First need to clean up the data. In this data set, we need to discount "Failed" readings: 

sensor_data = subset(sensor_data,sensor_data$Reading != "Failed")

# Because some of the data included string characters (letters), we have to tell R that the "Reading" column is a number: 

sensor_data$Reading = as.numeric(sensor_data$Reading)

# Next each test at the same location will count as a measure contributing to a cluster mean. So we will average all the readings at the same location: 

summary_sensor_data = aggregate(sensor_data$Reading,list(sensor_data$mWater.Location.ID),median)

colnames(summary_sensor_data) = c("Location","Mean")

# We are now going to merge information contained in the mWater surveys with the data from the sensors, in order to add in potentially relevant covariates: 

summary_sensor_data$Hood = "Unknown"
summary_sensor_data$Fan = "Unknown"

#This loop takes the location ID from each testing location and matches it to the ID in the survey data and then pulls out the values for Hood and Fan: 

for (t in 1:length(summary_sensor_data$Location)){
  
  summary_sensor_data$Hood[t] = survey_data$Do.you.have.a.hood.[match(summary_sensor_data$Location[t],survey_data$Cooking.Location.Site...Unique.ID)]
  
  if(is.na(summary_sensor_data$Hood[t])){summary_sensor_data$Hood[t] = "Unknown"}
  
    summary_sensor_data$Fan[t] = survey_data$Are.you.using.an.exhaust.fan.[match(summary_sensor_data$Location[t],survey_data$Cooking.Location.Site...Unique.ID)]
    
   if(is.na(summary_sensor_data$Fan[t])){summary_sensor_data$Fan[t] = "Unknown"}
  
}

# Here is a plot of the mean exposures recorded at each location: 

barplot(summary_sensor_data$Mean, names.arg = summary_sensor_data$Location,main="Mean PM 2.5 Exposure During Cooking", xlab="Location", ylab="PM 2.5 (ug/m3)")

# Now we're going to aggregate the data again, based on the cooking environment characteristics, and plot the results:

summary_sensor_data = na.omit(summary_sensor_data)

summary_sensor_data = aggregate(summary_sensor_data$Mean,list(summary_sensor_data$Fan),median)
colnames(summary_sensor_data) = c("Fan","Mean")

barplot(summary_sensor_data$Mean, names.arg = summary_sensor_data$Fan,main="Median PM 2.5 Exposure During Cooking", xlab="Fan", ylab="PM 2.5 (ug/m3)")


# Now we're going to plot each test as a time series to get a better visualization of what's going on - 

library(ggplot2)

ggplot(sensor_data,aes(x=Seconds,y=Reading,colour=Test,group=Test)) + geom_line()
## Warning: Removed 1 row(s) containing missing values (geom_path).

Air Quality Impacts on Health

We will now evaluate the potential impact on health in a scenario wherein your exposure to air quality is similar to the mean exposure collected through this lab.

To begin you will use the Household Air Polluation Intervention Tool (HAPIT).

  • For the pre-intervention exposure use the mean PM2.5 concentrations in the kitchen for locations where a fan is not used.

  • For the post-intervention exposure use the mean PM2.5 concentrations in the kitchen for locations where a fan is used.

  • Use default values for all other parameters.

For this exercise you will use the public-facing version of HAPIT, developed by Ajay Pillarisetti, located here: https://hapit.shinyapps.io/HAPIT/.

Discussion Questions

  1. What would the disease burden be in the United States if we cooked indoors without hoods (assume the exposures are those recorded without fans)?

  2. What is the health benefit attributable to using hoods and fans?

  3. How do these two disease burden scenarios compare with other causes of disease burden in the United States (https://vizhub.healthdata.org/gbd-compare/)? How about in Low SDI countries?