Introduction: Fog Sensor - Particle Photon - Save Data Online

To measure the amount of fog or smoke in the air we made this fog sensor. It measures the amount of light a LDR receives from a laser, and compares it to the amount of light of the surrounding. It posts the data on a google sheet realtime via IFTTT.

Step 1: Ingredients

- Particle Photon

- 2x Breadboard

- jumper wires

- 2x 220k Ohm resistors

- 3x 10k Ohm resistors

- 3 LED's (green, red, yellow)

- Humidity Sensor (DHT11)

- 2x LDR

- Laser

- Some timber or similar household materials for assembling the components.

- Something to cover the sensors ( i.e. a pvc duct)

Step 2: Setting Up the LED's

Connect the wires following the picture. Pin D7 allready has an internal resistor, so it can be connected directly to the LED.

Step 3: Setting Up the LDR's, Laser and Humidity Sensor

Connect the wires as denoted in the picture. We used a second breadboard for holding the LDR sensors, but they could also be connected directly.

The exact distance between the laser and LDR isn't important, however it should be at least 30 cm. The laser should be pointed at one of the LDR's, so the second LDR can be used as a reference. They should be exposed to the same amount of light from the surroundings. Make sure all the equipment is connected very rigidly, a small change in the direction of the laser screws up your measurements.

We used a pvc duct to shield the LDR's from direct light from the surroundings. You can be creative and use some cardboard or other materials as well. Make sure the fog or smoke can still enter the laser beam.

Step 4: The Code

Coding is done at build.particle.io. In console.particle.io the published values will be displayed.

The code we used can be found in the .txt file.
The particle software doesn't automatically understand the first line. You need to add the Adafruit_DHT library manually.

Further explanations:

To calibrate the LDR's the laser is turned off at the beginning. Both LDR's are compared over a series of measurements and the measured difference is set as 'DS' . This is the difference in sensitivity of the LDR's.

To calibrate the surrounding light, the laser is turned on and the maximum measured value of S is determined. This is set as 100% for the further measurements. It's value is saved as 'MaxS'.

After this the setup is completed and the sensor starts run timers to measure the air every 0.1 seconds for the LED's and sends a measurement every 5 seconds to the console.

Step 5: IFTTT

IFTTT - If This Than That is an useful tool to save the published values. Create an account if you don't already have one at IFTTT.com. Create a new applet.

If This

Click 'This', search for particle and click on it. Choose 'new event published'. In 'event name' type 'info'. This is the name of the events that are published every 5 seconds and need to be saved in the document. Click 'create trigger'.

Then That

Click 'that', search for sheets. Choose the google sheet icon. They ask you to connect your IFTTT account to google if you haven't already. Click 'add row to spreadsheet'.

Don't change any of the default settings, except for the 'formatted row' part. Copy paste the .txt in this field.

In order to make the data useful, excel needs to extract the percentage and time of measurement into different columns. To make this happen automatically for every new row, the code is written in the IFTTT applet.

Go to docs.google.com to open your new sheet called 'info'.

It may take some time to create the sheet and make the data available. Be patient.

LED Contest 2017

Participated in the
LED Contest 2017