Advertisement
Guest User

Main code

a guest
Jun 24th, 2016
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.73 KB | None | 0 0
  1. #include sensors.cpp
  2.  
  3. /*****************************DEVICE CREDENTIALS***********************************/
  4. String accesstoken = "e125058410689732277b9e1213d87436581edfbb";    //not currently used
  5. String deviceID = "1c0021001547353236343033";                       //this is particular for each photon
  6. /*****************************NETWORK CREDENTIALS***********************************/
  7. long timestamp;                                                     //Variable to hold UNIX time stamp
  8. int clientPort = 80;                                                //TCP Port no.
  9. byte server[] = { 10, 0, 0, 20 };                                   //IP Address of server, can be converted to work with DNS
  10. TCPClient client;                                                   //create client object
  11. /*****************************VARIABLES***********************************/
  12. long previousTime;                                                  //counter for timer.... NOTE THIS DOES NOT YET DEAL WITH 49 DAY OVERFLOW!
  13. int interval = 20000;                                               //interval to send data, and divider for everything else
  14.  
  15. /**************************CREATE SENSOR OBJECTS*******************************/
  16. MG811_CO2 co2sensor = new MG811_CO2(A0,3);
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. const int MG811_CO2 =       0;                                      //0-4095 analog                          //Sensor type constants
  25. const int MQ135_O3 =        1;                                      //0-4095 analog
  26. const int KY037_DECIBEL =   2;                                      //0-4095 analog
  27. const int MQ2_LPG =         3;                                      //0-4095 analog
  28. const int SMALL_DUST =      4;                                      //Custom digital
  29. const int LARGE_DUST =      5;                                      //custom digital
  30. const int BH1750FVI_LUX =   6;                                      //custom I2C
  31.  
  32. //EACH ONE MIGHT NEED ITS OWN COUNTER
  33.  
  34.  
  35. /*****************************SETUP***********************************/
  36. void setup()
  37. {
  38.   Serial.begin(115200);                                            //Begin serial at max baud rate
  39.   previousTime = millis();                                         //Store time since program start
  40.   lastCheck = millis();                                            //Store time since check of telaire pins
  41.  
  42.  
  43. }//end setup
  44.  
  45. /*****************************LOOP***********************************/
  46. void loop()
  47. {
  48.   //check if a sample is required
  49.   if (co2Sensor.checkSample(previousTime, interval)  == true)
  50.   {
  51.     co2Sensor.sample();
  52.     co2Sensjor.samplee();
  53.   }
  54.  
  55.   if (co2Sensor.checkRead(previousTime, interval) == true)
  56.   {
  57.     Serial.println("CO2 Sensor: " + (String)co2sensor.read());
  58.   }
  59.  
  60. }//end loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement