Guest User

WeatherStation code - 01ste02 on arduino forums

a guest
Apr 15th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 19.15 KB | None | 0 0
  1. /*
  2.   Forecast calculation code from Henrik Ekblad @ mysensors.org: https://www.mysensors.org/build/pressure
  3. */
  4.  
  5. #include "WiFiEsp.h"
  6. #include <Wire.h>
  7. #include <Adafruit_Sensor.h>
  8. #include <Adafruit_TSL2561_U.h>
  9. #include <Adafruit_MPL115A2.h>
  10. #include "Adafruit_SGP30.h"
  11. #include <DHT.h>
  12. #include <DHT_U.h>
  13.  
  14. #define DHTPIN 2 // Pin which is connected to the DHT sensor.
  15. #define DHTTYPE DHT22 // DHT 22 (AM2302)
  16.  
  17. bool debug = false;
  18.  
  19. Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
  20. Adafruit_MPL115A2 mpl115a2;
  21. Adafruit_SGP30 sgp;
  22. DHT_Unified dht(DHTPIN, DHTTYPE);
  23.  
  24. // Sleep time between reads (in seconds). Do not change this value as the forecast algorithm needs a sample every minute.
  25. const unsigned long SLEEP_TIME = 60000;
  26. const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
  27. enum FORECAST
  28. {
  29.   STABLE = 0,            // "Stable Weather Pattern"
  30.   SUNNY = 1,            // "Slowly rising Good Weather", "Clear/Sunny "
  31.   CLOUDY = 2,            // "Slowly falling L-Pressure ", "Cloudy/Rain "
  32.   UNSTABLE = 3,        // "Quickly rising H-Press",     "Not Stable"
  33.   THUNDERSTORM = 4,    // "Quickly falling L-Press",    "Thunderstorm"
  34.   UNKNOWN = 5            // "Unknown (More Time needed)
  35. };
  36.  
  37. float lastPressure = -1;
  38. float lastTemp = -1;
  39. int lastForecast = -1;
  40.  
  41. const int LAST_SAMPLES_COUNT = 5;
  42. float lastPressureSamples[LAST_SAMPLES_COUNT];
  43.  
  44. // this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
  45. // get kPa/h be dividing hPa by 10
  46. #define CONVERSION_FACTOR (1.0/10.0)
  47.  
  48. int minuteCount = 0;
  49. bool firstRound = true;
  50. // average value is used in forecast algorithm.
  51. float pressureAvg;
  52. // average after 2 hours is used as reference value for the next iteration.
  53. float pressureAvg2;
  54.  
  55. float dP_dt;
  56. bool metric;
  57.  
  58. const char ssid[] = "SHARK_2G";            // your network SSID (name)
  59. const char pass[] = "Growth24";        // your network password
  60. int status = WL_IDLE_STATUS;     // the Wifi radio's status
  61. float pressure = 1500;
  62. //String forecast = "4";
  63. //int forecast = -1;
  64. String light = "0";
  65. String temperature = "0";
  66. String humidity = "0";
  67. String humidityState = "0";
  68. String luxRequest = "";
  69. String pressureRequest = "";
  70. String PPM = "0";
  71. const char server[] = "192.168.1.227";
  72.  
  73. // Initialize the Ethernet client object
  74. WiFiEspClient client;
  75.  
  76. void setup()
  77. {
  78.   // initialize serial for debugging
  79.   Serial.begin(115200);
  80.  
  81.   if (Serial) {
  82.     debug = true;
  83.   } else {
  84.     debug = false;
  85.   }
  86.  
  87.  
  88.   // initialize serial for ESP module
  89.   Serial1.begin(9600);
  90.   // initialize ESP module
  91.   WiFi.init(&Serial1);
  92.  
  93.   // check for the presence of the shield
  94.   if (WiFi.status() == WL_NO_SHIELD) {
  95.     if (debug) {
  96.       Serial.println("WiFi shield not present");
  97.     }
  98.     // don't continue
  99.     while (true);
  100.   }
  101.  
  102.   // attempt to connect to WiFi network
  103.   while ( status != WL_CONNECTED) {
  104.     if (debug) {
  105.       Serial.print("Attempting to connect to WPA SSID: ");
  106.       Serial.println(ssid);
  107.     }
  108.     // Connect to WPA/WPA2 network
  109.     status = WiFi.begin(ssid, pass);
  110.   }
  111.   // you're connected now, so print out the data
  112.   if (debug) {
  113.     Serial.println("You're connected to the network");
  114.   }
  115.  
  116.   if (debug) {
  117.     printWifiStatus();
  118.     Serial.println();
  119.   }
  120.   initSensors();
  121. }
  122.  
  123. void loop()
  124. {
  125.   // if there are incoming bytes available
  126.   // from the server, read them and print them
  127.   while (client.available()) {
  128.     char c = client.read();
  129.     if (debug) {
  130.       Serial.write(c);
  131.     }
  132.   }
  133.  
  134.   getSensors();
  135.  
  136.   //int forecast = sample(pressure);
  137.  
  138.   //Serial.println(forecast);
  139.   request(luxRequest);
  140.   delay(60000);
  141. }
  142.  
  143. void printWifiStatus()
  144. {
  145.   // print the SSID of the network you're attached to
  146.   Serial.print("SSID: ");
  147.   Serial.println(WiFi.SSID());
  148.  
  149.   // print your WiFi shield's IP address
  150.   IPAddress ip = WiFi.localIP();
  151.   Serial.print("IP Address: ");
  152.   Serial.println(ip);
  153.  
  154.   // print the received signal strength
  155.   long rssi = WiFi.RSSI();
  156.   Serial.print("Signal strength (RSSI):");
  157.   Serial.print(rssi);
  158.   Serial.println(" dBm");
  159. }
  160.  
  161. void initSensors() {
  162.   /* Initialise the sensors */
  163.   dht.begin();
  164.   if (!tsl.begin())
  165.   {
  166.     /* There was a problem detecting the TSL2561 ... check your connections */
  167.     if (debug) {
  168.       Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
  169.     }
  170.     while (1);
  171.   }
  172.   if (! sgp.begin()) {
  173.     if (debug) {
  174.       Serial.println("Sensor not found :(");
  175.     }
  176.     while (1);
  177.   }
  178.  
  179.   /* Display some basic information on this sensor */
  180.   displaySensorDetails();
  181.  
  182.   /* Setup the sensor gain and integration time */
  183.   configureSensor();
  184.   mpl115a2.begin();
  185. }
  186.  
  187. void displaySensorDetails(void)
  188. {
  189.   sensor_t sensor;
  190.   tsl.getSensor(&sensor);
  191.   if (debug) {
  192.     Serial.println("------------------------------------");
  193.  
  194.     Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  195.     Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  196.     Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  197.     Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" lux");
  198.     Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" lux");
  199.     Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" lux");
  200.     Serial.println("------------------------------------");
  201.     Serial.println("");
  202.   }
  203.  
  204.   dht.temperature().getSensor(&sensor);
  205.   if (debug) {
  206.     Serial.println("------------------------------------");
  207.     Serial.println("Temperature");
  208.     Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  209.     Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  210.     Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  211.     Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" *C");
  212.     Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" *C");
  213.     Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" *C");
  214.     Serial.println("------------------------------------");
  215.   }
  216.   // Print humidity sensor details.
  217.   dht.humidity().getSensor(&sensor);
  218.   if (debug) {
  219.     Serial.println("------------------------------------");
  220.     Serial.println("Humidity");
  221.     Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  222.     Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  223.     Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  224.     Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println("%");
  225.     Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println("%");
  226.     Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println("%");
  227.     Serial.println("------------------------------------");
  228.   }
  229.   // Set delay between sensor readings based on sensor details.
  230.   //delayMS = sensor.min_delay / 1000;
  231.   if (debug) {
  232.     Serial.print("Found SGP30 serial #");
  233.     Serial.print(sgp.serialnumber[0], HEX);
  234.     Serial.print(sgp.serialnumber[1], HEX);
  235.     Serial.println(sgp.serialnumber[2], HEX);
  236.   }
  237.  
  238.   delay(500);
  239. }
  240.  
  241. void configureSensor(void)
  242. {
  243.   /* You can also manually set the gain or enable auto-gain support */
  244.   // tsl.setGain(TSL2561_GAIN_1X);      /* No gain ... use in bright light to avoid sensor saturation */
  245.   // tsl.setGain(TSL2561_GAIN_16X);     /* 16x gain ... use in low light to boost sensitivity */
  246.   tsl.enableAutoRange(true);            /* Auto-gain ... switches automatically between 1x and 16x */
  247.  
  248.   /* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
  249.   tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);      /* fast but low resolution */
  250.   // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS);  /* medium resolution and speed   */
  251.   // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */
  252.  
  253.   /* Update these values depending on what you've set above! */
  254.   if (debug) {
  255.     Serial.println("------------------------------------");
  256.     Serial.print  ("Gain:         "); Serial.println("Auto");
  257.     Serial.print  ("Timing:       "); Serial.println("13 ms");
  258.     Serial.println("------------------------------------");
  259.   }
  260. }
  261.  
  262. void getSensors() {
  263.   /* Get a new sensor event */
  264.   sensors_event_t event;
  265.   sensors_event_t event2;
  266.   tsl.getEvent(&event);
  267.   dht.temperature().getEvent(&event2);
  268.   sgp.IAQmeasure();
  269.  
  270.   /* Display the results (light is measured in lux) */
  271.   if (event.light)
  272.   {
  273.     if (debug) {
  274.       Serial.print(event.light); Serial.println(" lux");
  275.     }
  276.     light = event.light;
  277.   }
  278.   else
  279.   {
  280.     /* If event.light = 0 lux the sensor is probably saturated
  281.        and no reliable data could be generated! */
  282.     if (debug) {
  283.       Serial.println("Sensor overload");
  284.     }
  285.   }
  286.   float pressurehPA = 0, temperatureC = 0;
  287.  
  288.   pressurehPA = 10 * mpl115a2.getPressure();
  289.   if (debug) {
  290.     Serial.print("Pressure (hPa): "); Serial.print(pressurehPA, 4); Serial.println(" hPa");
  291.   }
  292.   pressure = pressurehPA;
  293.  
  294.   //temperatureC = mpl115a2.getTemperature();
  295.   //Serial.print("Temp (*C): "); Serial.print(temperatureC, 1); Serial.println(" *C");
  296.  
  297.   if (isnan(event2.temperature)) {
  298.     if (debug) {
  299.       Serial.println("Error reading temperature!");
  300.     }
  301.   }
  302.   else {
  303.     if (debug) {
  304.       Serial.print("Temperature: ");
  305.       Serial.print(event2.temperature);
  306.       Serial.println(" *C");
  307.     }
  308.     temperature = event2.temperature;
  309.   }
  310.   // Get humidity event and print its value.
  311.   dht.humidity().getEvent(&event2);
  312.   if (isnan(event2.relative_humidity)) {
  313.     if (debug) {
  314.       Serial.println("Error reading humidity!");
  315.     }
  316.   }
  317.   else {
  318.     if (debug) {
  319.       Serial.print("Humidity: ");
  320.       Serial.print(event2.relative_humidity);
  321.       Serial.println("%");
  322.     }
  323.     humidity = event2.relative_humidity;
  324.   }
  325.  
  326.   PPM = sgp.eCO2;
  327. }
  328.  
  329. void request(String requestHeader) {
  330.   while ( status != WL_CONNECTED) {
  331.     if (debug) {
  332.       Serial.print("Attempting to connect to WPA SSID: ");
  333.       Serial.println(ssid);
  334.     }
  335.     // Connect to WPA/WPA2 network
  336.     status = WiFi.begin(ssid, pass);
  337.   }
  338.   int forecast = sample(pressure);
  339.   String pressureRequest = String("GET /json.htm?type=command&param=udevice&idx=215&nvalue=0&svalue=");
  340.   pressureRequest = pressureRequest +  String(pressure);
  341.   pressureRequest = pressureRequest +  String(";");
  342.   pressureRequest = pressureRequest +  forecast;
  343.   pressureRequest = pressureRequest +  String(" HTTP/1.1");
  344.   if (debug) {
  345.     Serial.println(pressureRequest);
  346.   }
  347.   String luxRequest = String("GET /json.htm?type=command&param=udevice&idx=214&svalue=");
  348.   luxRequest = luxRequest +  String(light);
  349.   luxRequest = luxRequest +  String(" HTTP/1.1");
  350.  
  351.   String temperatureRequest = String("GET /json.htm?type=command&param=udevice&idx=219&nvalue=0&svalue=");
  352.   temperatureRequest = temperatureRequest +  String(temperature);
  353.   temperatureRequest = temperatureRequest +  String(" HTTP/1.1");
  354.  
  355.   String humidityRequest = String("GET /json.htm?type=command&param=udevice&idx=217&nvalue=");
  356.   humidityRequest = humidityRequest +  String(humidity);
  357.   humidityRequest = humidityRequest +  String("&svalue=");
  358.   humidityRequest = humidityRequest +  String(humidityState);
  359.   humidityRequest = humidityRequest +  String(" HTTP/1.1");
  360.  
  361.   String ppmRequest = String("GET /json.htm?type=command&param=udevice&idx=222&nvalue=");
  362.   ppmRequest = ppmRequest +  String(PPM);
  363.   ppmRequest = ppmRequest +  String(" HTTP/1.1");
  364.  
  365.   if (debug) {
  366.     Serial.println("Starting connection to server...");
  367.   }
  368.   // if you get a connection, report back via serial
  369.   if (client.connect(server, 8080)) {
  370.     if (debug) {
  371.       Serial.println("Connected to server");
  372.     }
  373.     // Make a HTTP request
  374.     client.println(pressureRequest);
  375.     client.println("Host: 192.168.1.227");
  376.     client.println("Connection: close");
  377.     client.println();
  378.   }
  379.   if (!client.connected()) {
  380.     if (debug) {
  381.       Serial.println();
  382.       Serial.println("Disconnecting from server...");
  383.     }
  384.     client.flush();
  385.     client.stop();
  386.     //status = WiFi.disconnect();
  387.  
  388.     // do nothing forevermore
  389.     //while (true);
  390.   }
  391.  
  392.   if (client.connect(server, 8080)) {
  393.     if (debug) {
  394.       Serial.println("Connected to server");
  395.     }
  396.     // Make a HTTP request
  397.     client.println(luxRequest);
  398.     client.println("Host: 192.168.1.227");
  399.     client.println("Connection: close");
  400.     client.println();
  401.   }
  402.   if (!client.connected()) {
  403.     if (debug) {
  404.       Serial.println();
  405.       Serial.println("Disconnecting from server...");
  406.     }
  407.     client.flush();
  408.     client.stop();
  409.     //status = WiFi.disconnect();
  410.  
  411.     // do nothing forevermore
  412.     //while (true);
  413.   }
  414.  
  415.   if (client.connect(server, 8080)) {
  416.     if (debug) {
  417.       Serial.println("Connected to server");
  418.     }
  419.     // Make a HTTP request
  420.     client.println(temperatureRequest);
  421.     client.println("Host: 192.168.1.227");
  422.     client.println("Connection: close");
  423.     client.println();
  424.   }
  425.   if (!client.connected()) {
  426.     if (debug) {
  427.       Serial.println();
  428.       Serial.println("Disconnecting from server...");
  429.     }
  430.     client.flush();
  431.     client.stop();
  432.     //status = WiFi.disconnect();
  433.  
  434.     // do nothing forevermore
  435.     //while (true);
  436.   }
  437.   while (client.connected()) {
  438.     while (client.available()) {
  439.       char ch = client.read();
  440.       if (debug) {
  441.         Serial.write(ch);
  442.       }
  443.     }
  444.   }
  445.   if (client.connect(server, 8080)) {
  446.     if (debug) {
  447.       Serial.println("Connected to server");
  448.     }
  449.     // Make a HTTP request
  450.     client.println(humidityRequest);
  451.     client.println("Host: 192.168.1.227");
  452.     client.println("Connection: close");
  453.     client.println();
  454.   }
  455.  
  456.   while (client.connected()) {
  457.     while (client.available()) {
  458.       char ch = client.read();
  459.       if (debug) {
  460.         Serial.write(ch);
  461.       }
  462.     }
  463.   }
  464.  
  465.   if (!client.connected()) {
  466.     if (debug) {
  467.       Serial.println();
  468.       Serial.println("Disconnecting from server...");
  469.     }
  470.     client.flush();
  471.     client.stop();
  472.     //status = WiFi.disconnect();
  473.  
  474.     // do nothing forevermore
  475.     //while (true);
  476.   }
  477.  
  478.   if (client.connect(server, 8080)) {
  479.     if (debug) {
  480.       Serial.println("Connected to server");
  481.     }
  482.     // Make a HTTP request
  483.     client.println(ppmRequest);
  484.     client.println("Host: 192.168.1.227");
  485.     client.println("Connection: close");
  486.     client.println();
  487.   }
  488.  
  489.   if (!client.connected()) {
  490.     if (debug) {
  491.       Serial.println();
  492.       Serial.println("Disconnecting from server...");
  493.     }
  494.     client.flush();
  495.     client.stop();
  496.     status = WiFi.disconnect();
  497.  
  498.     // do nothing forevermore
  499.     //while (true);
  500.   }
  501.   while (client.connected()) {
  502.     while (client.available()) {
  503.       char ch = client.read();
  504.       if (debug) {
  505.         Serial.write(ch);
  506.       }
  507.     }
  508.   }
  509. }
  510.  
  511. float getLastPressureSamplesAverage()
  512. {
  513.   float lastPressureSamplesAverage = 0;
  514.   for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
  515.   {
  516.     lastPressureSamplesAverage += lastPressureSamples[i];
  517.   }
  518.   lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;
  519.  
  520.   return lastPressureSamplesAverage;
  521. }
  522.  
  523. // Pressure in hPa -->  forecast done by calculating kPa/h
  524. int sample(float pressure)
  525. {
  526.   // Calculate the average of the last n minutes.
  527.   int index = minuteCount % LAST_SAMPLES_COUNT;
  528.   lastPressureSamples[index] = pressure;
  529.  
  530.   minuteCount++;
  531.   if (minuteCount > 185)
  532.   {
  533.     minuteCount = 6;
  534.   }
  535.  
  536.   if (minuteCount == 5)
  537.   {
  538.     pressureAvg = getLastPressureSamplesAverage();
  539.   }
  540.   else if (minuteCount == 35)
  541.   {
  542.     float lastPressureAvg = getLastPressureSamplesAverage();
  543.     float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
  544.     if (firstRound) // first time initial 3 hour
  545.     {
  546.       dP_dt = change * 2; // note this is for t = 0.5hour
  547.     }
  548.     else
  549.     {
  550.       dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
  551.     }
  552.   }
  553.   else if (minuteCount == 65)
  554.   {
  555.     float lastPressureAvg = getLastPressureSamplesAverage();
  556.     float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
  557.     if (firstRound) //first time initial 3 hour
  558.     {
  559.       dP_dt = change; //note this is for t = 1 hour
  560.     }
  561.     else
  562.     {
  563.       dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
  564.     }
  565.   }
  566.   else if (minuteCount == 95)
  567.   {
  568.     float lastPressureAvg = getLastPressureSamplesAverage();
  569.     float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
  570.     if (firstRound) // first time initial 3 hour
  571.     {
  572.       dP_dt = change / 1.5; // note this is for t = 1.5 hour
  573.     }
  574.     else
  575.     {
  576.       dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
  577.     }
  578.   }
  579.   else if (minuteCount == 125)
  580.   {
  581.     float lastPressureAvg = getLastPressureSamplesAverage();
  582.     pressureAvg2 = lastPressureAvg; // store for later use.
  583.     float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
  584.     if (firstRound) // first time initial 3 hour
  585.     {
  586.       dP_dt = change / 2; // note this is for t = 2 hour
  587.     }
  588.     else
  589.     {
  590.       dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
  591.     }
  592.   }
  593.   else if (minuteCount == 155)
  594.   {
  595.     float lastPressureAvg = getLastPressureSamplesAverage();
  596.     float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
  597.     if (firstRound) // first time initial 3 hour
  598.     {
  599.       dP_dt = change / 2.5; // note this is for t = 2.5 hour
  600.     }
  601.     else
  602.     {
  603.       dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
  604.     }
  605.   }
  606.   else if (minuteCount == 185)
  607.   {
  608.     float lastPressureAvg = getLastPressureSamplesAverage();
  609.     float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
  610.     if (firstRound) // first time initial 3 hour
  611.     {
  612.       dP_dt = change / 3; // note this is for t = 3 hour
  613.     }
  614.     else
  615.     {
  616.       dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
  617.     }
  618.     pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
  619.     firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
  620.   }
  621.  
  622.   int forecast = UNKNOWN;
  623.   if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
  624.   {
  625.     forecast = UNKNOWN;
  626.   }
  627.   else if (dP_dt < (-0.25))
  628.   {
  629.     forecast = THUNDERSTORM;
  630.   }
  631.   else if (dP_dt > 0.25)
  632.   {
  633.     forecast = UNSTABLE;
  634.   }
  635.   else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
  636.   {
  637.     forecast = CLOUDY;
  638.   }
  639.   else if ((dP_dt > 0.05) && (dP_dt < 0.25))
  640.   {
  641.     forecast = SUNNY;
  642.   }
  643.   else if ((dP_dt > (-0.05)) && (dP_dt < 0.05))
  644.   {
  645.     forecast = STABLE;
  646.   }
  647.   else
  648.   {
  649.     forecast = UNKNOWN;
  650.   }
  651.  
  652.   if (debug) {
  653.     Serial.print(F("Forecast at minute "));
  654.     Serial.print(minuteCount);
  655.     Serial.print(F(" dP/dt = "));
  656.     Serial.print(dP_dt);
  657.     Serial.print(F("kPa/h --> "));
  658.     Serial.println(weather[forecast]);
  659.   }
  660.  
  661.   return forecast;
  662. }
Advertisement
Add Comment
Please, Sign In to add comment