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. Troubleshooting
  3. RFM69 new driver delay

RFM69 new driver delay

Scheduled Pinned Locked Moved Troubleshooting
67 Posts 10 Posters 7.9k Views 8 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.
  • pepsonP pepson

    Finally
    In my opinion on MySensors 2.2.0 all my sketches (switch relay and cover ) works better. With no problem. NO PROBLEM.
    Cover works perfect and switch works perfect without any timeout and delay. ANd all node works without REPEATER.
    My opinion is that in version 2.3.0 something not working correct with radio RFM69HW.
    Maybe for sensors which send data from time to time is ok , but for cover which transfer data when cover is roll, it is problem... and gateway can not recived all data when node send position cover. Maybe developer read this thread and can do any changes to correct it.

    S Offline
    S Offline
    sineverba
    Hardware Contributor
    wrote on last edited by
    #56

    @pepson said in RFM69 new driver delay:

    Finally
    In my opinion on MySensors 2.2.0 all my sketches (switch relay and cover ) works better. With no problem. NO PROBLEM.
    Cover works perfect and switch works perfect without any timeout and delay. ANd all node works without REPEATER.
    My opinion is that in version 2.3.0 something not working correct with radio RFM69HW.
    Maybe for sensors which send data from time to time is ok , but for cover which transfer data when cover is roll, it is problem... and gateway can not recived all data when node send position cover. Maybe developer read this thread and can do any changes to correct it.

    RFM69W / HW user here. I can confirm that V 2.3.0 on both nodes and PI has some broken. My nodes, stable for 3+ months, with new version they have issues. In detail, they cannot get ACK. In my sketch, I check for ACK when transmitting, to force the watchdog or no. NO ACK received (1 every 20/30) :(

    And my nodes are "perfect". LifePo4 or AA, someone feeded directly, RPI3 with 2.5a... And I repeat, no issues in 3+ months from switching from NRF to RFM.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mickecarlsson
      wrote on last edited by
      #57

      This is my generic temperature/humidity/battery level sketch that I use. I have upgraded all my nodes and gateway to 2.3.0 yesterday and I don't have any issue whatsoever :-)

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * This is a sketch I use to measure temperature, humidity and battery level on
       * my Easy/Newbie PCB for MySensors (rev 9)
       * Hardware used:
       * Easy/Newbie PCB for MySensors
       * BME280 (I only use temperature and humidity, all code for barometic pressure removed)
       *
       */
      
      // Enable debug prints to serial monitor
      //#define MY_DEBUG
      #define   MY_SPLASH_SCREEN_DISABLED  // This saves a couple of bytes
      // Enable and select radio type attached
      #define   MY_RADIO_RFM69
      #define   MY_IS_RFM69HW
      #define   MY_RFM69_NEW_DRIVER
      #define   MY_RFM69_FREQUENCY RFM69_868MHZ
      
      #include <MySensors.h>
      #include <Wire.h>       // Enables the Wire communication protocol.
      // Bosch BME280 Embedded Adventures MOD-1022 weather multi-sensor Arduino code, 
      // written originally by Embedded Adventures. 
      // https://github.com/embeddedadventures/BME280
      #include <BME280_MOD-1022.h>
      // Internal battery measurement https://github.com/Yveaux/arduino_vcc
      #include <Vcc.h>
      
      // Change all text variables here, no need to hunt them down in the sketch
      // For sendSketchInfo()
      #define SKETCH_NAME       "Generic Temeperature/Humidity"
      #define SKETCH_VERSION    "1.13"
      // For present()
      #define PRESENT_TEMP_TEXT "Temperature Generic"
      #define PRESENT_HUM_TEXT  "Humidity Generic"
      #define PRESENT_BAT_TEXT  "Batteri Test-3"
      
      // Battery measurements
      const float VccMin        = 1.8*1.0;  // Min Vcc level, in Volts. Example for 2xAA Alkaline.
      const float VccMax        = 2.0*1.5;  // Max Vcc level, in Volts. Example for 2xAA Alkaline.
      const float VccCorrection = 1.0/1.0;  // Measured Vcc by multimeter divided by reported Vcc
      
      Vcc vcc(VccCorrection);
      
      // VARIABLES YOU CAN CHANGE
      // Send temperature only if it has changed? 1 = Yes 0 = No.
      #define COMPARE_TEMP 0
      // Set this value to the minimum change in temperature to measure.
      // BME280 has +-0.5 degrees precision, so it really doesn't matter that much.
      float tempThreshold = 0.5;
      // Send temperature only if changed? 1 = Yes 0 = No.
      #define COMPARE_HUM 0
      // Set this value to the minimum change in humidity to measure.
      // BME280 has +-3% relative humidity precision, so it really doesn't matter that much.
      float humThreshold = 0.5;
      
      #define TEMP_CHILD_ID       1
      #define HUM_CHILD_ID        2
      #define VOLTAGE_CHILD_ID    3
      
      float lastTemperature = -1;   // Store previous measurement
      float lastHumidity =    -1;   // Stores the previous measurement
      bool reportRSSI = false;      // true = send RSSI to controller
      int sendBattery = 6;          // report battery level only after 6 loops = 6*4 minutes = 24 minutes
      // Placeholder for batteryloop, set to one above sendBattery so that we get a report on startup
      int batteryLoop = sendBattery + 1; 
      
      // Time between send (in milliseconds), in this case, 4 minutes.
      unsigned long FOUR_MINUTE_SEND_FREQUENCY = 4 * 60000;
      
      // MYSENSORS COMMUNICATION VARIABLES
      MyMessage temperatureMsg(TEMP_CHILD_ID, V_TEMP);
      MyMessage humidityMsg(HUM_CHILD_ID, V_HUM);
      MyMessage voltageMsg(VOLTAGE_CHILD_ID, V_VOLTAGE);
      
      void setup()
      {
      
      #ifdef MY_DEBUG
        Serial.begin(115200);
      #endif
      
        Wire.begin(); // For the BME280 sensor
      #ifdef MY_DEBUG
        Serial.println(F("Starting ..."));
      #endif
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
        // Present the sensors to the gateway and controller
        present(TEMP_CHILD_ID, S_TEMP, PRESENT_TEMP_TEXT);
        present(HUM_CHILD_ID, S_HUM, PRESENT_HUM_TEXT);
        present(VOLTAGE_CHILD_ID, S_MULTIMETER, PRESENT_BAT_TEXT);
      }
      
      void loop()
      {
      #ifdef MY_DEBUG
        Serial.println(F("Read BME280 and report it's values."));
      #endif
        GetTemperatureHumidity();                 // Get temperature and humidity
      
        if(batteryLoop > sendBattery) {           // Is the batteryLoop higher than sendBattery?
      #ifdef MY_DEBUG
          Serial.println(F("Read the battery voltage and report it."));
      #endif
          MeasureBattery();                      // Measure and report battery level
          batteryLoop = 0;                       // Reset batteryLoop count
      }
      #ifdef MY_DEBUG
        Serial.print(F("Go to sleep for: "));
        Serial.print(FOUR_MINUTE_SEND_FREQUENCY / 60000);
        Serial.println(F(" minutes."));
      #endif
        batteryLoop++;                           // Increase batteryLoop before we sleep. 
        sleep(FOUR_MINUTE_SEND_FREQUENCY);       // Sleep for 4 minutes
      }
      
      /************************************************
      * GetTemperatureHumidity()
      * Routine for measuring temperature and humidity
      * Generic one that fits my need 
      ************************************************/
      void GetTemperatureHumidity()
      {
      #ifdef MY_DEBUG
        Serial.println("");
        Serial.println(F("BME280 - Requesting new data from sensor module."));
      #endif
        BME280.readCompensationParams();            // Need to read the NVM compensation parameters.
        // Normal mode for regular automatic samples
        BME280.writeStandbyTime(tsb_0p5ms);         // tsb = 0.5ms
        BME280.writeFilterCoefficient(fc_16);       // IIR Filter coefficient 16
        BME280.writeOversamplingPressure(os16x);    // pressure x16
        BME280.writeOversamplingTemperature(os8x);  // temperature x8
        BME280.writeOversamplingHumidity(os8x);     // humidity x8
        BME280.writeMode(smNormal);
          
      #ifdef MY_DEBUG
        Serial.println(F("Getting new values"));
      #endif
        while (BME280.isMeasuring()) {              // Wait for BME280 to fininsh reading data
      #ifdef MY_DEBUG
          Serial.println("Measuring...");
      #endif
          delay(50);
        }
        Serial.println("Done!");
        // Read out the data - must do this before calling the getxxxxx routines
        BME280.readMeasurements();
        float temperature = BME280.getTemperatureMostAccurate();  // Get the temperature first.
        float humidity = BME280.getHumidityMostAccurate();        // Get the humidity.
      #ifdef MY_DEBUG
        Serial.print(F("BME280 - Temperature = "));
        Serial.print(temperature);
        Serial.println(" °C");
        Serial.print(F("BME280 - Humidity = "));
        Serial.print(humidity);
        Serial.println(F(" %"));
      #endif
        // Now, let's send the measurements to the gateway.
        // Send temperature if the temperature difference bigger than the threshold
        if (COMPARE_TEMP == 1 && abs(temperature - lastTemperature) < tempThreshold) { 
      #ifdef MY_DEBUG
          Serial.print(temperature - lastTemperature);
          Serial.println(F(" Temperature difference too small, don't send it to gateway."));
      #endif
        } else {
      #ifdef MY_DEBUG
            Serial.println(F("Sending new temperature to the gateway."));
      #endif
            send(temperatureMsg.set(temperature, 1));
            lastTemperature = temperature; // Save temperatures for compare in the next round.
        } 
        // Send humidity if the humidity difference is bigger than the threshold.
        if (COMPARE_TEMP == 1 && abs(humidity - lastHumidity) < humThreshold) { 
      #ifdef MY_DEBUG
          Serial.print(humidity - lastHumidity);
          Serial.println(F(" Humidity difference too small, don't send it to the gateway."));
      #endif
        } else {
      #ifdef MY_DEBUG
          Serial.println(F("BME280 - Sending the new humidity to the gateway."));
      #endif
          send(humidityMsg.set(humidity, 1));
          lastHumidity = humidity; // Save new humidity to be able to compare in the next round.
        }
      #ifdef MY_DEBUG
        Serial.println(F("BME280 - Measurement complete. Putting sensor to sleep."));
      #endif
        BME280.writeMode(smSleep);  // set the BME280to sleep mode, save battery
      } // End of GetTemperatureHumidity
      
      /*
      * MeasureBattery()
      * Routine for measuring battery level
      * Generic one that fits my need
      * NOTE: You need to calibrate the measurement to get correct readings
      */
      void MeasureBattery()
      {
        float Vbat = vcc.Read_Volts();
        int batteryPercent = static_cast<int>(vcc.Read_Perc(VccMin, VccMax));
      
      #ifdef MY_DEBUG
        Serial.print(F("Battery percent: ")); 
        Serial.print(batteryPercent); 
        Serial.println(" %"); 
        Serial.print(F("Battery Voltage: ")); 
        Serial.print(Vbat); 
        Serial.println(F(" Volts"));
      #endif
          sendBatteryLevel(batteryPercent);
          send(voltageMsg.set(Vbat,2)); //send battery in Volt 2 decimal places
      }
      
      
      pepsonP 1 Reply Last reply
      0
      • pepsonP pepson

        @mickecarlsson
        Can you share me your all sketches ? Thanks
        And tell me how you have connected Gateway to RPI3? By ethernet or by serial ? Because i see in your building Gateway that you dont use parameter ETHERNET on port 5003

        And anybody has any contact to developer @tekka007 ?

        This is info what show in debug on version 2.3.0 gateway and also node on version 2.3.0

        pi@hassbian:~/MySensors $ sudo /usr/local/bin/mysgw
        Jun 22 17:22:49 INFO  Starting gateway...
        Jun 22 17:22:49 INFO  Protocol version - 2.3.0
        Jun 22 17:22:49 DEBUG MCO:BGN:INIT GW,CP=RPNGL---,VER=2.3.0
        Jun 22 17:22:49 DEBUG TSF:LRT:OK
        Jun 22 17:22:49 DEBUG TSM:INIT
        Jun 22 17:22:49 DEBUG TSF:WUR:MS=0
        Jun 22 17:22:49 DEBUG TSM:INIT:TSP OK
        Jun 22 17:22:49 DEBUG TSM:INIT:GW MODE
        Jun 22 17:22:49 DEBUG TSM:READY:ID=0,PAR=0,DIS=0
        Jun 22 17:22:49 DEBUG MCO:REG:NOT NEEDED
        Jun 22 17:22:49 DEBUG Listening for connections on 0.0.0.0:5003
        Jun 22 17:22:49 DEBUG MCO:BGN:STP
        Jun 22 17:22:49 DEBUG MCO:BGN:INIT OK,TSP=1
        Jun 22 17:22:54 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
        Jun 22 17:22:54 DEBUG TSF:MSG:BC
        Jun 22 17:22:54 DEBUG TSF:MSG:FPAR REQ,ID=2
        Jun 22 17:22:54 DEBUG TSF:CKU:OK,FCTRL
        Jun 22 17:22:54 DEBUG TSF:MSG:GWL OK
        Jun 22 17:22:54 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=O                 K:0
        Jun 22 17:22:56 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
        Jun 22 17:22:56 DEBUG TSF:MSG:PINGED,ID=2,HP=1
        Jun 22 17:22:57 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=                 OK:1
        Jun 22 17:22:57 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
        Jun 22 17:22:58 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=                 OK:0100
        Jun 22 17:22:59 DEBUG TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.0
        Jun 22 17:22:59 DEBUG TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.0
        Jun 22 17:23:00 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
        Jun 22 17:23:00 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
        Jun 22 17:23:03 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=25,sg=0:1xRelay &                  Button-Sypialni
        Jun 22 17:23:03 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=25,sg=0:1xRelay &                  Button-Sypialni
        Jun 22 17:23:03 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=5,sg=0:2.2.0
        Jun 22 17:23:04 DEBUG TSF:MSG:READ,2-2-0,s=1,c=0,t=3,pt=0,l=0,sg=0:
        Jun 22 17:23:05 DEBUG TSF:MSG:READ,2-2-0,s=1,c=0,t=3,pt=0,l=0,sg=0:
        Jun 22 17:23:05 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
        Jun 22 17:23:06 DEBUG TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
        Jun 22 17:23:07 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=2,pt=2,l=2,sg=0:0
        Jun 22 17:23:08 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=2,pt=2,l=2,sg=0:0
        Jun 22 17:23:08 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
        Jun 22 17:23:09 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
        
        
        M Offline
        M Offline
        mickecarlsson
        wrote on last edited by
        #58

        @pepson said in RFM69 new driver delay:

        And tell me how you have connected Gateway to RPI3? By ethernet or by serial ? Because i see in your building Gateway that you dont use parameter ETHERNET on port 5003

        I use Ethernet to connect to my Domoticz.
        The reason that you don't see my configuration for ETHERNET or PORT is because they are default when you configure.
        If you look at the file Makefile.inc you will see the build options. In my case the file looks like this:

        SOC=BCM2837
        CPPFLAGS=-march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -DMY_RADIO_RFM69 -DMY_RFM69_NEW_DRIVER -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DMY_RFM69_FREQUENCY=RFM69_868MHZ -DMY_IS_RFM69HW 
        LDFLAGS=-pthread 
        PREFIX=/usr/local
        CC=gcc
        CXX=g++
        BUILDDIR=build
        BINDIR=bin
        GATEWAY_DIR=/usr/local/bin
        INIT_SYSTEM=systemd
        SPI_DRIVER=BCM
        

        So in my case I have these defines:
        MY_RADIO_RFM69
        MY_RFM69_NEW_DRIVER
        MY_GATEWAY_LINUX
        MY_DEBUG
        LINUX_SPI_BCM
        LINUX_ARCH_RASPBERRYPI
        MY_RFM69_FREQUENCY=RFM69_868MHZ
        MY_IS_RFM69HW

        pepsonP 1 Reply Last reply
        0
        • M mickecarlsson

          This is my generic temperature/humidity/battery level sketch that I use. I have upgraded all my nodes and gateway to 2.3.0 yesterday and I don't have any issue whatsoever :-)

          /**
           * The MySensors Arduino library handles the wireless radio link and protocol
           * between your home built sensors/actuators and HA controller of choice.
           * The sensors forms a self healing radio network with optional repeaters. Each
           * repeater and gateway builds a routing tables in EEPROM which keeps track of the
           * network topology allowing messages to be routed to nodes.
           *
           * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
           * Copyright (C) 2013-2015 Sensnology AB
           * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
           *
           * Documentation: http://www.mysensors.org
           * Support Forum: http://forum.mysensors.org
           *
           * This program is free software; you can redistribute it and/or
           * modify it under the terms of the GNU General Public License
           * version 2 as published by the Free Software Foundation.
           *
           *******************************
           *
           * DESCRIPTION
           *
           * This is a sketch I use to measure temperature, humidity and battery level on
           * my Easy/Newbie PCB for MySensors (rev 9)
           * Hardware used:
           * Easy/Newbie PCB for MySensors
           * BME280 (I only use temperature and humidity, all code for barometic pressure removed)
           *
           */
          
          // Enable debug prints to serial monitor
          //#define MY_DEBUG
          #define   MY_SPLASH_SCREEN_DISABLED  // This saves a couple of bytes
          // Enable and select radio type attached
          #define   MY_RADIO_RFM69
          #define   MY_IS_RFM69HW
          #define   MY_RFM69_NEW_DRIVER
          #define   MY_RFM69_FREQUENCY RFM69_868MHZ
          
          #include <MySensors.h>
          #include <Wire.h>       // Enables the Wire communication protocol.
          // Bosch BME280 Embedded Adventures MOD-1022 weather multi-sensor Arduino code, 
          // written originally by Embedded Adventures. 
          // https://github.com/embeddedadventures/BME280
          #include <BME280_MOD-1022.h>
          // Internal battery measurement https://github.com/Yveaux/arduino_vcc
          #include <Vcc.h>
          
          // Change all text variables here, no need to hunt them down in the sketch
          // For sendSketchInfo()
          #define SKETCH_NAME       "Generic Temeperature/Humidity"
          #define SKETCH_VERSION    "1.13"
          // For present()
          #define PRESENT_TEMP_TEXT "Temperature Generic"
          #define PRESENT_HUM_TEXT  "Humidity Generic"
          #define PRESENT_BAT_TEXT  "Batteri Test-3"
          
          // Battery measurements
          const float VccMin        = 1.8*1.0;  // Min Vcc level, in Volts. Example for 2xAA Alkaline.
          const float VccMax        = 2.0*1.5;  // Max Vcc level, in Volts. Example for 2xAA Alkaline.
          const float VccCorrection = 1.0/1.0;  // Measured Vcc by multimeter divided by reported Vcc
          
          Vcc vcc(VccCorrection);
          
          // VARIABLES YOU CAN CHANGE
          // Send temperature only if it has changed? 1 = Yes 0 = No.
          #define COMPARE_TEMP 0
          // Set this value to the minimum change in temperature to measure.
          // BME280 has +-0.5 degrees precision, so it really doesn't matter that much.
          float tempThreshold = 0.5;
          // Send temperature only if changed? 1 = Yes 0 = No.
          #define COMPARE_HUM 0
          // Set this value to the minimum change in humidity to measure.
          // BME280 has +-3% relative humidity precision, so it really doesn't matter that much.
          float humThreshold = 0.5;
          
          #define TEMP_CHILD_ID       1
          #define HUM_CHILD_ID        2
          #define VOLTAGE_CHILD_ID    3
          
          float lastTemperature = -1;   // Store previous measurement
          float lastHumidity =    -1;   // Stores the previous measurement
          bool reportRSSI = false;      // true = send RSSI to controller
          int sendBattery = 6;          // report battery level only after 6 loops = 6*4 minutes = 24 minutes
          // Placeholder for batteryloop, set to one above sendBattery so that we get a report on startup
          int batteryLoop = sendBattery + 1; 
          
          // Time between send (in milliseconds), in this case, 4 minutes.
          unsigned long FOUR_MINUTE_SEND_FREQUENCY = 4 * 60000;
          
          // MYSENSORS COMMUNICATION VARIABLES
          MyMessage temperatureMsg(TEMP_CHILD_ID, V_TEMP);
          MyMessage humidityMsg(HUM_CHILD_ID, V_HUM);
          MyMessage voltageMsg(VOLTAGE_CHILD_ID, V_VOLTAGE);
          
          void setup()
          {
          
          #ifdef MY_DEBUG
            Serial.begin(115200);
          #endif
          
            Wire.begin(); // For the BME280 sensor
          #ifdef MY_DEBUG
            Serial.println(F("Starting ..."));
          #endif
          }
          
          void presentation()
          {
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
            // Present the sensors to the gateway and controller
            present(TEMP_CHILD_ID, S_TEMP, PRESENT_TEMP_TEXT);
            present(HUM_CHILD_ID, S_HUM, PRESENT_HUM_TEXT);
            present(VOLTAGE_CHILD_ID, S_MULTIMETER, PRESENT_BAT_TEXT);
          }
          
          void loop()
          {
          #ifdef MY_DEBUG
            Serial.println(F("Read BME280 and report it's values."));
          #endif
            GetTemperatureHumidity();                 // Get temperature and humidity
          
            if(batteryLoop > sendBattery) {           // Is the batteryLoop higher than sendBattery?
          #ifdef MY_DEBUG
              Serial.println(F("Read the battery voltage and report it."));
          #endif
              MeasureBattery();                      // Measure and report battery level
              batteryLoop = 0;                       // Reset batteryLoop count
          }
          #ifdef MY_DEBUG
            Serial.print(F("Go to sleep for: "));
            Serial.print(FOUR_MINUTE_SEND_FREQUENCY / 60000);
            Serial.println(F(" minutes."));
          #endif
            batteryLoop++;                           // Increase batteryLoop before we sleep. 
            sleep(FOUR_MINUTE_SEND_FREQUENCY);       // Sleep for 4 minutes
          }
          
          /************************************************
          * GetTemperatureHumidity()
          * Routine for measuring temperature and humidity
          * Generic one that fits my need 
          ************************************************/
          void GetTemperatureHumidity()
          {
          #ifdef MY_DEBUG
            Serial.println("");
            Serial.println(F("BME280 - Requesting new data from sensor module."));
          #endif
            BME280.readCompensationParams();            // Need to read the NVM compensation parameters.
            // Normal mode for regular automatic samples
            BME280.writeStandbyTime(tsb_0p5ms);         // tsb = 0.5ms
            BME280.writeFilterCoefficient(fc_16);       // IIR Filter coefficient 16
            BME280.writeOversamplingPressure(os16x);    // pressure x16
            BME280.writeOversamplingTemperature(os8x);  // temperature x8
            BME280.writeOversamplingHumidity(os8x);     // humidity x8
            BME280.writeMode(smNormal);
              
          #ifdef MY_DEBUG
            Serial.println(F("Getting new values"));
          #endif
            while (BME280.isMeasuring()) {              // Wait for BME280 to fininsh reading data
          #ifdef MY_DEBUG
              Serial.println("Measuring...");
          #endif
              delay(50);
            }
            Serial.println("Done!");
            // Read out the data - must do this before calling the getxxxxx routines
            BME280.readMeasurements();
            float temperature = BME280.getTemperatureMostAccurate();  // Get the temperature first.
            float humidity = BME280.getHumidityMostAccurate();        // Get the humidity.
          #ifdef MY_DEBUG
            Serial.print(F("BME280 - Temperature = "));
            Serial.print(temperature);
            Serial.println(" °C");
            Serial.print(F("BME280 - Humidity = "));
            Serial.print(humidity);
            Serial.println(F(" %"));
          #endif
            // Now, let's send the measurements to the gateway.
            // Send temperature if the temperature difference bigger than the threshold
            if (COMPARE_TEMP == 1 && abs(temperature - lastTemperature) < tempThreshold) { 
          #ifdef MY_DEBUG
              Serial.print(temperature - lastTemperature);
              Serial.println(F(" Temperature difference too small, don't send it to gateway."));
          #endif
            } else {
          #ifdef MY_DEBUG
                Serial.println(F("Sending new temperature to the gateway."));
          #endif
                send(temperatureMsg.set(temperature, 1));
                lastTemperature = temperature; // Save temperatures for compare in the next round.
            } 
            // Send humidity if the humidity difference is bigger than the threshold.
            if (COMPARE_TEMP == 1 && abs(humidity - lastHumidity) < humThreshold) { 
          #ifdef MY_DEBUG
              Serial.print(humidity - lastHumidity);
              Serial.println(F(" Humidity difference too small, don't send it to the gateway."));
          #endif
            } else {
          #ifdef MY_DEBUG
              Serial.println(F("BME280 - Sending the new humidity to the gateway."));
          #endif
              send(humidityMsg.set(humidity, 1));
              lastHumidity = humidity; // Save new humidity to be able to compare in the next round.
            }
          #ifdef MY_DEBUG
            Serial.println(F("BME280 - Measurement complete. Putting sensor to sleep."));
          #endif
            BME280.writeMode(smSleep);  // set the BME280to sleep mode, save battery
          } // End of GetTemperatureHumidity
          
          /*
          * MeasureBattery()
          * Routine for measuring battery level
          * Generic one that fits my need
          * NOTE: You need to calibrate the measurement to get correct readings
          */
          void MeasureBattery()
          {
            float Vbat = vcc.Read_Volts();
            int batteryPercent = static_cast<int>(vcc.Read_Perc(VccMin, VccMax));
          
          #ifdef MY_DEBUG
            Serial.print(F("Battery percent: ")); 
            Serial.print(batteryPercent); 
            Serial.println(" %"); 
            Serial.print(F("Battery Voltage: ")); 
            Serial.print(Vbat); 
            Serial.println(F(" Volts"));
          #endif
              sendBatteryLevel(batteryPercent);
              send(voltageMsg.set(Vbat,2)); //send battery in Volt 2 decimal places
          }
          
          
          pepsonP Offline
          pepsonP Offline
          pepson
          wrote on last edited by
          #59

          @mickecarlsson
          You dont have issue becuase temp/hum send data from time to time every defined time.
          My sketch with relay also looks that works ok.
          But problem is on sketch with relay to control covers. WHen cover roll node send still data and it is problem...
          This is my opinion.

          1 Reply Last reply
          0
          • M mickecarlsson

            @pepson said in RFM69 new driver delay:

            And tell me how you have connected Gateway to RPI3? By ethernet or by serial ? Because i see in your building Gateway that you dont use parameter ETHERNET on port 5003

            I use Ethernet to connect to my Domoticz.
            The reason that you don't see my configuration for ETHERNET or PORT is because they are default when you configure.
            If you look at the file Makefile.inc you will see the build options. In my case the file looks like this:

            SOC=BCM2837
            CPPFLAGS=-march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -DMY_RADIO_RFM69 -DMY_RFM69_NEW_DRIVER -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DMY_RFM69_FREQUENCY=RFM69_868MHZ -DMY_IS_RFM69HW 
            LDFLAGS=-pthread 
            PREFIX=/usr/local
            CC=gcc
            CXX=g++
            BUILDDIR=build
            BINDIR=bin
            GATEWAY_DIR=/usr/local/bin
            INIT_SYSTEM=systemd
            SPI_DRIVER=BCM
            

            So in my case I have these defines:
            MY_RADIO_RFM69
            MY_RFM69_NEW_DRIVER
            MY_GATEWAY_LINUX
            MY_DEBUG
            LINUX_SPI_BCM
            LINUX_ARCH_RASPBERRYPI
            MY_RFM69_FREQUENCY=RFM69_868MHZ
            MY_IS_RFM69HW

            pepsonP Offline
            pepsonP Offline
            pepson
            wrote on last edited by pepson
            #60

            @mickecarlsson said in RFM69 new driver delay:

            MY_RADIO_RFM69 -DMY_RFM69_NEW_DRIVER -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DMY_RFM69_FREQUENCY=RFM69_868MHZ -DMY_IS_RFM69HW
            LDFLAGS=-pthread

            Tell me you have BME280 this :
            https://www.aliexpress.com/item/3In1-BME280-GY-BME280-Digital-Sensor-SPI-I2C-Humidity-Temperature-and-Barometric-Pressure-Sensor-Module-1/32847825408.html?spm=2114.search0104.3.1.6d76301deOqjBT&ws_ab_test=searchweb0_0,searchweb201602_3_10152_10151_10065_10344_10068_5722815_10342_10343_10340_5722915_10341_5722615_10696_10084_10083_10618_10304_10307_10820_10301_10821_5722715_10843_10059_306_100031_10103_10624_10623_10622_5722515_10621_10620,searchweb201603_1,ppcSwitch_5&algo_expid=8f90a51c-aded-4f24-a909-68e32bf05b4b-0&algo_pvid=8f90a51c-aded-4f24-a909-68e32bf05b4b&priceBeautifyAB=0

            My defined is the same:

            SOC=BCM2837
            CPPFLAGS=-march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -DMY_RADIO_RFM69 -DMY_RFM69_NEW_DRIVER -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DMY_DEFAULT_TX_LED_PIN=18 -DMY_DEFAULT_RX_LED_PIN=16 -DMY_DEFAULT_ERR_LED_PIN=12 -DMY_PORT=5003 -DMY_IS_RFM69HW -DMY_RFM69_FREQUENCY=RFM69_868MHZ 
            LDFLAGS=-pthread 
            PREFIX=/usr/local
            CC=gcc
            CXX=g++
            BUILDDIR=build
            BINDIR=bin
            GATEWAY_DIR=/usr/local/bin
            INIT_SYSTEM=systemd
            SPI_DRIVER=BCM
            
            1 Reply Last reply
            0
            • scalzS Offline
              scalzS Offline
              scalz
              Hardware Contributor
              wrote on last edited by scalz
              #61

              @pepson
              just to know, when you get this issue, do you send to one shutter only? (because i see you're sending each %, each 200ms). Well we have already did a stress test in the past, one packet each 50-70ms with a dozen of nodes and it worked but that was with a local unoffcial lib, and not with rpi as gw.
              I don't remember if buffer has been implemented in regular branch, for rfm69 (but I think so). And it should work like you said it works with 2.2
              We'll be able retry some stress tests, unfortunately not on rpi as gw (not using this setup), I'm not sure but maybe only marceloaqno may be using rpi with rfm69 (not sure), and we're a very few rfm69 users. Let us check if it's a general problem or rpi as gw only.
              Sorry for disturbance ;)

              pepsonP 1 Reply Last reply
              0
              • scalzS scalz

                @pepson
                just to know, when you get this issue, do you send to one shutter only? (because i see you're sending each %, each 200ms). Well we have already did a stress test in the past, one packet each 50-70ms with a dozen of nodes and it worked but that was with a local unoffcial lib, and not with rpi as gw.
                I don't remember if buffer has been implemented in regular branch, for rfm69 (but I think so). And it should work like you said it works with 2.2
                We'll be able retry some stress tests, unfortunately not on rpi as gw (not using this setup), I'm not sure but maybe only marceloaqno may be using rpi with rfm69 (not sure), and we're a very few rfm69 users. Let us check if it's a general problem or rpi as gw only.
                Sorry for disturbance ;)

                pepsonP Offline
                pepsonP Offline
                pepson
                wrote on last edited by
                #62

                @scalz
                Hmmm
                I am not advanced user. This sketch i found on github from other user. I can change sometinh in sketch to test it ? Can you help me what change in sketch to test ?

                1 Reply Last reply
                0
                • scalzS Offline
                  scalzS Offline
                  scalz
                  Hardware Contributor
                  wrote on last edited by scalz
                  #63

                  @pepson
                  no idea if it will help you, but what i meant is sending less msg .
                  I think i recognize some parts of this sketch, not sure :)

                  So, in your sketch, here you can see it sends at each %

                    if (isMoving) 
                    {
                      unsigned long _now = millis();
                      if (_now - lastLevelTime >= timeOneLevel * 1000) {
                        if (directionUpDown == DIRECTION_UP) {
                          currentShutterLevel += 1;
                        } else {
                          currentShutterLevel -= 1;
                        }
                        currentShutterLevel = constrain(currentShutterLevel, 0, 100);
                        #ifdef MY_DEBUG
                        Serial.println(String(requestedShutterLevel));
                        Serial.println(String(currentShutterLevel));
                        #endif
                        lastLevelTime = millis();
                        send(msgPercentage.set(currentShutterLevel));
                  

                  try to change this last line, by:

                  if (currentShutterLevel % 5 == 0) send(msgPercentage.set(currentShutterLevel)); // change 5 by 10 if you want to send each 10% for example
                  

                  no worry about shutter level update in controller, because when it will stop it will send its level (with sendstate in shutterhalt).
                  As your settings in top of sketch is 20sec for a complete roll, then it should send each second instead of 200ms previously (except if you did some calibration), and if i'm not wrong, I quickly read it!

                  pepsonP 1 Reply Last reply
                  0
                  • scalzS scalz

                    @pepson
                    no idea if it will help you, but what i meant is sending less msg .
                    I think i recognize some parts of this sketch, not sure :)

                    So, in your sketch, here you can see it sends at each %

                      if (isMoving) 
                      {
                        unsigned long _now = millis();
                        if (_now - lastLevelTime >= timeOneLevel * 1000) {
                          if (directionUpDown == DIRECTION_UP) {
                            currentShutterLevel += 1;
                          } else {
                            currentShutterLevel -= 1;
                          }
                          currentShutterLevel = constrain(currentShutterLevel, 0, 100);
                          #ifdef MY_DEBUG
                          Serial.println(String(requestedShutterLevel));
                          Serial.println(String(currentShutterLevel));
                          #endif
                          lastLevelTime = millis();
                          send(msgPercentage.set(currentShutterLevel));
                    

                    try to change this last line, by:

                    if (currentShutterLevel % 5 == 0) send(msgPercentage.set(currentShutterLevel)); // change 5 by 10 if you want to send each 10% for example
                    

                    no worry about shutter level update in controller, because when it will stop it will send its level (with sendstate in shutterhalt).
                    As your settings in top of sketch is 20sec for a complete roll, then it should send each second instead of 200ms previously (except if you did some calibration), and if i'm not wrong, I quickly read it!

                    pepsonP Offline
                    pepsonP Offline
                    pepson
                    wrote on last edited by
                    #64

                    @scalz

                    Sorry but i dont know what line chage with this your line

                    if (currentShutterLevel % 5 == 0) send(msgPercentage.set(currentShutterLevel)); // change 5 by 10 if you want to send each 10% for example```
                    1 Reply Last reply
                    0
                    • scalzS Offline
                      scalzS Offline
                      scalz
                      Hardware Contributor
                      wrote on last edited by scalz
                      #65

                      @pepson
                      I extracted a part of your sketch above. change the last line of the extract

                      pepsonP 1 Reply Last reply
                      0
                      • scalzS scalz

                        @pepson
                        I extracted a part of your sketch above. change the last line of the extract

                        pepsonP Offline
                        pepsonP Offline
                        pepson
                        wrote on last edited by pepson
                        #66

                        @scalz

                        Should looks like this ?

                        if (isMoving) 
                          {
                            unsigned long _now = millis();
                            if (_now - lastLevelTime >= timeOneLevel * 1000) {
                              if (directionUpDown == DIRECTION_UP) {
                                currentShutterLevel += 1;
                              } else {
                                currentShutterLevel -= 1;
                              }
                              currentShutterLevel = constrain(currentShutterLevel, 0, 100);
                              #ifdef MY_DEBUG
                              Serial.println(String(requestedShutterLevel));
                              Serial.println(String(currentShutterLevel));
                              #endif
                              lastLevelTime = millis();
                              if (currentShutterLevel % 5 == 0) send(msgPercentage.set(currentShutterLevel)); // change 5 by 10 if you want to send each 10% for example```
                        pepsonP 1 Reply Last reply
                        0
                        • pepsonP pepson

                          @scalz

                          Should looks like this ?

                          if (isMoving) 
                            {
                              unsigned long _now = millis();
                              if (_now - lastLevelTime >= timeOneLevel * 1000) {
                                if (directionUpDown == DIRECTION_UP) {
                                  currentShutterLevel += 1;
                                } else {
                                  currentShutterLevel -= 1;
                                }
                                currentShutterLevel = constrain(currentShutterLevel, 0, 100);
                                #ifdef MY_DEBUG
                                Serial.println(String(requestedShutterLevel));
                                Serial.println(String(currentShutterLevel));
                                #endif
                                lastLevelTime = millis();
                                if (currentShutterLevel % 5 == 0) send(msgPercentage.set(currentShutterLevel)); // change 5 by 10 if you want to send each 10% for example```
                          pepsonP Offline
                          pepsonP Offline
                          pepson
                          wrote on last edited by
                          #67

                          Ok tested as show in previus post. And the same problem. Maybe a little better. But maybe no...
                          On 2.2.0 is a very very better.

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


                          18

                          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