2. The code


The code gives instructions to the Arduino. The Arduino is the “computer” of the circuit, which interfaces between the circuit and the app.
The circuit collects electrical data about the level of air pollutants, and the app displays the electrical data in numerical form on a mobile device.

A few of the ways that the code directs the Arduino is by designating the Arduino’s pins as high or low voltage, and assigning the overall resistance of the circuit. The code also directs the Arduino on how to collect data and interact with the app. For example, when the “Collect” button is pressed on the app, the Arduino receives a command to collect data and transfer it to the app.  The time in between data point collections is also encoded. There are many more ways the code enables the Arduino to support the circuit and the app, all of which allow the sensor system to function as intended. 

Intructions:

1. Download the arduino software

The Arduino software is free, and can be downloaded at https://www.arduino.cc/en/Main/Software.
When you arrive at the webpage look under 'Download the Arduino IDE' and ensure to download the version of the software that aligns with the operating system you are using.

2. Open the arduino software

3. Copy+paste in the code

Various versions of the code are given below in downloadable files.
       Version 1 contains the code for only the PM sensor
       Version 2 contains the code for both the PM sensor and the NOx sensor. 
       Version 1 with comments contains the code for only the PM sensor, including comments
       Version 2 with comments contains the code for both the PM sensor and the NOx sensor. 

The document with comments includes annotation to allow a user unfamiliar with coding to understand how the various pieces work. The comments are not read by the Arduino, and therefore do not affect functionality. (Anything within “/* */” and behind “//” are comments, and appear in grey). 

Regardless of the code you use, copy in everything as it is to ensure functionality.

4. Plug the arduino into your computer

Use the USB cord to connect your Arduino board to a USB port on your computer.
*Prior plugging in the Arduino, unplug the two wires connected to Pins 0 and 1
(which are connected to the Bluetooth module.)

5. Upload the sketch

Before uploading, open the “Tools” menu.
-Ensure that the correct board is selected (Arduino UNO/Genuino)
-Ensure that you are using the correct port. If you are using Windows, you can verify which port corresponds to the Arduino in the Device Manager. To do this, open the Start menu, type “device manager”, and open the device manager. You might get a warning that you do not have administrative permissions. This is ok, since you don’t want to make any changes in the Device Manager. Then click on the little arrow next to “Ports”, or double click on “Ports”. You should be able to see which port (COM#) is associated with the Arduino.

Then, click the “Upload” button.

6. Check functionality

Click on the “Serial Monitor” button in the top right corner of the window.
Next, click on the bar at the top of the Serial Processor window, type a “1” and hit enter.
This should start the data collection process. If “COLLECTING DATA” appears right away,
this indicates that the Arduino is functioning.