Gregory MatosAugust BehmEros Vazquez
Published

Photon Athletic Performance Sensor

These sensors aim to measure temperature, humidity, and CO2 levels in two separate areas to determine which is better for athletic activity.

IntermediateWork in progress646
Photon Athletic Performance Sensor

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×14
MQ135 Gas Sensor
×2
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×2
Resistor 10k ohm
Resistor 10k ohm
×2

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Google Sheets
Google Sheets

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Schematics

Casing File

*This file can only be edited in Adobe Illustrator.
*Be sure cutter settings are set according to the material.
Use this to cut out a box casing ( from wood) in a laser cutter.

Code

Sensor Collection Code

Arduino
Use this code in Particle build, then upload it to a sensor. Be sure to have both( or one) of your sensors properly wired.
#include <Adafruit_DHT.h>


#define DHTPIN 4            // what pin we're connected to
#define DHTTYPE DHT22       // DHT 22 (AM2302)

DHT dht(DHTPIN, DHTTYPE);

double hum;                 // current hum
double temp;                // current temp
double co2;                 // current co2 lvl

void setup() {
    
    pinMode(A0, INPUT);
    Serial.begin(9600);
    pinMode(DHTPIN, INPUT);
    
    Particle.variable("hum", hum);
    Particle.variable("temp", temp);
    Particle.variable("co2", co2);
}

void loop() {    
    double checkHum = dht.getHumidity();
    double checkTemp = dht.getTempFarenheit();
    double checkCo2 = analogRead(A0);
    
    /*
    if (checkHum > 0 && checkHum < 100)
        hum = checkHum;
        
    if (checkTemp > 32 && checkTemp < 100)
        temp = checkTemp;
    */
    
    Serial.println("Temp: " + String(checkTemp));
    Serial.println("Hum: " + String(checkHum));
    Serial.println("Co2: " + String(checkCo2));
        
    delay(3000);
}

Spreadsheet Recording Code

JavaScript
Use this in the code of a google spreadsheet.
function collectCurrent() {
  "use strict";
  try
  {
    //Replace the device ID below with your Photon's unique device ID
    var deviceID = "200029000347343233323032";
    
    //Replace the access token below with your Photon's unique access token
    var accessToken = "867739e105b7366392f823d16060d57d6a1ab90d";
    
    //Replace the value below with you group ID
    var groupID = 404;
    
    //Replace the room number below with location of the Photon
    var room = 134;
    
    var sheet = SpreadsheetApp.getActiveSheet();

    // Fetch the value of the testValue variable from the Spark Cloud API.
    // The name of your variable in Particle's cloud must match the variable in the URL below.
    var response = UrlFetchApp.fetch("https://api.spark.io/v1/devices/" + deviceID + "/hum?access_token=" + accessToken);

    // Parse the JSON and extract the testValue.
    var jsonResponse = JSON.parse(response.getContentText());
    var hum = jsonResponse.result;

    response = UrlFetchApp.fetch("https://api.spark.io/v1/devices/" + deviceID + "/temp?access_token=" + accessToken);
    jsonResponse = JSON.parse(response.getContentText());
    var temp = jsonResponse.result;    
    
    response = UrlFetchApp.fetch("https://api.spark.io/v1/devices/" + deviceID + "/co2?access_token=" + accessToken);
    jsonResponse = JSON.parse(response.getContentText());
    var co2 = jsonResponse.result;  

    // Create a timestamp.
    var timeStamp = new Date();

    // Append the timestamp and the temperature to the sheet.
    sheet.appendRow([timeStamp, groupID, room, temp, hum, co2]);
  } catch (e)
  {	
    // If something doesn't work, log it, then rethrow the error.
	Logger.log(e.name + ": " + e.message);
	throw (e);
  }
}

Credits

Gregory Matos

Gregory Matos

1 project • 1 follower
August Behm

August Behm

1 project • 1 follower
Eros Vazquez

Eros Vazquez

1 project • 2 followers

Comments

Add projectSign up / Login