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.

2015_07_16 Initial testing (MBTA Red line: Alewife to Ashmont)

I started at Harvard station at 3:50. I went to alewife to start from the very end of the Red line. I assume that I got there around 4. I took two measurements at each station. One when there was no subway and another when the subway was coming in. I stood at the middle of the platform, couple steps behind the yellow line. The purpose of the second measurement was to see what happens to air quality when subway comes in and people get on and off. The arrival of subway creates breeze so it will increase an amount of dust presumably. People will also emit some gasses so there will be a difference also. It was quite difficult to get the right timing for the second measurement. It was okay when the station had many commuters but when there were not that many people, I had to get on the subway before it finished taking the measurement. From Harvard square station to The South station there were a lot of people. Other stations had fewer people meaning that the second measurements taken in those ones were not as accurate as the measurements taken in crowded stations. From JFK to Ashmont, there were almost no people at the station. People looked at the setup, but just two people approached me and asked me questions.

I will compare all the gas levels when there was no train, and when the train is coming in. Hydrogen level doesn’t change much. Overall, Hydrogen level tends to drop when the train is arriving although some stations show the opposite. Ozone level also stays mostly the same regardless of the presence of cars, and it also drops when the train arrives. It was the same for Alcohol as well. Dust sensor indicated a significant difference. I expected that as subway went through the rail, it would create the wind and would storm up the dust. Out of 17 stations, dust sensor worked at 14 stations. 3 stations just showed 0.62 for some reason. Out of 17 stations, only 6 stations had higher dust concentration on the second measurement. That indicates that it is actually dustier when the car is not around.

Hydrogen level was high in Alewife, Davis, Park street and Ashmont (over 380). It was low at Charles, South, JFK, and Shawmut. Except for South, three other stations, Charles, JFK, and Shawmut stations were located outside.

There was not much difference in ozone level between stations. Fields corner had the lowest ozone level (86.9, 93.8) and the highest was Alewife (138.1, 137.5).

Alcohol level had slight variations. It was the high in Park street, Downtown crossing, South, and Broadway (over 170). All of those stations, except for Broadway had a lot of commuters. When there are more people, there are probably more people who drank alcohol. Alcohol level was low in outside stations (around 130) and stations where there were almost no people.

Carbon Monoxide didn’t have many variations. It was highest in Porter square (182) and lowest in Charles (146).

Dust sensor showed the biggest variation. It was highest in Ashmont when a train was arriving (2475) and lowest in Kendall also when the train was coming in (78).

Sensors seem to work fine except I need to look into hazardous gas.

2015_07_15 Initial testing (pollution expected areas)

Today was the first field testing with an actual mesh enclosure and LCD. Setup was more portable and wires were less showing. Several people asked me questions about the device. More than any other testing. I noticed that old men are really interested in the device. They were all surprised to hear that I was a high school student. One of them asked me if I am an MIT student and another man asked me if I had a business card. I was happy to learn that people are interested in what I am doing. It was a bit scary when a police officer asked me what I was doing, but he was just curious after all.

I went to several places where there were expected to be air pollution. I also tested chemicals that have a strong scent. It also rained during testing today so that was different from other days.

Compared to a regular road, the car repair garage had significantly lower Hydrogen level (Normal: 241, Garage: 121). It also had lower ozone level (186, 153) and lower hazardous gas (3.2, 2.9). It had higher alcohol (146, 160) and higher Carbon Monoxide level (162, 187). I expected higher hazardous gas percentage for a repair shop. Considering the difference was small and that the repair shop was near the road, the hazardous gas sensor seems to work fine.

Construction site had the second lowest ozone level (107). Alcohol level and Carbon Monoxide level were similar to car repair garage (Alcohol: 166, Carbon Monoxide: 186).

Waste disposal area had the lowest ozone level (105). Alcohol and Carbon Monoxide level were almost the same as repair garage and construction site (165). Waste disposal area had the highest hazardous gas level out of all the locations (3.7).

Lush had all kinds of soap that smelled like heaven. However, alcohol level was significantly higher than other places (187.5). Carbon Monoxide level was significantly high as well (207.9). Since soap is an alkaline solution that contains fatty acids and glycerol, it might have high alcohol level and Carbon Monoxide level.

I took a measurement when I was passing people who were drinking. As expected, the alcohol level marked the highest (285). Carbon Monoxide level was equally as high (284).

Frigidaire vent was really hot (27.3 oC) compared to other locations at that time. I could feel the hot gas coming out of the vent when I was near it. Hydrogen level marked the lowest (105.7).

It rained during field testing. Rain dropped temperature and amount of light as expected. Rain als dropped ozone (sunny road: 186, rainy road: 141). It had slight increase in alcohol and Carbon Monoxide level.

I tested tide, nail polish, and nail polish remover as a highly toxic chemicals. Nail polish remover had the highest Hydrogen (177), ozone (181), alcohol (312), Carbon Dioxide (699), and Hazardous gas level (3.5). Those are all the gas sensors. Remover’s gas levels were not slightly but rather significantly higher than all the other chemicals. That indicates that nail polish remover is the most toxic and strong chemical out of the three. Tide had the lowest gas levels so that would allow me to conclude that tide is milder than the other chemicals.

Alcohol and Carbon Monoxide sensor seems to overlap their measurements. I am not exactly sure what ozone is measuring. The hazardous Gas sensor might not be working because the values are much lower than the 2015_07_07 measurements. Today it remained around 3, but 07_07 measurement had around 140.

 

2015_07_07 Initial testing (Harvard square area - Commercial places)

Arduino board was not working properly since yesterday. It worked in my room but once I got out, the device just stopped measuring. It was a strange situation because it worked perfectly fine in the room. I was already worried to start field testing because I have already been to a station twice and had to come back because the device didn’t work. As expected, the board stopped working on the bus. I came up with a trick to reset the board every time. I just had to be extra careful of the order because ‘master count’ would be shown as 1 for every measurement. It was when I was texting Dr. Paster, that I realized the problem. I was unplugging and replugging the cord every time to start the device, which meant that something was wrong with the cord. So I bought another USB cord and plugged it in. When I saw LED blinking, I was so excited, relieved, and angry at the same time. Excited because I could take new measurements, relieved because I don’t have to keep an eye on the SD card light, and angry because it was the cord, which is not even a part of Arduino program, that was causing the problem. But anyways, I was ready to take measurements and I had to hurry because the battery was running out.

I tried to measure twice at the same location to be more consistent with the data. Most of the other sensors were consistent, but I could see that light sensor varied greatly just like the last time. Even around 8 PM, Harvard square was still quite bright (515 lux).

It was extremely humid (60+%) and hot (29+oC) around 4 PM today. At 8 PM, the temperature dropped to about 26oC but humidity rose to about 70%.

I chose Bank of America ATM space and Starbucks as my two extremes for the number of people. There was just me in the ATM space and there were more than 30 people in Starbucks. Starbucks had about 1.2 higher Hydrogen level than that of ATM space (ATM space: 172.14, Starbucks: 208.7). Ozone level was about the same (152, 151.74). Carbon Monoxide level was about 1.2 times higher in Starbucks (163.4, 190.58). The hazardous gas amount was also about 1.2 times higher in Starbucks (127.64, 154.52). By this, it can be inferred that more people means more gas.

I made a prediction that bookstore, where there are hundreds of books made of thousands of chemically produced papers would have high contamination rate. Hazardous gas and Alcohol gas level were pretty high, but I think that depended more on the number of people. Bookstore had more people than ATM space but fewer people than Starbucks, and the amount of gas seems to fall between those two extremes.

I went to three Outbound stations; Porter, Davis, and Alewife. Porter station had highest ozone level (159.98) and Alewife had the lowest (143.74). Porter station had the highest gas level, in general, including ozone, Alcohol, Carbon Monoxide, and Hazardous gas. However, the differences were small, even negligible. All three stations had much fewer commuters compared to that of Inbound stations. Alewife station had the highest ceiling (4.9m).

2015_07_02 Initial testing (Mt.Auburn area)

This was my second field measurement.  I was more aware of the consistency of the environments and variety of locations.The light source was hard to keep under control. Even on the same bus, depending on the amount of sunlight, light measurement varied significantly.

Humidity outside around 4 PM was 42%. Garden which was surrounded by the plant was relatively higher, as 50.14%. Subways were more humid than the buses (subway: 50%, bus: 38%). Commercial places such as Burger king and Macy’s had lower humidity level, which were 36.98% and 37.25% each.

Temperature outdoor around 4 PM was 27oC. The temperature dropped drastically after 6:30 PM to 23.62 oC.

Harvard Square bus station had the lowest altitude (7.96m) which was even lower than the subway stations.

