Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Bug Reports
  3. Possible Bug version 2.2.0

Possible Bug version 2.2.0

Scheduled Pinned Locked Moved Bug Reports
38 Posts 4 Posters 3.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sindrome73
    wrote on last edited by
    #1

    Good morning, for one of my Weather Station (very early stage) I used the code below. Which works perfectly with MySensors 2.1.1
    Yesterday I updated my Arduino IDE to Version 2.2.0 and when I try to compile the code it goes, but once loaded the scketch on my arduino Pro, it does not work, while reloading the code compiled with MySensors 2.1.1 It works !!

    I think there is something wrong with the latest version of Mysensors

    // ---- - Stazione Meteo Francy Ver 1 - ----
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached 
    #define MY_RADIO_NRF24
    
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC
    
    
    #define   MY_RF24_CHANNEL 84
    
    
    #define MY_SIGNING_SOFT
    #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
    #define MY_SIGNING_REQUEST_SIGNATURES
    
    
    
    // Definisco il Nodo
    #define MY_NODE_ID 66
    
    // Nomino i figli del Nodo
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_aaaa 2
    #define CHILD_ID_HUMI 3
    #define CHILD_ID_bbbb 4
    #define CHILD_ID_BARO 5
    #define CHILD_ID_LIGHT 6
    
    
    #define LIGHT_SENSOR_ANALOG_PIN 0
    
    const float ALTITUDE = 335;
    //----------------------------- Pressione
    //float pressione = 1017;
    //int forecast = 4;
    const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
    enum FORECAST
    {
        STABLE = 0,            // "Stable Weather Pattern"
        SUNNY = 1,            // "Slowly rising Good Weather", "Clear/Sunny "
        CLOUDY = 2,            // "Slowly falling L-Pressure ", "Cloudy/Rain "
        UNSTABLE = 3,        // "Quickly rising H-Press",     "Not Stable"
        THUNDERSTORM = 4,    // "Quickly falling L-Press",    "Thunderstorm"
        UNKNOWN = 5            // "Unknown (More Time needed)
    };
    //-----------------------------------------
    
    
    
    
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>
    #include <Wire.h>
    #include <Adafruit_BMP085.h>
    DHT dht;
    
    //-----------------------------
    Adafruit_BMP085 bmp = Adafruit_BMP085();      // Digital Pressure Sensor 
    
    float lastPressure = -1;
    float lastTemp = -1;
    int lastForecast = -1;
    
    const int LAST_SAMPLES_COUNT = 5;
    float lastPressureSamples[LAST_SAMPLES_COUNT];
    
    // this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
    // get kPa/h be dividing hPa by 10 
    #define CONVERSION_FACTOR (1.0/10.0)
    
    int minuteCount = 0;
    bool firstRound = true;
    // average value is used in forecast algorithm.
    float pressureAvg;
    // average after 2 hours is used as reference value for the next iteration.
    float pressureAvg2;
    
    float dP_dt;
    bool metric;
    //-----------------------------
    
    //Dichiarazioni per pause dei diversi blocchi
    unsigned long int time;
    unsigned long int lettura_Press;
    unsigned long int lettura_Temp;
    
    unsigned long int letturaluce_time;
    //------------------------------
    
    int lastLightLevel; //Dichiarazione Luminosita
    
    float temperatureDTH2;
    
    
    void presentation()  
     { 
      sendSketchInfo("Temp e Umidita", "3");
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_aaaa, S_LIGHT);
      present(CHILD_ID_HUMI, S_HUM);
      present(CHILD_ID_bbbb, S_LIGHT);
      present(CHILD_ID_BARO, S_BARO);
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
      }
      
    
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgaaaa(CHILD_ID_HUMI, V_LIGHT);
    MyMessage msgHumi(CHILD_ID_HUMI, V_HUM);
    MyMessage msgbbbb(CHILD_ID_HUMI, V_LIGHT);
    MyMessage msgPres(CHILD_ID_BARO, V_PRESSURE);
    MyMessage msgForecast(CHILD_ID_BARO, V_FORECAST);
    MyMessage msg4(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    
    
    
    void setup()
    {
      // Setto il Pin dove e collegato il sensore di Temperatura DHT22
      dht.setup(3);
    
      //Settaggi del BMP180
          if (!bmp.begin()) 
        {
            Serial.println("Could not find a valid BMP085 sensor, check wiring!");
            while (1) {}
        }
        metric = getControllerConfig().isMetric;
      //Fine settaggi BMP180 
    
    //-- Setup Variabili MILLIS per sensore di Pressione
    time=millis();
    lettura_Press = millis();
    lettura_Temp = millis();
    letturaluce_time = millis();
      }
    
    
    void loop()
    {
    //Attivo Time MILLIS       
    time=millis();
      
    //----------- Inizio DHT22 ------------------------
    if(time>lettura_Temp+12000){
    delay(dht.getMinimumSamplingPeriod());
    
    Serial.println("--- Temperatura ---  ");
    
    float temperatureDTH;
    
    float humidity = dht.getHumidity();
    float temperatureDHT = dht.getTemperature();
    
    temperatureDTH2 = temperatureDTH;
    
     //Invio la lettura della Temperatura
      send(msgTemp.set(temperatureDHT, 1));
      //delay(6000); // Faccio una pausa ed invio altra lettura
     //Invio lettura Umidita
      send(msgHumi.set(humidity, 1));
      //delay(4000);
      
    lettura_Temp=millis();
    }
    
    //---------- Inizio Pressione ---------------------------
    if(time>lettura_Press+11000){
    Serial.println("--- Tempo passato lego la Pressione---  ");
    
    float temperatureDHT2;
    
    float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
    float temperature = temperatureDHT2;
    
    if (!metric) 
        {
            // Convert to fahrenheit
            temperature = temperature * 9.0 / 5.0 + 32.0;
        }
        
    int forecast = sample(pressure);
        Serial.print("Pressione = ");
        Serial.print(pressure);
        Serial.println(" hPa");
        Serial.print("Forecast = ");
        Serial.println(weather[forecast]);
    
     if (pressure != lastPressure) 
        {
            send(msgPres.set(pressure, 0));
            lastPressure = pressure;
        }
    if (forecast != lastForecast)
        {
            send(msgForecast.set(weather[forecast]));
            lastForecast = forecast;
        }
      
    lettura_Press=millis();
    }
    
    //-------------- Inizio Luminosita --------------------------
    if(time>letturaluce_time+10000){
    Serial.print("Tempo passato lego la Luce: ");
      
            int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
        Serial.println(lightLevel);
        //delay(1000); 
        
        if (lightLevel != lastLightLevel) {
           if(lightLevel > lastLightLevel + 7 || lightLevel < lastLightLevel - 7){
            send(msg4.set(lightLevel));
            Serial.print("Invio nuova lettura LUX: ");
            Serial.println(lightLevel);
            lastLightLevel = lightLevel;
           }
        }
    letturaluce_time=millis();    
    }    
        //Fine Luminosita
    
      
    //--------- Eventuale 4 Modulo -------------------------
    
    // Chiusura Loop
    }
    
    
    
    
    
    
    //------------ Aggiuntivo Previsione del Barometro ---------------------
    
    float getLastPressureSamplesAverage()
    {
        float lastPressureSamplesAverage = 0;
        for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
        {
            lastPressureSamplesAverage += lastPressureSamples[i];
        }
        lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;
    
        return lastPressureSamplesAverage;
    }
    
    
    // Algorithm found here
    // http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
    // Pressure in hPa -->  forecast done by calculating kPa/h
    int sample(float pressure)
    {
      
        // Calculate the average of the last n minutes.
        int index = minuteCount % LAST_SAMPLES_COUNT;
        lastPressureSamples[index] = pressure;
    
        minuteCount++;
        if (minuteCount > 185)
        {
            minuteCount = 6;
        }
    
        if (minuteCount == 5)
        {
            pressureAvg = getLastPressureSamplesAverage();
        }
        else if (minuteCount == 35)
        {
            float lastPressureAvg = getLastPressureSamplesAverage();
            float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
            if (firstRound) // first time initial 3 hour
            {
                dP_dt = change * 2; // note this is for t = 0.5hour
            }
            else
            {
                dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
            }
        }
        else if (minuteCount == 65)
        {
            float lastPressureAvg = getLastPressureSamplesAverage();
            float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
            if (firstRound) //first time initial 3 hour
            {
                dP_dt = change; //note this is for t = 1 hour
            }
            else
            {
                dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
            }
        }
        else if (minuteCount == 95)
        {
            float lastPressureAvg = getLastPressureSamplesAverage();
            float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
            if (firstRound) // first time initial 3 hour
            {
                dP_dt = change / 1.5; // note this is for t = 1.5 hour
            }
            else
            {
                dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
            }
        }
        else if (minuteCount == 125)
        {
            float lastPressureAvg = getLastPressureSamplesAverage();
            pressureAvg2 = lastPressureAvg; // store for later use.
            float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
            if (firstRound) // first time initial 3 hour
            {
                dP_dt = change / 2; // note this is for t = 2 hour
            }
            else
            {
                dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
            }
        }
        else if (minuteCount == 155)
        {
            float lastPressureAvg = getLastPressureSamplesAverage();
            float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
            if (firstRound) // first time initial 3 hour
            {
                dP_dt = change / 2.5; // note this is for t = 2.5 hour
            }
            else
            {
                dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
            }
        }
        else if (minuteCount == 185)
        {
            float lastPressureAvg = getLastPressureSamplesAverage();
            float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
            if (firstRound) // first time initial 3 hour
            {
                dP_dt = change / 3; // note this is for t = 3 hour
            }
            else
            {
                dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
            }
            pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
            firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
        }
    
        int forecast = UNKNOWN;
        if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
        {
            forecast = UNKNOWN;
        }
        else if (dP_dt < (-0.25))
        {
            forecast = THUNDERSTORM;
        }
        else if (dP_dt > 0.25)
        {
            forecast = UNSTABLE;
        }
        else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
        {
            forecast = CLOUDY;
        }
        else if ((dP_dt > 0.05) && (dP_dt < 0.25))
        {
            forecast = SUNNY;
        }
        else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
        {
            forecast = STABLE;
        }
        else
        {
            forecast = UNKNOWN;
        }
    
        // uncomment when debugging
        Serial.print(F("Forecast at minute "));
        Serial.print(minuteCount);
        Serial.print(F(" dP/dt = "));
        Serial.print(dP_dt);
        Serial.print(F("kPa/h --> "));
        Serial.println(weather[forecast]);
    
        return forecast;
    }```
    alexsh1A AnticimexA 2 Replies Last reply
    0
    • S sindrome73

      Good morning, for one of my Weather Station (very early stage) I used the code below. Which works perfectly with MySensors 2.1.1
      Yesterday I updated my Arduino IDE to Version 2.2.0 and when I try to compile the code it goes, but once loaded the scketch on my arduino Pro, it does not work, while reloading the code compiled with MySensors 2.1.1 It works !!

      I think there is something wrong with the latest version of Mysensors

      // ---- - Stazione Meteo Francy Ver 1 - ----
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable and select radio type attached 
      #define MY_RADIO_NRF24
      
      #define MY_PARENT_NODE_ID 0
      #define MY_PARENT_NODE_IS_STATIC
      
      
      #define   MY_RF24_CHANNEL 84
      
      
      #define MY_SIGNING_SOFT
      #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
      #define MY_SIGNING_REQUEST_SIGNATURES
      
      
      
      // Definisco il Nodo
      #define MY_NODE_ID 66
      
      // Nomino i figli del Nodo
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_aaaa 2
      #define CHILD_ID_HUMI 3
      #define CHILD_ID_bbbb 4
      #define CHILD_ID_BARO 5
      #define CHILD_ID_LIGHT 6
      
      
      #define LIGHT_SENSOR_ANALOG_PIN 0
      
      const float ALTITUDE = 335;
      //----------------------------- Pressione
      //float pressione = 1017;
      //int forecast = 4;
      const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
      enum FORECAST
      {
          STABLE = 0,            // "Stable Weather Pattern"
          SUNNY = 1,            // "Slowly rising Good Weather", "Clear/Sunny "
          CLOUDY = 2,            // "Slowly falling L-Pressure ", "Cloudy/Rain "
          UNSTABLE = 3,        // "Quickly rising H-Press",     "Not Stable"
          THUNDERSTORM = 4,    // "Quickly falling L-Press",    "Thunderstorm"
          UNKNOWN = 5            // "Unknown (More Time needed)
      };
      //-----------------------------------------
      
      
      
      
      
      #include <SPI.h>
      #include <MySensors.h>  
      #include <DHT.h>
      #include <Wire.h>
      #include <Adafruit_BMP085.h>
      DHT dht;
      
      //-----------------------------
      Adafruit_BMP085 bmp = Adafruit_BMP085();      // Digital Pressure Sensor 
      
      float lastPressure = -1;
      float lastTemp = -1;
      int lastForecast = -1;
      
      const int LAST_SAMPLES_COUNT = 5;
      float lastPressureSamples[LAST_SAMPLES_COUNT];
      
      // this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
      // get kPa/h be dividing hPa by 10 
      #define CONVERSION_FACTOR (1.0/10.0)
      
      int minuteCount = 0;
      bool firstRound = true;
      // average value is used in forecast algorithm.
      float pressureAvg;
      // average after 2 hours is used as reference value for the next iteration.
      float pressureAvg2;
      
      float dP_dt;
      bool metric;
      //-----------------------------
      
      //Dichiarazioni per pause dei diversi blocchi
      unsigned long int time;
      unsigned long int lettura_Press;
      unsigned long int lettura_Temp;
      
      unsigned long int letturaluce_time;
      //------------------------------
      
      int lastLightLevel; //Dichiarazione Luminosita
      
      float temperatureDTH2;
      
      
      void presentation()  
       { 
        sendSketchInfo("Temp e Umidita", "3");
        present(CHILD_ID_TEMP, S_TEMP);
        present(CHILD_ID_aaaa, S_LIGHT);
        present(CHILD_ID_HUMI, S_HUM);
        present(CHILD_ID_bbbb, S_LIGHT);
        present(CHILD_ID_BARO, S_BARO);
        present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
        }
        
      
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgaaaa(CHILD_ID_HUMI, V_LIGHT);
      MyMessage msgHumi(CHILD_ID_HUMI, V_HUM);
      MyMessage msgbbbb(CHILD_ID_HUMI, V_LIGHT);
      MyMessage msgPres(CHILD_ID_BARO, V_PRESSURE);
      MyMessage msgForecast(CHILD_ID_BARO, V_FORECAST);
      MyMessage msg4(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
      
      
      
      void setup()
      {
        // Setto il Pin dove e collegato il sensore di Temperatura DHT22
        dht.setup(3);
      
        //Settaggi del BMP180
            if (!bmp.begin()) 
          {
              Serial.println("Could not find a valid BMP085 sensor, check wiring!");
              while (1) {}
          }
          metric = getControllerConfig().isMetric;
        //Fine settaggi BMP180 
      
      //-- Setup Variabili MILLIS per sensore di Pressione
      time=millis();
      lettura_Press = millis();
      lettura_Temp = millis();
      letturaluce_time = millis();
        }
      
      
      void loop()
      {
      //Attivo Time MILLIS       
      time=millis();
        
      //----------- Inizio DHT22 ------------------------
      if(time>lettura_Temp+12000){
      delay(dht.getMinimumSamplingPeriod());
      
      Serial.println("--- Temperatura ---  ");
      
      float temperatureDTH;
      
      float humidity = dht.getHumidity();
      float temperatureDHT = dht.getTemperature();
      
      temperatureDTH2 = temperatureDTH;
      
       //Invio la lettura della Temperatura
        send(msgTemp.set(temperatureDHT, 1));
        //delay(6000); // Faccio una pausa ed invio altra lettura
       //Invio lettura Umidita
        send(msgHumi.set(humidity, 1));
        //delay(4000);
        
      lettura_Temp=millis();
      }
      
      //---------- Inizio Pressione ---------------------------
      if(time>lettura_Press+11000){
      Serial.println("--- Tempo passato lego la Pressione---  ");
      
      float temperatureDHT2;
      
      float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
      float temperature = temperatureDHT2;
      
      if (!metric) 
          {
              // Convert to fahrenheit
              temperature = temperature * 9.0 / 5.0 + 32.0;
          }
          
      int forecast = sample(pressure);
          Serial.print("Pressione = ");
          Serial.print(pressure);
          Serial.println(" hPa");
          Serial.print("Forecast = ");
          Serial.println(weather[forecast]);
      
       if (pressure != lastPressure) 
          {
              send(msgPres.set(pressure, 0));
              lastPressure = pressure;
          }
      if (forecast != lastForecast)
          {
              send(msgForecast.set(weather[forecast]));
              lastForecast = forecast;
          }
        
      lettura_Press=millis();
      }
      
      //-------------- Inizio Luminosita --------------------------
      if(time>letturaluce_time+10000){
      Serial.print("Tempo passato lego la Luce: ");
        
              int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
          Serial.println(lightLevel);
          //delay(1000); 
          
          if (lightLevel != lastLightLevel) {
             if(lightLevel > lastLightLevel + 7 || lightLevel < lastLightLevel - 7){
              send(msg4.set(lightLevel));
              Serial.print("Invio nuova lettura LUX: ");
              Serial.println(lightLevel);
              lastLightLevel = lightLevel;
             }
          }
      letturaluce_time=millis();    
      }    
          //Fine Luminosita
      
        
      //--------- Eventuale 4 Modulo -------------------------
      
      // Chiusura Loop
      }
      
      
      
      
      
      
      //------------ Aggiuntivo Previsione del Barometro ---------------------
      
      float getLastPressureSamplesAverage()
      {
          float lastPressureSamplesAverage = 0;
          for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
          {
              lastPressureSamplesAverage += lastPressureSamples[i];
          }
          lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;
      
          return lastPressureSamplesAverage;
      }
      
      
      // Algorithm found here
      // http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
      // Pressure in hPa -->  forecast done by calculating kPa/h
      int sample(float pressure)
      {
        
          // Calculate the average of the last n minutes.
          int index = minuteCount % LAST_SAMPLES_COUNT;
          lastPressureSamples[index] = pressure;
      
          minuteCount++;
          if (minuteCount > 185)
          {
              minuteCount = 6;
          }
      
          if (minuteCount == 5)
          {
              pressureAvg = getLastPressureSamplesAverage();
          }
          else if (minuteCount == 35)
          {
              float lastPressureAvg = getLastPressureSamplesAverage();
              float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
              if (firstRound) // first time initial 3 hour
              {
                  dP_dt = change * 2; // note this is for t = 0.5hour
              }
              else
              {
                  dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
              }
          }
          else if (minuteCount == 65)
          {
              float lastPressureAvg = getLastPressureSamplesAverage();
              float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
              if (firstRound) //first time initial 3 hour
              {
                  dP_dt = change; //note this is for t = 1 hour
              }
              else
              {
                  dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
              }
          }
          else if (minuteCount == 95)
          {
              float lastPressureAvg = getLastPressureSamplesAverage();
              float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
              if (firstRound) // first time initial 3 hour
              {
                  dP_dt = change / 1.5; // note this is for t = 1.5 hour
              }
              else
              {
                  dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
              }
          }
          else if (minuteCount == 125)
          {
              float lastPressureAvg = getLastPressureSamplesAverage();
              pressureAvg2 = lastPressureAvg; // store for later use.
              float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
              if (firstRound) // first time initial 3 hour
              {
                  dP_dt = change / 2; // note this is for t = 2 hour
              }
              else
              {
                  dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
              }
          }
          else if (minuteCount == 155)
          {
              float lastPressureAvg = getLastPressureSamplesAverage();
              float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
              if (firstRound) // first time initial 3 hour
              {
                  dP_dt = change / 2.5; // note this is for t = 2.5 hour
              }
              else
              {
                  dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
              }
          }
          else if (minuteCount == 185)
          {
              float lastPressureAvg = getLastPressureSamplesAverage();
              float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
              if (firstRound) // first time initial 3 hour
              {
                  dP_dt = change / 3; // note this is for t = 3 hour
              }
              else
              {
                  dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
              }
              pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
              firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
          }
      
          int forecast = UNKNOWN;
          if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
          {
              forecast = UNKNOWN;
          }
          else if (dP_dt < (-0.25))
          {
              forecast = THUNDERSTORM;
          }
          else if (dP_dt > 0.25)
          {
              forecast = UNSTABLE;
          }
          else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
          {
              forecast = CLOUDY;
          }
          else if ((dP_dt > 0.05) && (dP_dt < 0.25))
          {
              forecast = SUNNY;
          }
          else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
          {
              forecast = STABLE;
          }
          else
          {
              forecast = UNKNOWN;
          }
      
          // uncomment when debugging
          Serial.print(F("Forecast at minute "));
          Serial.print(minuteCount);
          Serial.print(F(" dP/dt = "));
          Serial.print(dP_dt);
          Serial.print(F("kPa/h --> "));
          Serial.println(weather[forecast]);
      
          return forecast;
      }```
      alexsh1A Offline
      alexsh1A Offline
      alexsh1
      wrote on last edited by
      #2

      @sindrome73 it does not work is a large statement. Did you try different Arduino? Logs?

      1 Reply Last reply
      0
      • S sindrome73

        Good morning, for one of my Weather Station (very early stage) I used the code below. Which works perfectly with MySensors 2.1.1
        Yesterday I updated my Arduino IDE to Version 2.2.0 and when I try to compile the code it goes, but once loaded the scketch on my arduino Pro, it does not work, while reloading the code compiled with MySensors 2.1.1 It works !!

        I think there is something wrong with the latest version of Mysensors

        // ---- - Stazione Meteo Francy Ver 1 - ----
        
        // Enable debug prints
        #define MY_DEBUG
        
        // Enable and select radio type attached 
        #define MY_RADIO_NRF24
        
        #define MY_PARENT_NODE_ID 0
        #define MY_PARENT_NODE_IS_STATIC
        
        
        #define   MY_RF24_CHANNEL 84
        
        
        #define MY_SIGNING_SOFT
        #define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
        #define MY_SIGNING_REQUEST_SIGNATURES
        
        
        
        // Definisco il Nodo
        #define MY_NODE_ID 66
        
        // Nomino i figli del Nodo
        #define CHILD_ID_TEMP 1
        #define CHILD_ID_aaaa 2
        #define CHILD_ID_HUMI 3
        #define CHILD_ID_bbbb 4
        #define CHILD_ID_BARO 5
        #define CHILD_ID_LIGHT 6
        
        
        #define LIGHT_SENSOR_ANALOG_PIN 0
        
        const float ALTITUDE = 335;
        //----------------------------- Pressione
        //float pressione = 1017;
        //int forecast = 4;
        const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
        enum FORECAST
        {
            STABLE = 0,            // "Stable Weather Pattern"
            SUNNY = 1,            // "Slowly rising Good Weather", "Clear/Sunny "
            CLOUDY = 2,            // "Slowly falling L-Pressure ", "Cloudy/Rain "
            UNSTABLE = 3,        // "Quickly rising H-Press",     "Not Stable"
            THUNDERSTORM = 4,    // "Quickly falling L-Press",    "Thunderstorm"
            UNKNOWN = 5            // "Unknown (More Time needed)
        };
        //-----------------------------------------
        
        
        
        
        
        #include <SPI.h>
        #include <MySensors.h>  
        #include <DHT.h>
        #include <Wire.h>
        #include <Adafruit_BMP085.h>
        DHT dht;
        
        //-----------------------------
        Adafruit_BMP085 bmp = Adafruit_BMP085();      // Digital Pressure Sensor 
        
        float lastPressure = -1;
        float lastTemp = -1;
        int lastForecast = -1;
        
        const int LAST_SAMPLES_COUNT = 5;
        float lastPressureSamples[LAST_SAMPLES_COUNT];
        
        // this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
        // get kPa/h be dividing hPa by 10 
        #define CONVERSION_FACTOR (1.0/10.0)
        
        int minuteCount = 0;
        bool firstRound = true;
        // average value is used in forecast algorithm.
        float pressureAvg;
        // average after 2 hours is used as reference value for the next iteration.
        float pressureAvg2;
        
        float dP_dt;
        bool metric;
        //-----------------------------
        
        //Dichiarazioni per pause dei diversi blocchi
        unsigned long int time;
        unsigned long int lettura_Press;
        unsigned long int lettura_Temp;
        
        unsigned long int letturaluce_time;
        //------------------------------
        
        int lastLightLevel; //Dichiarazione Luminosita
        
        float temperatureDTH2;
        
        
        void presentation()  
         { 
          sendSketchInfo("Temp e Umidita", "3");
          present(CHILD_ID_TEMP, S_TEMP);
          present(CHILD_ID_aaaa, S_LIGHT);
          present(CHILD_ID_HUMI, S_HUM);
          present(CHILD_ID_bbbb, S_LIGHT);
          present(CHILD_ID_BARO, S_BARO);
          present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
          }
          
        
        MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
        MyMessage msgaaaa(CHILD_ID_HUMI, V_LIGHT);
        MyMessage msgHumi(CHILD_ID_HUMI, V_HUM);
        MyMessage msgbbbb(CHILD_ID_HUMI, V_LIGHT);
        MyMessage msgPres(CHILD_ID_BARO, V_PRESSURE);
        MyMessage msgForecast(CHILD_ID_BARO, V_FORECAST);
        MyMessage msg4(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
        
        
        
        void setup()
        {
          // Setto il Pin dove e collegato il sensore di Temperatura DHT22
          dht.setup(3);
        
          //Settaggi del BMP180
              if (!bmp.begin()) 
            {
                Serial.println("Could not find a valid BMP085 sensor, check wiring!");
                while (1) {}
            }
            metric = getControllerConfig().isMetric;
          //Fine settaggi BMP180 
        
        //-- Setup Variabili MILLIS per sensore di Pressione
        time=millis();
        lettura_Press = millis();
        lettura_Temp = millis();
        letturaluce_time = millis();
          }
        
        
        void loop()
        {
        //Attivo Time MILLIS       
        time=millis();
          
        //----------- Inizio DHT22 ------------------------
        if(time>lettura_Temp+12000){
        delay(dht.getMinimumSamplingPeriod());
        
        Serial.println("--- Temperatura ---  ");
        
        float temperatureDTH;
        
        float humidity = dht.getHumidity();
        float temperatureDHT = dht.getTemperature();
        
        temperatureDTH2 = temperatureDTH;
        
         //Invio la lettura della Temperatura
          send(msgTemp.set(temperatureDHT, 1));
          //delay(6000); // Faccio una pausa ed invio altra lettura
         //Invio lettura Umidita
          send(msgHumi.set(humidity, 1));
          //delay(4000);
          
        lettura_Temp=millis();
        }
        
        //---------- Inizio Pressione ---------------------------
        if(time>lettura_Press+11000){
        Serial.println("--- Tempo passato lego la Pressione---  ");
        
        float temperatureDHT2;
        
        float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
        float temperature = temperatureDHT2;
        
        if (!metric) 
            {
                // Convert to fahrenheit
                temperature = temperature * 9.0 / 5.0 + 32.0;
            }
            
        int forecast = sample(pressure);
            Serial.print("Pressione = ");
            Serial.print(pressure);
            Serial.println(" hPa");
            Serial.print("Forecast = ");
            Serial.println(weather[forecast]);
        
         if (pressure != lastPressure) 
            {
                send(msgPres.set(pressure, 0));
                lastPressure = pressure;
            }
        if (forecast != lastForecast)
            {
                send(msgForecast.set(weather[forecast]));
                lastForecast = forecast;
            }
          
        lettura_Press=millis();
        }
        
        //-------------- Inizio Luminosita --------------------------
        if(time>letturaluce_time+10000){
        Serial.print("Tempo passato lego la Luce: ");
          
                int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
            Serial.println(lightLevel);
            //delay(1000); 
            
            if (lightLevel != lastLightLevel) {
               if(lightLevel > lastLightLevel + 7 || lightLevel < lastLightLevel - 7){
                send(msg4.set(lightLevel));
                Serial.print("Invio nuova lettura LUX: ");
                Serial.println(lightLevel);
                lastLightLevel = lightLevel;
               }
            }
        letturaluce_time=millis();    
        }    
            //Fine Luminosita
        
          
        //--------- Eventuale 4 Modulo -------------------------
        
        // Chiusura Loop
        }
        
        
        
        
        
        
        //------------ Aggiuntivo Previsione del Barometro ---------------------
        
        float getLastPressureSamplesAverage()
        {
            float lastPressureSamplesAverage = 0;
            for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
            {
                lastPressureSamplesAverage += lastPressureSamples[i];
            }
            lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;
        
            return lastPressureSamplesAverage;
        }
        
        
        // Algorithm found here
        // http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
        // Pressure in hPa -->  forecast done by calculating kPa/h
        int sample(float pressure)
        {
          
            // Calculate the average of the last n minutes.
            int index = minuteCount % LAST_SAMPLES_COUNT;
            lastPressureSamples[index] = pressure;
        
            minuteCount++;
            if (minuteCount > 185)
            {
                minuteCount = 6;
            }
        
            if (minuteCount == 5)
            {
                pressureAvg = getLastPressureSamplesAverage();
            }
            else if (minuteCount == 35)
            {
                float lastPressureAvg = getLastPressureSamplesAverage();
                float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
                if (firstRound) // first time initial 3 hour
                {
                    dP_dt = change * 2; // note this is for t = 0.5hour
                }
                else
                {
                    dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
                }
            }
            else if (minuteCount == 65)
            {
                float lastPressureAvg = getLastPressureSamplesAverage();
                float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
                if (firstRound) //first time initial 3 hour
                {
                    dP_dt = change; //note this is for t = 1 hour
                }
                else
                {
                    dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
                }
            }
            else if (minuteCount == 95)
            {
                float lastPressureAvg = getLastPressureSamplesAverage();
                float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
                if (firstRound) // first time initial 3 hour
                {
                    dP_dt = change / 1.5; // note this is for t = 1.5 hour
                }
                else
                {
                    dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
                }
            }
            else if (minuteCount == 125)
            {
                float lastPressureAvg = getLastPressureSamplesAverage();
                pressureAvg2 = lastPressureAvg; // store for later use.
                float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
                if (firstRound) // first time initial 3 hour
                {
                    dP_dt = change / 2; // note this is for t = 2 hour
                }
                else
                {
                    dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
                }
            }
            else if (minuteCount == 155)
            {
                float lastPressureAvg = getLastPressureSamplesAverage();
                float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
                if (firstRound) // first time initial 3 hour
                {
                    dP_dt = change / 2.5; // note this is for t = 2.5 hour
                }
                else
                {
                    dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
                }
            }
            else if (minuteCount == 185)
            {
                float lastPressureAvg = getLastPressureSamplesAverage();
                float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
                if (firstRound) // first time initial 3 hour
                {
                    dP_dt = change / 3; // note this is for t = 3 hour
                }
                else
                {
                    dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
                }
                pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
                firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
            }
        
            int forecast = UNKNOWN;
            if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
            {
                forecast = UNKNOWN;
            }
            else if (dP_dt < (-0.25))
            {
                forecast = THUNDERSTORM;
            }
            else if (dP_dt > 0.25)
            {
                forecast = UNSTABLE;
            }
            else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
            {
                forecast = CLOUDY;
            }
            else if ((dP_dt > 0.05) && (dP_dt < 0.25))
            {
                forecast = SUNNY;
            }
            else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
            {
                forecast = STABLE;
            }
            else
            {
                forecast = UNKNOWN;
            }
        
            // uncomment when debugging
            Serial.print(F("Forecast at minute "));
            Serial.print(minuteCount);
            Serial.print(F(" dP/dt = "));
            Serial.print(dP_dt);
            Serial.print(F("kPa/h --> "));
            Serial.println(weather[forecast]);
        
            return forecast;
        }```
        AnticimexA Offline
        AnticimexA Offline
        Anticimex
        Contest Winner
        wrote on last edited by
        #3

        @sindrome73 you use signing? Have you followed the signing migration guide for 2.1 to 2.2?
        https://forum.mysensors.org/topic/7843/security-migrating-from-library-version-2-1-to-2-2

        Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

        alexsh1A S 2 Replies Last reply
        0
        • AnticimexA Anticimex

          @sindrome73 you use signing? Have you followed the signing migration guide for 2.1 to 2.2?
          https://forum.mysensors.org/topic/7843/security-migrating-from-library-version-2-1-to-2-2

          alexsh1A Offline
          alexsh1A Offline
          alexsh1
          wrote on last edited by
          #4

          @anticimex Just out of curiosity - what happens if re-personalisation is not done after moving to 2.2.0? Signing fails?

          AnticimexA 1 Reply Last reply
          0
          • alexsh1A alexsh1

            @anticimex Just out of curiosity - what happens if re-personalisation is not done after moving to 2.2.0? Signing fails?

            AnticimexA Offline
            AnticimexA Offline
            Anticimex
            Contest Winner
            wrote on last edited by
            #5

            @alexsh1 checksum verification for the signing backend will fail and signing will not operate

            Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

            alexsh1A 1 Reply Last reply
            0
            • AnticimexA Anticimex

              @alexsh1 checksum verification for the signing backend will fail and signing will not operate

              alexsh1A Offline
              alexsh1A Offline
              alexsh1
              wrote on last edited by
              #6

              @anticimex OK, but if the GW is still on 2.1.1 and nodes are 2.2.0 it should be fine, right?

              AnticimexA 1 Reply Last reply
              0
              • alexsh1A alexsh1

                @anticimex OK, but if the GW is still on 2.1.1 and nodes are 2.2.0 it should be fine, right?

                AnticimexA Offline
                AnticimexA Offline
                Anticimex
                Contest Winner
                wrote on last edited by
                #7

                @alexsh1 if the 2.2 node has correct checksum yes. And this is shown in the debug log.

                Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                1 Reply Last reply
                0
                • AnticimexA Anticimex

                  @sindrome73 you use signing? Have you followed the signing migration guide for 2.1 to 2.2?
                  https://forum.mysensors.org/topic/7843/security-migrating-from-library-version-2-1-to-2-2

                  S Offline
                  S Offline
                  sindrome73
                  wrote on last edited by
                  #8

                  @anticimex

                  532/5000
                  I made the customization from the beginning, with MySensors 2.2.0

                  I followed these steps:

                  • The EEPROM has been deleted
                  • Open SecurityPersonalize.ino inserted the new Key
                  • loaded the scketch and it does not go

                  I redid the same procedure above, then EEprom deleted, SecurityPersonalize file, and loaded the scketch, but this time using Mysensors 2.1.1
                  And here it worked ..... The same thing I did on Several Pro Mini at 5V 16Mhz and the result is the same ..... That's why I assume there may be something wrong with 2.2.0

                  AnticimexA 1 Reply Last reply
                  0
                  • S sindrome73

                    @anticimex

                    532/5000
                    I made the customization from the beginning, with MySensors 2.2.0

                    I followed these steps:

                    • The EEPROM has been deleted
                    • Open SecurityPersonalize.ino inserted the new Key
                    • loaded the scketch and it does not go

                    I redid the same procedure above, then EEprom deleted, SecurityPersonalize file, and loaded the scketch, but this time using Mysensors 2.1.1
                    And here it worked ..... The same thing I did on Several Pro Mini at 5V 16Mhz and the result is the same ..... That's why I assume there may be something wrong with 2.2.0

                    AnticimexA Offline
                    AnticimexA Offline
                    Anticimex
                    Contest Winner
                    wrote on last edited by
                    #9

                    @sindrome73 2.2 works. At least signing. Log please.

                    Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      sindrome73
                      wrote on last edited by
                      #10

                      I apologize, but I did not understand what you tell me ....

                      I would like to add that the script without the signature with the 2.2 version works, while the signature works only with MySensors 2.1

                      AnticimexA 1 Reply Last reply
                      0
                      • S sindrome73

                        I apologize, but I did not understand what you tell me ....

                        I would like to add that the script without the signature with the 2.2 version works, while the signature works only with MySensors 2.1

                        AnticimexA Offline
                        AnticimexA Offline
                        Anticimex
                        Contest Winner
                        wrote on last edited by
                        #11

                        @sindrome73 log please.

                        Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          sindrome73
                          wrote on last edited by
                          #12

                          In the evening ..... Now I'm at work and I can not

                          AnticimexA 1 Reply Last reply
                          0
                          • S sindrome73

                            In the evening ..... Now I'm at work and I can not

                            AnticimexA Offline
                            AnticimexA Offline
                            Anticimex
                            Contest Winner
                            wrote on last edited by
                            #13

                            @sindrome73 no problem

                            Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              sindrome73
                              wrote on last edited by
                              #14

                              Here I am at home .... I proceeded to redo the procedure and this sot is the log ....

                              I had to put an image because the last signs that mida I can not copy them as text ....

                              0_1522266474450_Log_arduino.jpg

                              AnticimexA 2 Replies Last reply
                              0
                              • S sindrome73

                                Here I am at home .... I proceeded to redo the procedure and this sot is the log ....

                                I had to put an image because the last signs that mida I can not copy them as text ....

                                0_1522266474450_Log_arduino.jpg

                                AnticimexA Offline
                                AnticimexA Offline
                                Anticimex
                                Contest Winner
                                wrote on last edited by
                                #15

                                @sindrome73 log looks pretty corrupt, but I can't find any signing related messages so it would seem signing is not enabled on the node. Do you have a log from the GW? Is it also running 2.2.0?

                                Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                1 Reply Last reply
                                0
                                • S sindrome73

                                  Here I am at home .... I proceeded to redo the procedure and this sot is the log ....

                                  I had to put an image because the last signs that mida I can not copy them as text ....

                                  0_1522266474450_Log_arduino.jpg

                                  AnticimexA Offline
                                  AnticimexA Offline
                                  Anticimex
                                  Contest Winner
                                  wrote on last edited by
                                  #16

                                  @sindrome73 sorry, the capabilities string indicate software signing. But I don't see the backend initialization message. Could you please enable verbose signing debug?

                                  Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    sindrome73
                                    wrote on last edited by
                                    #17

                                    tell me how to abbilitate the detailed signature debug .....

                                    AnticimexA 1 Reply Last reply
                                    0
                                    • S sindrome73

                                      tell me how to abbilitate the detailed signature debug .....

                                      AnticimexA Offline
                                      AnticimexA Offline
                                      Anticimex
                                      Contest Winner
                                      wrote on last edited by
                                      #18

                                      @sindrome73 https://www.mysensors.org/apidocs-beta/group__MySigningTroubleshootinggrp.html

                                      Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        sindrome73
                                        wrote on last edited by
                                        #19

                                        Here is the log with the Debug signed abbreviation.
                                        I specify that I had to disable // # define MY_DEBUG because the scketch is too big

                                        0_1522270397919_Log_arduino2.jpg

                                        AnticimexA 2 Replies Last reply
                                        0
                                        • S sindrome73

                                          Here is the log with the Debug signed abbreviation.
                                          I specify that I had to disable // # define MY_DEBUG because the scketch is too big

                                          0_1522270397919_Log_arduino2.jpg

                                          AnticimexA Offline
                                          AnticimexA Offline
                                          Anticimex
                                          Contest Winner
                                          wrote on last edited by
                                          #20

                                          @sindrome73 signing messages look sane. But the logs look very corrupt. It also looks like the sketch crashed and restarted so I suspect you are running out of stack space. The arduino IDE reports and warns about memory usage and I suspect you get a warning on that.

                                          Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular