Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. KevinT
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    KevinT

    @KevinT

    3
    Reputation
    12
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    KevinT Follow

    Best posts made by KevinT

    • RE: Home Assistant errors with serial gateway

      Hi electrik,
      Yes, my nodes send the sketch name within the presentation function.
      As for the gateway, I have not set up a sketch name, the example I found did not implement this, so I didn't think it
      was necessary?

      I manually named the gateway node in the configuration.yaml file, and the "missing sketch name" message no longer appears in the log. I guess, I'll add an entry for node 0 (controller) as well .

      I'm still getting the "USB0 not ready after 15.0 secs" at startup, but all seems to work regardless.

      I connected the gateway to my pc using mycontroller, it all works fine. Logs look normal.

      Here is the code for one of my nodes, a temperature node with Arduino mini & RFM69 radio, running on battery.

      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      #define MY_BAUD_RATE 38400
      
      // Enable and select radio type attached
      //#define MY_RADIO_RF24
      #define MY_RADIO_RFM69
      #define MY_IS_RFM69HW
      #define MY_RFM69_FREQUENCY  RFM69_915MHZ
      
      #include <MySensors.h>  
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
      
      #define ONE_WIRE_BUS 8 // Pin where dallas sensor is connected 
      
      #define CHILD_ID_TEMP 0
      #define CHILD_ID_BATT 1
      
      // function protos
      void ReadBat(double& b, uint8_t& bPct);
      
      unsigned long SLEEP_TIME = 300000;    // Sleep time between reads (5min) (in milliseconds)
      const int BAT_V = A0;                 // battery voltage, AnaIn 0
      
      OneWire oneWire(ONE_WIRE_BUS);        // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire);  // Pass the oneWire reference to Dallas Temperature. 
      
      float lastTemperature;
      double bat, lastBat=0.0;
      uint8_t batPct;
      int numSensors=0;
      bool receivedConfig = false;
      bool metric = true;
      bool initialValuesSent = false;
      bool initialValTempSent = false;
      bool initialValBatSent = false;
      
      // Initialize message objects
      MyMessage msg(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgBatt(CHILD_ID_BATT, V_VOLTAGE);
      
      void before()
      {
        // Startup up the OneWire library
        sensors.begin();
      }
      
      void setup()  
      { 
        sensors.setWaitForConversion(false);
        // requestTemperatures() will not block current thread
        Serial.print("Found ");
        Serial.print(sensors.getDeviceCount(), DEC);
        Serial.println(" temperature devices.");
        sensors.requestTemperatures();
      }
      
      void presentation() {
        Serial.println("Sending presentation");
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Temperature Sensor", "1.2");
        // Present all sensors to controller
        present(CHILD_ID_TEMP, S_TEMP, "Bed room Temperature");
        present(CHILD_ID_BATT, S_MULTIMETER, "Bed room node Voltage");
      }
      
      void loop()     
      {     
        int16_t conversionTime = 0;
        float temperature = 0;
        
        if (!initialValuesSent) {
          Serial.println("Sending initial value");
          // Read in the battery voltage
          ReadBat(bat, batPct);
          // get temperature conversion time
          conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
          wait(conversionTime);
          // Fetch temperature
          temperature = sensors.getTempCByIndex(0);
          // send the temperature reading
          // set(float value, uint8_t decimals)
          send(msg.set(temperature, 2));
          Serial.println("Requesting initial Temp value from controller");
          request(CHILD_ID_TEMP, V_TEMP);
          wait(2000, C_SET, V_TEMP);
          // send bat voltage
          send(msgBatt.set(bat, 2));
          Serial.println("Requesting initial Batt value from controller");
          request(CHILD_ID_BATT, V_VOLTAGE);
          wait(2000, C_SET, V_VOLTAGE);
        }
      //  {
        else {
          // Fetch temperatures from Dallas sensors (non-blocking)
          sensors.requestTemperatures();
          // Read in the battery voltage
          ReadBat(bat, batPct);
        
          // query conversion time and sleep until conversion completed
          conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
          
          // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
          sleep(conversionTime);
        
          // Read temperature and send to controller 
          // Fetch temperature
          temperature = sensors.getTempCByIndex(0);
          Serial.println("temperature: ");
          Serial.println(temperature);
        
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
            // Send in the new temperature
            // set(float value, uint8_t decimals)
            send(msg.set(temperature, 2));
            // Save new temperatures for next compare
            lastTemperature=temperature;
          }
          // Send in the new battery level
          sendBatteryLevel(batPct);
          send(msgBatt.set(bat, 2));
          // Save the battery level for next compare
          lastBat = bat;
          Serial.println("Sleep...");
          sleep(SLEEP_TIME);
        }
      }
      
      void receive(const MyMessage &message) {
        if (message.isAck()) {
           Serial.println("This is an ack from gateway");
        }
      
        if (message.type == V_TEMP) {
          if (!initialValTempSent) {
            Serial.println("Received initial temp value from controller");
            initialValTempSent = true;
          }
        }
        else if (message.type == V_VOLTAGE) {
          if (!initialValBatSent) {
            Serial.println("Received initial bat value from controller");
            initialValBatSent = true;
          }
        }
        if (initialValTempSent && initialValBatSent)
          initialValuesSent = true;
      }
      
      // b - battery voltage
      // bPct - battery percent
      void ReadBat(double& b, uint8_t& bPct)
      {
        long sumBat=0;
        int i;
      
        // take average over 64 readings
        for (i = 0; i < 64; ++i) {
          // read & sum battery voltage
          sumBat += analogRead(BAT_V);
        }
        sumBat = sumBat >> 6;      // shift 6 -> divide by 64
        b = sumBat*3.3/1023.0;
        bPct = (uint8_t)(sumBat*100.0/1023.0);
      }
      

      Here is the serial gateway sketch:

      #include <SoftwareSerial.h>
      SoftwareSerial softSerial(8, 9); // RX, TX
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      #define MY_DEBUGDEVICE softSerial
      // You also need to create softSerial in setup()
      
      // Enable and select radio type attached
      //#define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM95
      #define MY_RADIO_RFM69
      #define MY_IS_RFM69HW
      #define MY_RFM69_FREQUENCY  RFM69_915MHZ
      
      
      // Set LOW transmit power level as default, if you have an amplified NRF-module and
      // power your radio separately with a good regulator you can turn up PA level.
      //#define MY_RF24_PA_LEVEL RF24_PA_LOW
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      // Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      
      // Inverses behavior of inclusion button (if using external pullup)
      //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
      
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Inverses the behavior of leds
      //#define MY_WITH_LEDS_BLINKING_INVERSE
      
      // Flash leds on rx/tx/err
      // Uncomment to override default HW configurations
      //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
      
      #include <MySensors.h>
      
      void setup()
      {
        softSerial.begin(38400);
      }
      
      void presentation()
      {
      	// Present locally attached sensors
      }
      
      void loop()
      {
      	// Send locally attached sensor data here
      }
      
      posted in Home Assistant
      KevinT
      KevinT
    • RE: RFM69HW & ATC not working

      Documenting what I've found in the library code for the community.
      When using #define MY_IS_RFM69HW:
      The driver enables PA1 and PA2 and disables PA0 power amps. It automatically selects the right combination of PA1 and PA2 to achieve the target power level.
      Power range is -2 to +20 dBm

      When NOT using #define MY_IS_RFM69HW:
      Then only PA0 is enabled.
      PA0 is identical between the RFM69W and RFM69HW.
      Power range is -18 to +13 dBm
      Basically, your RFM69HW operates as an RFM69W.

      Also, when using the new RFM69 driver, ATC mode is on by default, unless you explicitly turn it off using macro #define MY_RFM69_ATC_MODE_DISABLED
      The default ATC target RSSI level is -80 dBm which you can change using #define MY_RFM69_ATC_TARGET_RSSI_DBM

      Cheers

      posted in Troubleshooting
      KevinT
      KevinT
    • RE: RFM69HW & ATC not working

      @scalz
      This is my first attempt at using the lower power PA0. I am getting an RSSI of -75 with the radios about 5m apart and the radio using 10 dBm to achieve this. Quite disappointing. I was expecting the transmit power to be much lower, since in High Power mode I was getting an RSSI of -45 with transmit power of -2 dBm.
      I thought that perhaps the radio was reporting the wrong transmit power, or that the library was not interpreting it correctly. I expected results similar to the data sheet.
      b17272d8-0fc8-42a4-925b-534e0801865d-image.png
      But you say this is a common problem!
      I was planning on standardising on the high power radio for all my nodes, but now I see I will have to switch to the RFM69W for many of them.

      Thanks very much for taking the time to bring me up to speed, its greatly appreciated.

      posted in Troubleshooting
      KevinT
      KevinT

    Latest posts made by KevinT

    • RE: Gateway report all nodes rf power

      @mfalkvidd Thanks, that's exactly what I need. I wasn't sure how to retrieve the values at the gateway.
      Just wondering how the receive works. Is it called every time the gateway receives data from a node, after the node processes the message?

      Thanks again,
      KevinT

      posted in General Discussion
      KevinT
      KevinT
    • Gateway report all nodes rf power

      Hi,

      I'm running a mysensors network using RFM69 radios and I am wondering if it is possible to have the gateway report (as sensors) all the attached node's rf power levels?

      I have played with the rf reporting and I currently have a couple of nodes reporting their levels. I configured the 'sensors' as S_LIGHT_LEVEL since I report the 0-100% transmit level. I couldn't find a sensor specific to rf power.

      Just thought it would be easier to have the gateway report the levels since the measurements are coming from the gateway in the first place.

      Thanks,

      Kevin

      posted in General Discussion
      KevinT
      KevinT
    • RE: can't remove unused sensors from HA

      I know this thread is old, but it might help others in future searches.

      I simply deleted the child I no longer used from the persistence file, saved it and restarted Home Assistant.
      The child was gone.
      If you want to change a child to a new sensor this also works.
      After restarting Home Assistant, power up the node and the child will present itself and update the persistence file.

      posted in Home Assistant
      KevinT
      KevinT
    • RE: RFM69HW & ATC not working

      @scalz
      That was going to be my next question, the expected range/power for RFM69W, if they are good, reasonable radios.
      I also noticed in the forums a lot of complaints about bad NRF24L01 clones. It seems that RFM radios are a better choice?

      posted in Troubleshooting
      KevinT
      KevinT
    • RE: RFM69HW & ATC not working

      @scalz
      This is my first attempt at using the lower power PA0. I am getting an RSSI of -75 with the radios about 5m apart and the radio using 10 dBm to achieve this. Quite disappointing. I was expecting the transmit power to be much lower, since in High Power mode I was getting an RSSI of -45 with transmit power of -2 dBm.
      I thought that perhaps the radio was reporting the wrong transmit power, or that the library was not interpreting it correctly. I expected results similar to the data sheet.
      b17272d8-0fc8-42a4-925b-534e0801865d-image.png
      But you say this is a common problem!
      I was planning on standardising on the high power radio for all my nodes, but now I see I will have to switch to the RFM69W for many of them.

      Thanks very much for taking the time to bring me up to speed, its greatly appreciated.

      posted in Troubleshooting
      KevinT
      KevinT
    • RE: RFM69HW & ATC not working

      Hi @scalz,
      I don't know, I've tried it, it worked for me.
      Just to be clear, I'm still using #define MY_RADIO_RFM69
      What in the library would stop it?

      posted in Troubleshooting
      KevinT
      KevinT
    • RE: RFM69HW & ATC not working

      Documenting what I've found in the library code for the community.
      When using #define MY_IS_RFM69HW:
      The driver enables PA1 and PA2 and disables PA0 power amps. It automatically selects the right combination of PA1 and PA2 to achieve the target power level.
      Power range is -2 to +20 dBm

      When NOT using #define MY_IS_RFM69HW:
      Then only PA0 is enabled.
      PA0 is identical between the RFM69W and RFM69HW.
      Power range is -18 to +13 dBm
      Basically, your RFM69HW operates as an RFM69W.

      Also, when using the new RFM69 driver, ATC mode is on by default, unless you explicitly turn it off using macro #define MY_RFM69_ATC_MODE_DISABLED
      The default ATC target RSSI level is -80 dBm which you can change using #define MY_RFM69_ATC_TARGET_RSSI_DBM

      Cheers

      posted in Troubleshooting
      KevinT
      KevinT
    • RE: RFM69HW & ATC not working

      I've more information to share.

      Seems I was running out of memory, when I turned off debug, which freed up some room, I started to get more reasonable results.

      Uplink Qlty: 0, Xmit Level (dBm): -2, Xmit Level (%): 0
      Xmit RSSI: -45, Recv RSSI: -39
      
      

      Wondering if this is as low as it can go?

      Looking at the datasheet,
      PA1 and PA2 combined on pin PA_BOOST: +2 to +17 dBm
      and
      PA1+PA2 on PA_BOOST with high output power +20dBm settings (see 3.3.7): +5 to +20 dBm

      I don't know what power level is selected when we enable #define MY_IS_RFM69HW

      Can we simply run it as a low power RFM69 by commenting out the #define?

      posted in Troubleshooting
      KevinT
      KevinT
    • RFM69HW & ATC not working

      Hi,
      I'm hoping someone can help me with ATC mode on my RFM69HW/Arduino Pro Mini nodes.
      I've enabled it per the example sketch RFM69_RFM95_ATC_SignalReport.ino.

      I've updated the node & gateway to use the new RFM69 driver.

      It doesn't seem to adjust the transmit power on my node and I get a TSF error as well.
      A couple example debug outputs:

      BME280 - Sending the new humidity to the gateway.
      55791 TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:53.11
      Uplink Qlty: 0, Xmit Level (dBm): 107, Xmit Level (%): 140
      Xmit RSSI: -46, Recv RSSI: -54, Xmit SNR: -256, Recv SNR: -256
      55805 TSF:MSG:READ,92-1-4,s=2,c=1,t=4,pt=0,l=6,sg=0:102.05
      55816 !TSF:MSG:LEN=26,EXP=13
      State: ST_SLEEP
      
      Uplink Qlty: 0, Xmit Level (dBm): 11, Xmit Level (%): 108
      Xmit RSSI: -46, Recv RSSI: -53, Xmit SNR: -256, Recv SNR: -256
      56082 TSF:MSG:READ,92-2-4,s=2,c=1,t=4,pt=0,l=6,sg=0:102.05
      56094 !TSF:MSG:LEN=32,EXP=13
      56096 TSF:MSG:READ,92-2-4,s=2,c=1,t=4,pt=0,l=6,sg=0:102.05
      56102 !TSF:MSG:LEN=26,EXP=13
      State: ST_SLEEP
      
      

      You can see that the Xmit levels don't make sense.
      The Xmit RSSI should be moving towards -70 dBm but never really changes.

      Here's the macros in the node's code:

      // if you uncomment this, you can get test and debug updates about everything the sensor is doing by using the serial monitor tool.
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      //#define MY_RADIO_RF24                            // A 2.4Ghz transmitter and receiver, often used with MySensors.
      // #define MY_RF24_PA_LEVEL RF24_PA_MIN              // This sets a low-power mode for the radio. Useful if you use the version with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio.
      #define MY_RADIO_RFM69                        // possible 434, 868, 915Mhz transmitter and reveiver.
      #define MY_RFM69_NEW_DRIVER                   // ATC on RFM69 works only with the new driver (not compatible with old=default driver)
      #define MY_IS_RFM69HW                         // high power version of radio
      #define MY_RFM69_FREQUENCY  RFM69_915MHZ
      #define MY_RFM69_ATC_TARGET_RSSI_DBM (-70)    // target RSSI -70dBm
      #define MY_RFM69_MAX_POWER_LEVEL_DBM 10       // max. TX power 10dBm = 10mW
      
      // Do you want this sensor to also be a repeater?
      // #define MY_REPEATER_FEATURE                    // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this.
      
      // Are you using this sensor on battery power?
      #define BATTERY_POWERED
      
      // Would you like to report humidity?
      #define REPORT_HUMIDITY
      
      // LIBRARIES
      #include <SPI.h>                                  // A communication backbone, the Serial Peripheral Interface.
      #include <MySensors.h>                            // The MySensors library. Hurray!
      #include <Wire.h>                                 // Enables the Wire communication protocol.
      #include <BME280_MOD-1022.h>                      // Bosch BME280 Embedded Adventures MOD-1022 weather multi-sensor Arduino code, written originally by Embedded Adventures. https://github.com/embeddedadventures/BME280
      
      

      and later, in the loop()

      #ifdef REPORT_HUMIDITY
            // Send humidity
            if (COMPARE_HUM == 1 && fabs(humidity - lastHumidity) < humThreshold) { // is the humidity difference bigger than the threshold?
      //        Serial.print(humidity - lastHumidity);
      //        Serial.println("- BME280 - Humidity difference too small, so not sending the new measurement to the gateway.");
            } else {
              Serial.println("BME280 - Sending the new humidity to the gateway.");
              send(humidityMsg.set(humidity, 2));
              lastHumidity = humidity; // Save new humidity to be able to compare in the next round.
            }
      #endif
            // Send pressure
            if (COMPARE_PRES == 1 && fabs(pressure - lastPressure) < presThreshold) { // is the pressure difference bigger than the threshold?
      //        Serial.print(pressure - lastPressure);
      //        Serial.println("- BME280 - Pressure difference too small, so not sending the new measurement to the gateway.");
            } else {
              Serial.println("BME280 - Sending the new pressure to the gateway.");
              send(pressureMsg.set(pressure, 2));
              lastPressure = pressure; // Save new pressure to be able to compare in the next round.
            }
      
            ReportRfPower();
            state = ST_SLEEP;
            break;
      

      and the report of ATC values:

      void ReportRfPower()
      {
        Serial.print("Uplink Qlty: ");  Serial.print(transportGetSignalReport(SR_UPLINK_QUALITY));
        Serial.print(", Xmit Level (dBm): ");  Serial.print(transportGetSignalReport(SR_TX_POWER_LEVEL));
        Serial.print(", Xmit Level (%): ");  Serial.println(transportGetSignalReport(SR_TX_POWER_PERCENT));
              
        Serial.print("Xmit RSSI: ");  Serial.print(transportGetSignalReport(SR_TX_RSSI));
        Serial.print(", Recv RSSI: ");  Serial.print(transportGetSignalReport(SR_RX_RSSI));
        Serial.print(", Xmit SNR: ");  Serial.print(transportGetSignalReport(SR_TX_SNR));
        Serial.print(", Recv SNR: ");  Serial.println(transportGetSignalReport(SR_RX_SNR));
      }
      
      

      Any ideas?

      posted in Troubleshooting
      KevinT
      KevinT
    • RE: Home Assistant errors with serial gateway

      Hi electrik,
      Yes, my nodes send the sketch name within the presentation function.
      As for the gateway, I have not set up a sketch name, the example I found did not implement this, so I didn't think it
      was necessary?

      I manually named the gateway node in the configuration.yaml file, and the "missing sketch name" message no longer appears in the log. I guess, I'll add an entry for node 0 (controller) as well .

      I'm still getting the "USB0 not ready after 15.0 secs" at startup, but all seems to work regardless.

      I connected the gateway to my pc using mycontroller, it all works fine. Logs look normal.

      Here is the code for one of my nodes, a temperature node with Arduino mini & RFM69 radio, running on battery.

      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      #define MY_BAUD_RATE 38400
      
      // Enable and select radio type attached
      //#define MY_RADIO_RF24
      #define MY_RADIO_RFM69
      #define MY_IS_RFM69HW
      #define MY_RFM69_FREQUENCY  RFM69_915MHZ
      
      #include <MySensors.h>  
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
      
      #define ONE_WIRE_BUS 8 // Pin where dallas sensor is connected 
      
      #define CHILD_ID_TEMP 0
      #define CHILD_ID_BATT 1
      
      // function protos
      void ReadBat(double& b, uint8_t& bPct);
      
      unsigned long SLEEP_TIME = 300000;    // Sleep time between reads (5min) (in milliseconds)
      const int BAT_V = A0;                 // battery voltage, AnaIn 0
      
      OneWire oneWire(ONE_WIRE_BUS);        // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire);  // Pass the oneWire reference to Dallas Temperature. 
      
      float lastTemperature;
      double bat, lastBat=0.0;
      uint8_t batPct;
      int numSensors=0;
      bool receivedConfig = false;
      bool metric = true;
      bool initialValuesSent = false;
      bool initialValTempSent = false;
      bool initialValBatSent = false;
      
      // Initialize message objects
      MyMessage msg(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgBatt(CHILD_ID_BATT, V_VOLTAGE);
      
      void before()
      {
        // Startup up the OneWire library
        sensors.begin();
      }
      
      void setup()  
      { 
        sensors.setWaitForConversion(false);
        // requestTemperatures() will not block current thread
        Serial.print("Found ");
        Serial.print(sensors.getDeviceCount(), DEC);
        Serial.println(" temperature devices.");
        sensors.requestTemperatures();
      }
      
      void presentation() {
        Serial.println("Sending presentation");
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Temperature Sensor", "1.2");
        // Present all sensors to controller
        present(CHILD_ID_TEMP, S_TEMP, "Bed room Temperature");
        present(CHILD_ID_BATT, S_MULTIMETER, "Bed room node Voltage");
      }
      
      void loop()     
      {     
        int16_t conversionTime = 0;
        float temperature = 0;
        
        if (!initialValuesSent) {
          Serial.println("Sending initial value");
          // Read in the battery voltage
          ReadBat(bat, batPct);
          // get temperature conversion time
          conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
          wait(conversionTime);
          // Fetch temperature
          temperature = sensors.getTempCByIndex(0);
          // send the temperature reading
          // set(float value, uint8_t decimals)
          send(msg.set(temperature, 2));
          Serial.println("Requesting initial Temp value from controller");
          request(CHILD_ID_TEMP, V_TEMP);
          wait(2000, C_SET, V_TEMP);
          // send bat voltage
          send(msgBatt.set(bat, 2));
          Serial.println("Requesting initial Batt value from controller");
          request(CHILD_ID_BATT, V_VOLTAGE);
          wait(2000, C_SET, V_VOLTAGE);
        }
      //  {
        else {
          // Fetch temperatures from Dallas sensors (non-blocking)
          sensors.requestTemperatures();
          // Read in the battery voltage
          ReadBat(bat, batPct);
        
          // query conversion time and sleep until conversion completed
          conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
          
          // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
          sleep(conversionTime);
        
          // Read temperature and send to controller 
          // Fetch temperature
          temperature = sensors.getTempCByIndex(0);
          Serial.println("temperature: ");
          Serial.println(temperature);
        
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
            // Send in the new temperature
            // set(float value, uint8_t decimals)
            send(msg.set(temperature, 2));
            // Save new temperatures for next compare
            lastTemperature=temperature;
          }
          // Send in the new battery level
          sendBatteryLevel(batPct);
          send(msgBatt.set(bat, 2));
          // Save the battery level for next compare
          lastBat = bat;
          Serial.println("Sleep...");
          sleep(SLEEP_TIME);
        }
      }
      
      void receive(const MyMessage &message) {
        if (message.isAck()) {
           Serial.println("This is an ack from gateway");
        }
      
        if (message.type == V_TEMP) {
          if (!initialValTempSent) {
            Serial.println("Received initial temp value from controller");
            initialValTempSent = true;
          }
        }
        else if (message.type == V_VOLTAGE) {
          if (!initialValBatSent) {
            Serial.println("Received initial bat value from controller");
            initialValBatSent = true;
          }
        }
        if (initialValTempSent && initialValBatSent)
          initialValuesSent = true;
      }
      
      // b - battery voltage
      // bPct - battery percent
      void ReadBat(double& b, uint8_t& bPct)
      {
        long sumBat=0;
        int i;
      
        // take average over 64 readings
        for (i = 0; i < 64; ++i) {
          // read & sum battery voltage
          sumBat += analogRead(BAT_V);
        }
        sumBat = sumBat >> 6;      // shift 6 -> divide by 64
        b = sumBat*3.3/1023.0;
        bPct = (uint8_t)(sumBat*100.0/1023.0);
      }
      

      Here is the serial gateway sketch:

      #include <SoftwareSerial.h>
      SoftwareSerial softSerial(8, 9); // RX, TX
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      #define MY_DEBUGDEVICE softSerial
      // You also need to create softSerial in setup()
      
      // Enable and select radio type attached
      //#define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM95
      #define MY_RADIO_RFM69
      #define MY_IS_RFM69HW
      #define MY_RFM69_FREQUENCY  RFM69_915MHZ
      
      
      // Set LOW transmit power level as default, if you have an amplified NRF-module and
      // power your radio separately with a good regulator you can turn up PA level.
      //#define MY_RF24_PA_LEVEL RF24_PA_LOW
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      // Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      
      // Inverses behavior of inclusion button (if using external pullup)
      //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
      
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Inverses the behavior of leds
      //#define MY_WITH_LEDS_BLINKING_INVERSE
      
      // Flash leds on rx/tx/err
      // Uncomment to override default HW configurations
      //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
      
      #include <MySensors.h>
      
      void setup()
      {
        softSerial.begin(38400);
      }
      
      void presentation()
      {
      	// Present locally attached sensors
      }
      
      void loop()
      {
      	// Send locally attached sensor data here
      }
      
      posted in Home Assistant
      KevinT
      KevinT