Hydrogen level was especially higher in indoor locations such as Burger king, and Macy’s, where a lot of people were concentrated in a limited space. In the subway, during a rush hour where there were much more people than the previous subways, Hydrogen level was about 26 higher.I visited 5 red line subway stations; Harvard Square, Central Square, Kendall, Charles, and Park Street stations. Out of five stations, Charles station was the brightest because it was an outdoor station. The darkest station was Kendall station, which had 35 lux. The humidity of the five stations were about the same but Park Street station was the most humid (49.21%) and Charles station was least humid (42.06%). Harvard Square station was the hottest (28.59oC), and Kendall station was the coolest (26.31oC). Central Square station was the lowest altitude station (9.08m). Charles station which was outside had the highest altitude (20.7m). Harvard Square station had the lowest ceiling and Central Square station had the highest ceiling. Hydrogen level was highest in Park Street station (128.64). Park street station had a connection to Green line, which means that there were more passengers in the station. According to today’s measurements, more people means higher Hydrogen level.

2015_07_01 Initial testing (Near Holworthy St, Cambridge, MA 02138)

Today was my first field measurement. It was very exciting but at the same time I was worried that people might notice it too much and ask too many questions about the testing. Luckily, they did show interest but not too much.

I had 28 different set of data from 19 different locations. Some values, including pressure and Oxygen level, remained almost constant or had very little variations between locations. Significant differences were shown in amount of light, humidity, temperature, altitude, height of ceiling, and propane and Ethanol level.

The light was detected the most outside. Around 4 PM, the amount of light was well above 11,000 lux. Subway had 113.8 lux to 146.1 lux. Different subway stations showed a significant difference in light. Harvard station had 159.22 lux, Central square had 174.5 lux, and Kendall square 54.36 lux, which was the darkest among three.

Humidity seemed to be higher around plants. All three subway stations had about 55% humidity. People feel pleasant between 40% and 60% humidity, so subway stations seem to meet that pleasant level. The humidity level was significantly low at a clothing store (Urban Outfitters) as 32.6%. For more pleasant shopping, the store would need to raise the humidity level.

Outside temperature around 4 PM was about 29oC. Subway stations were about 27oC. A grocery store (Star Market) showed the lowest temperature which was 24.68oC.

Stations showed lower altitude, around 56m, compared to other locations. Harvard square station was the lowest among the three.

Propane Ethanol level seems to be high around plants. Porch, Harvard park, and Harvard which were surrounded by plants had high Propane Ethanol level compared to other locations.

Three subway stations, which were my main experiment locations didn’t show any significant difference between each other. I see several discrepancies in the same station, so there is a possibility of not consistent measurement. To get more accurate measurements, I need to keep the environment as consistent as possible. For example, I should take into account if I am standing under a light source or not, how many seconds have passed after bus or subway door had closed, and even number of people. I should be more aware of the variants next time I take measurements.

Device development

Used Arduino Mega ADK as microcontroller.

Device phase 1: Getting the idea

The sensors were simply put on the breadboard. There were 9 sensors connected; lux, DHT, 2 Accelerometer, Barometric pressure, Oxygen, Air contaminants, Hydrogen, and Propane Ethanol. The focus was more on to see which sensors were sensitive to changes. It was also to see what additional sensors were needed to get useful measurements. The setup was relatively simple, so it didn’t have an enclosure.


Device phase 2: Field testing

Breadboard seemed to be fuller with added sensors. There were 13 sensors connected; lux, DHT, Barometric pressure, Sonar, Accelerometer, Propane Ethanol, SD card reader, Ozone, Alcohol gas, Carbon Monoxide, Hazardous gas, Oxygen, Dust. Air contaminants and Hydrogen sensors were taken out because the other sensors were able to detect air contaminants and Hydrogen as well. There was no need for repetition. In addition to newly added gas sensors, second phase device had hardware that allowed field testing. SD card reader, a switch, and an LED light bulb. SD card reader saved the data on the SD card so there was no need to bring laptops. The switch turned on and off the setup so selective testing on specific location was possible. LED light bulb was used for keeping track of the order of measurements. Setup was put inside a box to be more secure.


Device phase 3: sturdy and less intrusive

Setup became even more complex and to start the actual testing, there was a need for a better enclosure. The enclosure needed to protect the sensors yet allow ventilation for air sensors. Setup also needed to be less conspicuous. With the wires hanging out of the boxes, people might think the setup is a bomb. Another feature of phase 3 of the device was that it integrated an LCD screen. The screen kept track of time, order, and initiation so the setup no longer needed a huge button or the bright red LED light.