Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sensors.cpp
- /*****************************DEVICE CREDENTIALS***********************************/
- String accesstoken = "e125058410689732277b9e1213d87436581edfbb"; //not currently used
- String deviceID = "1c0021001547353236343033"; //this is particular for each photon
- /*****************************NETWORK CREDENTIALS***********************************/
- long timestamp; //Variable to hold UNIX time stamp
- int clientPort = 80; //TCP Port no.
- byte server[] = { 10, 0, 0, 20 }; //IP Address of server, can be converted to work with DNS
- TCPClient client; //create client object
- /*****************************VARIABLES***********************************/
- long previousTime; //counter for timer.... NOTE THIS DOES NOT YET DEAL WITH 49 DAY OVERFLOW!
- int interval = 20000; //interval to send data, and divider for everything else
- /**************************CREATE SENSOR OBJECTS*******************************/
- MG811_CO2 co2sensor = new MG811_CO2(A0,3);
- const int MG811_CO2 = 0; //0-4095 analog //Sensor type constants
- const int MQ135_O3 = 1; //0-4095 analog
- const int KY037_DECIBEL = 2; //0-4095 analog
- const int MQ2_LPG = 3; //0-4095 analog
- const int SMALL_DUST = 4; //Custom digital
- const int LARGE_DUST = 5; //custom digital
- const int BH1750FVI_LUX = 6; //custom I2C
- //EACH ONE MIGHT NEED ITS OWN COUNTER
- /*****************************SETUP***********************************/
- void setup()
- {
- Serial.begin(115200); //Begin serial at max baud rate
- previousTime = millis(); //Store time since program start
- lastCheck = millis(); //Store time since check of telaire pins
- }//end setup
- /*****************************LOOP***********************************/
- void loop()
- {
- //check if a sample is required
- if (co2Sensor.checkSample(previousTime, interval) == true)
- {
- co2Sensor.sample();
- co2Sensjor.samplee();
- }
- if (co2Sensor.checkRead(previousTime, interval) == true)
- {
- Serial.println("CO2 Sensor: " + (String)co2sensor.read());
- }
- }//end loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement