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 / m^3\)).

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 (all diodes are like this! LED stands for “Light Emitting Diode”).

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 that will likely be different for you). 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!

Modifying the Firmware

Here’s the code that’s running on the microcontroller. Feel free to download, modify and test! You can follow the guide here to quickly learn how to write new firmware to the microcontroller.

https://github.com/TaylorSharpeSS/MCGE_PM25

In order to make the firmware work, you will need to do a few things: (1) Install the “Adafruit SAMD Boards” in the boards manager, and (2) Install the “Adafruit_PM25AQI” and “Adafruit_DotStar.h” libraries in the library manager. These are both done inside the Arduino interface. A good place to start is the guide above.

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, or to identify it.

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

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 environment 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 center-point 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 - Start data logging on your computer. Remember to log the data with timestamps, and log to a text file! If you’re using CoolTerm, you can do this by setting up the logging settings and starting to write to a file, as shown below:

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. Make sure the logged data has been saved to a text file! Include whether the logged event used ventilation by adding the phrase, “WithVentilation” or “WithoutVentilation” to the text file.

Here’s what your text file should look like, in a room with good air quality:

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 - and as an added bonus, you’ll know a little bit more about your own exposure to harmful air pollution.

Some examples of cooking test setups from previous years
Some examples of cooking test setups from previous years

Data Analysis

We will work together as a class to to analyze the data. In previous classes with graduate students, we incorporated a survey system and a number of extra steps; for our class, we will be taking a look at the overall profile of indoor air pollution during a cooking event, and thinking about…

  1. How harmful is exposure to this concentration of air pollution?

  2. How much can we decrease air pollution by using an active ventilation system?

Air Quality Impacts on Health

Finally, 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 Pollution Intervention Tool (HAPIT), which you have used in a previous lab.

  • 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?