Arduino code

Arduino is an open-source microcontroller so it is easy to download examples. Websites like Adafruit provides libraries for each sensor. It is possible to test the sensors with the provided libraries, but it is the programmer’s job to integrate those sensors into a specific code needed. It is better to make several revisions onto a working code.

A. All_together

This code was written during Device phase 1. 8 sensors that had separate codes were put into a single code.


B. All_together_average

All_together_average is an integration of average into All_together code. With running sum and average, this code takes an average of each sensor. It takes about 40 seconds to take an average. It is easier to compare with the average because sensor values oscillate within the time interval.


C. All_together_average_withe_save

When doing a field test, it is inconvenient to bring laptops. An SD card can make the setup portable. SD card stores data as a datastring. After field testing, data can be read on a computer with SD card reader. It is also easy to put the datalog on SD card into a spreadsheet. This code was written during Device phase 2, which had a switch to initialize the testing, and LED light to show the order. Master count code kept track of the order on the SD card.


D. All_together_average_with_save_longer

This version of the code is the next version of All_together_average_with_save. All_together_with_save_longer has a slight yet crucial modification to the previous code. This code takes longer and continuous measurements. While the previous code took 50 measurements in 40 seconds, this code takes 750 measurements in 10 minutes. This is useful to show the difference in gas concentration over time. For example, during rush hour, over a ten-minute interval, when commuters get on and off the subway, sensors will pick up the difference. It can also be more accurate than the previous codes because it takes 750 measurements instead of 50. However, it can be troublesome when measurements need to be taken in a short time.


E. All_together_average_with_save_LCD

This is the ultimate version of the code. It has all the other features minus switch and LED light because LCD screen can initialize the sensors and keep track of the order.


F. All_together_average_with_save_LCD_array

Array shows the change over time of the sensor values. For example, it will show the whole process of how the subway comes in, stops for passengers to get on, and leave the platform. Values will oscillate over the course of arrival and departure, which will indicate when the gas level will be the highest and the lowest.