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. [Solved] Node not reconnecting

[Solved] Node not reconnecting

Scheduled Pinned Locked Moved Troubleshooting
17 Posts 5 Posters 5.3k Views 6 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.
  • kk02067K Offline
    kk02067K Offline
    kk02067
    wrote on last edited by tekka
    #1

    I have a node that is causing problems for me. When I have the node and the gateway in the same room all works fine. But when I move them apart the node stops sending the messages after a random couple of hours. This I think is because of the range. But if I move the node closer to the gatway again it doesn't reconnect. And the debug from the node outputs:

    !TSP:SEND:TNR
    !TSP:SEND:TNR
    !TSP:SEND:TNR
    RF24:write register, reg=0, value=12
    RF24:power down
    

    and repeats until I reset the node.

    It seems that my auto reset of the nod fails also.

    The sketch looks like this:

    #include <SoftReset.h>
    
    /******************************************************************************
    I2C_ReadAllData.ino
    BME280 Arduino and Teensy example
    Marshall Taylor @ SparkFun Electronics
    May 20, 2015
    https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
    
    This sketch configures the BME280 to read all measurements.  The sketch also
    displays the BME280's physical memory and what the driver perceives the
    calibration words to be.
    
    Resources:
    Uses Wire.h for I2C operation
    Uses SPI.h for SPI operation
    
    Development environment specifics:
    Arduino IDE 1.6.4
    Teensy loader 1.23
    
    This code is released under the [MIT License](http://opensource.org/licenses/MIT).
    Please review the LICENSE.md file included with this example. If you have any questions 
    or concerns with licensing, please contact techsupport@sparkfun.com.
    Distributed as-is; no warranty is given.
    ******************************************************************************/
    
    #include <stdint.h>
    #include "SparkFunBME280.h"
    //Library allows either I2C or SPI, so include both.
    #include "Wire.h"
    #include "SPI.h"
    
    #define MY_DEBUG
    #define MY_DEBUG_VERBOSE_RF24
    #define MY_RADIO_NRF24
    #include <MySensors.h>
    
    #define SKETCH_NAME "Min väderstation"
    #define SKETCH_MAJOR_VER "1"
    #define SKETCH_MINOR_VER "1"
    #define CHILD_ID_1 1
    #define CHILD_ID_2 2
    #define CHILD_ID_3 3
    
    
    //Global sensor object
    BME280 Sensor;
    
    
    MyMessage msg1(CHILD_ID_1, V_TEMP);
    MyMessage msg2(CHILD_ID_2, V_HUM);
    MyMessage msg3(CHILD_ID_3, V_PRESSURE);
    
    
    void setup()
    {
    	//***Driver settings********************************//
    	//commInterface can be I2C_MODE or SPI_MODE
    	//specify chipSelectPin using arduino pin names
    	//specify I2C address.  Can be 0x77(default) or 0x76
    	
    	//For I2C, enable the following and disable the SPI section
    	Sensor.settings.commInterface = I2C_MODE;
    	Sensor.settings.I2CAddress = 0x76;
    	
    	//For SPI enable the following and dissable the I2C section
    	//Sensor.settings.commInterface = SPI_MODE;
    	//Sensor.settings.chipSelectPin = 10;
    
    
    	//***Operation settings*****************************//
    	
    	//renMode can be:
    	//  0, Sleep mode
    	//  1 or 2, Forced mode
    	//  3, Normal mode
    	Sensor.settings.runMode = 3; //Normal mode
    	
    	//tStandby can be:
    	//  0, 0.5ms
    	//  1, 62.5ms
    	//  2, 125ms
    	//  3, 250ms
    	//  4, 500ms
    	//  5, 1000ms
    	//  6, 10ms
    	//  7, 20ms
    	Sensor.settings.tStandby = 5;
    	
    	//filter can be off or number of FIR coefficients to use:
    	//  0, filter off
    	//  1, coefficients = 2
    	//  2, coefficients = 4
    	//  3, coefficients = 8
    	//  4, coefficients = 16
    	Sensor.settings.filter = 0;
    	
    	//tempOverSample can be:
    	//  0, skipped
    	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
    	Sensor.settings.tempOverSample = 1;
    
    	//pressOverSample can be:
    	//  0, skipped
    	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
        Sensor.settings.pressOverSample = 1;
    	
    	//humidOverSample can be:
    	//  0, skipped
    	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
    	Sensor.settings.humidOverSample = 1;
    	
    //	Serial.begin(57600);
    	Serial.print("Program Started\n");
    	Serial.print("Starting BME280... result of .begin(): 0x");
    	
    	//Calling .begin() causes the settings to be loaded
    	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
    	Serial.println(Sensor.begin(), HEX);
    
    	Serial.print("Displaying ID, reset and ctrl regs\n");
    	
    	Serial.print("ID(0xD0): 0x");
    	Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
    	Serial.print("Reset register(0xE0): 0x");
    	Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
    	Serial.print("ctrl_meas(0xF4): 0x");
    	Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
    	Serial.print("ctrl_hum(0xF2): 0x");
    	Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
    
    	Serial.print("\n\n");
    
    	Serial.print("Displaying all regs\n");
    	uint8_t memCounter = 0x80;
    	uint8_t tempReadData;
    	for(int rowi = 8; rowi < 16; rowi++ )
    	{
    		Serial.print("0x");
    		Serial.print(rowi, HEX);
    		Serial.print("0:");
    		for(int coli = 0; coli < 16; coli++ )
    		{
    			tempReadData = Sensor.readRegister(memCounter);
    			Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
    			Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
    			Serial.print(" ");
    			memCounter++;
    		}
    		Serial.print("\n");
    	}
    	
    	
    	Serial.print("\n\n");
    	
    	Serial.print("Displaying concatenated calibration words\n");
    	Serial.print("dig_T1, uint16: ");
    	Serial.println(Sensor.calibration.dig_T1);
    	Serial.print("dig_T2, int16: ");
    	Serial.println(Sensor.calibration.dig_T2);
    	Serial.print("dig_T3, int16: ");
    	Serial.println(Sensor.calibration.dig_T3);
    	
    	Serial.print("dig_P1, uint16: ");
    	Serial.println(Sensor.calibration.dig_P1);
    	Serial.print("dig_P2, int16: ");
    	Serial.println(Sensor.calibration.dig_P2);
    	Serial.print("dig_P3, int16: ");
    	Serial.println(Sensor.calibration.dig_P3);
    	Serial.print("dig_P4, int16: ");
    	Serial.println(Sensor.calibration.dig_P4);
    	Serial.print("dig_P5, int16: ");
    	Serial.println(Sensor.calibration.dig_P5);
    	Serial.print("dig_P6, int16: ");
    	Serial.println(Sensor.calibration.dig_P6);
    	Serial.print("dig_P7, int16: ");
    	Serial.println(Sensor.calibration.dig_P7);
    	Serial.print("dig_P8, int16: ");
    	Serial.println(Sensor.calibration.dig_P8);
    	Serial.print("dig_P9, int16: ");
    	Serial.println(Sensor.calibration.dig_P9);
    	
    	Serial.print("dig_H1, uint8: ");
    	Serial.println(Sensor.calibration.dig_H1);
    	Serial.print("dig_H2, int16: ");
    	Serial.println(Sensor.calibration.dig_H2);
    	Serial.print("dig_H3, uint8: ");
    	Serial.println(Sensor.calibration.dig_H3);
    	Serial.print("dig_H4, int16: ");
    	Serial.println(Sensor.calibration.dig_H4);
    	Serial.print("dig_H5, int16: ");
    	Serial.println(Sensor.calibration.dig_H5);
    	Serial.print("dig_H6, uint8: ");
    	Serial.println(Sensor.calibration.dig_H6);
    		
    	Serial.println();
    
            pinMode(8,OUTPUT);  //pin8 as output for battcheck
            digitalWrite(8,LOW); //see to that pin is low to save power
            analogReference(INTERNAL);  //internal 1.1V reference for battcheck
    
            
    }
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
    
      // Register binary input sensor to sensor_node (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      present(CHILD_ID_1, S_TEMP);  
      present(CHILD_ID_2, S_HUM);  
      present(CHILD_ID_3, S_BARO);  
    
    }
    
    
    
            double  temperature;
            double  humidity;
            double  pressure;
            double  oldtemperature;
            double  oldhumidity;
            double  oldpressure;
            unsigned char fail;
    
    
    void loop()
    {
    	//Each loop, take a reading.
    	//Start with temperature, as that data is needed for accurate compensation.
    	//Reading the temperature updates the compensators of the other functions
    	//in the background.
    
    /*	Serial.print("Temperature: ");
    	Serial.print(Sensor.readTempC(), 2);
    	Serial.println(" degrees C");
    
    	Serial.print("Temperature: ");
    	Serial.print(Sensor.readTempF(), 2);
    	Serial.println(" degrees F");
    
    	Serial.print("Pressure: ");
    	Serial.print(Sensor.readFloatPressure(), 2);
    	Serial.println(" Pa");
    
    	Serial.print("Altitude: ");
    	Serial.print(Sensor.readFloatAltitudeMeters(), 2);
    	Serial.println("m");
    
    	Serial.print("Altitude: ");
    	Serial.print(Sensor.readFloatAltitudeFeet(), 2);
    	Serial.println("ft");	
    
    	Serial.print("%RH: ");
    	Serial.print(Sensor.readFloatHumidity(), 2);
    	Serial.println(" %");
    	
    	Serial.println();
    	
    	delay(1000);
    */
    
            float  batt;
    
    
            digitalWrite(8,HIGH);
            delay(10);
           	
            batt=analogRead(0);
            batt=batt-900;
            batt=batt/1.23;
           
           
            Serial.print("Batt%: ");
           	Serial.print(batt);
           digitalWrite(8,LOW);
           
            sendBatteryLevel(batt);
           
            temperature=Sensor.readTempC();
            humidity=Sensor.readFloatHumidity();
            pressure=Sensor.readFloatPressure()/100;
    
            if(temperature != oldtemperature){
            
            if(!send(msg1.set(temperature,2))){fail++;};
            oldtemperature=temperature;
            
            }
    
            if(humidity != oldhumidity){
    
            if(!send(msg2.set(humidity,2))){fail++;};
            oldhumidity=humidity;
    
            }
    
            if(pressure != oldpressure){
    
            if(!send(msg3.set(pressure,2))){fail++;};
            oldpressure=pressure;
            }
         
            if (fail>6){fail=0; Serial.print("Transmit error, Reseting!");soft_restart();}
    
            fail=0;
    
         sleep(30000);
    

    What does the message:

    !TSP:SEND:TNR

    mean and how do I handle it?

    mfalkviddM 1 Reply Last reply
    1
    • kk02067K kk02067

      I have a node that is causing problems for me. When I have the node and the gateway in the same room all works fine. But when I move them apart the node stops sending the messages after a random couple of hours. This I think is because of the range. But if I move the node closer to the gatway again it doesn't reconnect. And the debug from the node outputs:

      !TSP:SEND:TNR
      !TSP:SEND:TNR
      !TSP:SEND:TNR
      RF24:write register, reg=0, value=12
      RF24:power down
      

      and repeats until I reset the node.

      It seems that my auto reset of the nod fails also.

      The sketch looks like this:

      #include <SoftReset.h>
      
      /******************************************************************************
      I2C_ReadAllData.ino
      BME280 Arduino and Teensy example
      Marshall Taylor @ SparkFun Electronics
      May 20, 2015
      https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
      
      This sketch configures the BME280 to read all measurements.  The sketch also
      displays the BME280's physical memory and what the driver perceives the
      calibration words to be.
      
      Resources:
      Uses Wire.h for I2C operation
      Uses SPI.h for SPI operation
      
      Development environment specifics:
      Arduino IDE 1.6.4
      Teensy loader 1.23
      
      This code is released under the [MIT License](http://opensource.org/licenses/MIT).
      Please review the LICENSE.md file included with this example. If you have any questions 
      or concerns with licensing, please contact techsupport@sparkfun.com.
      Distributed as-is; no warranty is given.
      ******************************************************************************/
      
      #include <stdint.h>
      #include "SparkFunBME280.h"
      //Library allows either I2C or SPI, so include both.
      #include "Wire.h"
      #include "SPI.h"
      
      #define MY_DEBUG
      #define MY_DEBUG_VERBOSE_RF24
      #define MY_RADIO_NRF24
      #include <MySensors.h>
      
      #define SKETCH_NAME "Min väderstation"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "1"
      #define CHILD_ID_1 1
      #define CHILD_ID_2 2
      #define CHILD_ID_3 3
      
      
      //Global sensor object
      BME280 Sensor;
      
      
      MyMessage msg1(CHILD_ID_1, V_TEMP);
      MyMessage msg2(CHILD_ID_2, V_HUM);
      MyMessage msg3(CHILD_ID_3, V_PRESSURE);
      
      
      void setup()
      {
      	//***Driver settings********************************//
      	//commInterface can be I2C_MODE or SPI_MODE
      	//specify chipSelectPin using arduino pin names
      	//specify I2C address.  Can be 0x77(default) or 0x76
      	
      	//For I2C, enable the following and disable the SPI section
      	Sensor.settings.commInterface = I2C_MODE;
      	Sensor.settings.I2CAddress = 0x76;
      	
      	//For SPI enable the following and dissable the I2C section
      	//Sensor.settings.commInterface = SPI_MODE;
      	//Sensor.settings.chipSelectPin = 10;
      
      
      	//***Operation settings*****************************//
      	
      	//renMode can be:
      	//  0, Sleep mode
      	//  1 or 2, Forced mode
      	//  3, Normal mode
      	Sensor.settings.runMode = 3; //Normal mode
      	
      	//tStandby can be:
      	//  0, 0.5ms
      	//  1, 62.5ms
      	//  2, 125ms
      	//  3, 250ms
      	//  4, 500ms
      	//  5, 1000ms
      	//  6, 10ms
      	//  7, 20ms
      	Sensor.settings.tStandby = 5;
      	
      	//filter can be off or number of FIR coefficients to use:
      	//  0, filter off
      	//  1, coefficients = 2
      	//  2, coefficients = 4
      	//  3, coefficients = 8
      	//  4, coefficients = 16
      	Sensor.settings.filter = 0;
      	
      	//tempOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.tempOverSample = 1;
      
      	//pressOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
          Sensor.settings.pressOverSample = 1;
      	
      	//humidOverSample can be:
      	//  0, skipped
      	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
      	Sensor.settings.humidOverSample = 1;
      	
      //	Serial.begin(57600);
      	Serial.print("Program Started\n");
      	Serial.print("Starting BME280... result of .begin(): 0x");
      	
      	//Calling .begin() causes the settings to be loaded
      	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
      	Serial.println(Sensor.begin(), HEX);
      
      	Serial.print("Displaying ID, reset and ctrl regs\n");
      	
      	Serial.print("ID(0xD0): 0x");
      	Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
      	Serial.print("Reset register(0xE0): 0x");
      	Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
      	Serial.print("ctrl_meas(0xF4): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
      	Serial.print("ctrl_hum(0xF2): 0x");
      	Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
      
      	Serial.print("\n\n");
      
      	Serial.print("Displaying all regs\n");
      	uint8_t memCounter = 0x80;
      	uint8_t tempReadData;
      	for(int rowi = 8; rowi < 16; rowi++ )
      	{
      		Serial.print("0x");
      		Serial.print(rowi, HEX);
      		Serial.print("0:");
      		for(int coli = 0; coli < 16; coli++ )
      		{
      			tempReadData = Sensor.readRegister(memCounter);
      			Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
      			Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
      			Serial.print(" ");
      			memCounter++;
      		}
      		Serial.print("\n");
      	}
      	
      	
      	Serial.print("\n\n");
      	
      	Serial.print("Displaying concatenated calibration words\n");
      	Serial.print("dig_T1, uint16: ");
      	Serial.println(Sensor.calibration.dig_T1);
      	Serial.print("dig_T2, int16: ");
      	Serial.println(Sensor.calibration.dig_T2);
      	Serial.print("dig_T3, int16: ");
      	Serial.println(Sensor.calibration.dig_T3);
      	
      	Serial.print("dig_P1, uint16: ");
      	Serial.println(Sensor.calibration.dig_P1);
      	Serial.print("dig_P2, int16: ");
      	Serial.println(Sensor.calibration.dig_P2);
      	Serial.print("dig_P3, int16: ");
      	Serial.println(Sensor.calibration.dig_P3);
      	Serial.print("dig_P4, int16: ");
      	Serial.println(Sensor.calibration.dig_P4);
      	Serial.print("dig_P5, int16: ");
      	Serial.println(Sensor.calibration.dig_P5);
      	Serial.print("dig_P6, int16: ");
      	Serial.println(Sensor.calibration.dig_P6);
      	Serial.print("dig_P7, int16: ");
      	Serial.println(Sensor.calibration.dig_P7);
      	Serial.print("dig_P8, int16: ");
      	Serial.println(Sensor.calibration.dig_P8);
      	Serial.print("dig_P9, int16: ");
      	Serial.println(Sensor.calibration.dig_P9);
      	
      	Serial.print("dig_H1, uint8: ");
      	Serial.println(Sensor.calibration.dig_H1);
      	Serial.print("dig_H2, int16: ");
      	Serial.println(Sensor.calibration.dig_H2);
      	Serial.print("dig_H3, uint8: ");
      	Serial.println(Sensor.calibration.dig_H3);
      	Serial.print("dig_H4, int16: ");
      	Serial.println(Sensor.calibration.dig_H4);
      	Serial.print("dig_H5, int16: ");
      	Serial.println(Sensor.calibration.dig_H5);
      	Serial.print("dig_H6, uint8: ");
      	Serial.println(Sensor.calibration.dig_H6);
      		
      	Serial.println();
      
              pinMode(8,OUTPUT);  //pin8 as output for battcheck
              digitalWrite(8,LOW); //see to that pin is low to save power
              analogReference(INTERNAL);  //internal 1.1V reference for battcheck
      
              
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
      
        // Register binary input sensor to sensor_node (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        present(CHILD_ID_1, S_TEMP);  
        present(CHILD_ID_2, S_HUM);  
        present(CHILD_ID_3, S_BARO);  
      
      }
      
      
      
              double  temperature;
              double  humidity;
              double  pressure;
              double  oldtemperature;
              double  oldhumidity;
              double  oldpressure;
              unsigned char fail;
      
      
      void loop()
      {
      	//Each loop, take a reading.
      	//Start with temperature, as that data is needed for accurate compensation.
      	//Reading the temperature updates the compensators of the other functions
      	//in the background.
      
      /*	Serial.print("Temperature: ");
      	Serial.print(Sensor.readTempC(), 2);
      	Serial.println(" degrees C");
      
      	Serial.print("Temperature: ");
      	Serial.print(Sensor.readTempF(), 2);
      	Serial.println(" degrees F");
      
      	Serial.print("Pressure: ");
      	Serial.print(Sensor.readFloatPressure(), 2);
      	Serial.println(" Pa");
      
      	Serial.print("Altitude: ");
      	Serial.print(Sensor.readFloatAltitudeMeters(), 2);
      	Serial.println("m");
      
      	Serial.print("Altitude: ");
      	Serial.print(Sensor.readFloatAltitudeFeet(), 2);
      	Serial.println("ft");	
      
      	Serial.print("%RH: ");
      	Serial.print(Sensor.readFloatHumidity(), 2);
      	Serial.println(" %");
      	
      	Serial.println();
      	
      	delay(1000);
      */
      
              float  batt;
      
      
              digitalWrite(8,HIGH);
              delay(10);
             	
              batt=analogRead(0);
              batt=batt-900;
              batt=batt/1.23;
             
             
              Serial.print("Batt%: ");
             	Serial.print(batt);
             digitalWrite(8,LOW);
             
              sendBatteryLevel(batt);
             
              temperature=Sensor.readTempC();
              humidity=Sensor.readFloatHumidity();
              pressure=Sensor.readFloatPressure()/100;
      
              if(temperature != oldtemperature){
              
              if(!send(msg1.set(temperature,2))){fail++;};
              oldtemperature=temperature;
              
              }
      
              if(humidity != oldhumidity){
      
              if(!send(msg2.set(humidity,2))){fail++;};
              oldhumidity=humidity;
      
              }
      
              if(pressure != oldpressure){
      
              if(!send(msg3.set(pressure,2))){fail++;};
              oldpressure=pressure;
              }
           
              if (fail>6){fail=0; Serial.print("Transmit error, Reseting!");soft_restart();}
      
              fail=0;
      
           sleep(30000);
      

      What does the message:

      !TSP:SEND:TNR

      mean and how do I handle it?

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @kk02067 see @tekka's explanation in this post (especially step 7 and 8) https://forum.mysensors.org/topic/4347/can-t-get-sensors-talking/3

      1 Reply Last reply
      0
      • kk02067K Offline
        kk02067K Offline
        kk02067
        wrote on last edited by
        #3

        I have read that thread Before but it doesn't explain what:

        !TSP:SEND:TNR => Transport:SEND:Transport Not Ready

        really means. What has happend and what needs to be done.

        I have corrected my sketch regarding the autoreset of the node. I hope that helps to keep the node communicating.

        #include <SoftReset.h>
        
        /******************************************************************************
        I2C_ReadAllData.ino
        BME280 Arduino and Teensy example
        Marshall Taylor @ SparkFun Electronics
        May 20, 2015
        https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
        
        This sketch configures the BME280 to read all measurements.  The sketch also
        displays the BME280's physical memory and what the driver perceives the
        calibration words to be.
        
        Resources:
        Uses Wire.h for I2C operation
        Uses SPI.h for SPI operation
        
        Development environment specifics:
        Arduino IDE 1.6.4
        Teensy loader 1.23
        
        This code is released under the [MIT License](http://opensource.org/licenses/MIT).
        Please review the LICENSE.md file included with this example. If you have any questions 
        or concerns with licensing, please contact techsupport@sparkfun.com.
        Distributed as-is; no warranty is given.
        ******************************************************************************/
        
        #include <stdint.h>
        #include "SparkFunBME280.h"
        //Library allows either I2C or SPI, so include both.
        #include "Wire.h"
        #include "SPI.h"
        
        #define MY_DEBUG
        #define MY_DEBUG_VERBOSE_RF24
        #define MY_RADIO_NRF24
        #include <MySensors.h>
        
        #define SKETCH_NAME "Min väderstation"
        #define SKETCH_MAJOR_VER "1"
        #define SKETCH_MINOR_VER "1"
        #define CHILD_ID_1 1
        #define CHILD_ID_2 2
        #define CHILD_ID_3 3
        
        
        //Global sensor object
        BME280 Sensor;
        
        
        MyMessage msg1(CHILD_ID_1, V_TEMP);
        MyMessage msg2(CHILD_ID_2, V_HUM);
        MyMessage msg3(CHILD_ID_3, V_PRESSURE);
        
        
        void setup()
        {
        	//***Driver settings********************************//
        	//commInterface can be I2C_MODE or SPI_MODE
        	//specify chipSelectPin using arduino pin names
        	//specify I2C address.  Can be 0x77(default) or 0x76
        	
        	//For I2C, enable the following and disable the SPI section
        	Sensor.settings.commInterface = I2C_MODE;
        	Sensor.settings.I2CAddress = 0x76;
        	
        	//For SPI enable the following and dissable the I2C section
        	//Sensor.settings.commInterface = SPI_MODE;
        	//Sensor.settings.chipSelectPin = 10;
        
        
        	//***Operation settings*****************************//
        	
        	//renMode can be:
        	//  0, Sleep mode
        	//  1 or 2, Forced mode
        	//  3, Normal mode
        	Sensor.settings.runMode = 3; //Normal mode
        	
        	//tStandby can be:
        	//  0, 0.5ms
        	//  1, 62.5ms
        	//  2, 125ms
        	//  3, 250ms
        	//  4, 500ms
        	//  5, 1000ms
        	//  6, 10ms
        	//  7, 20ms
        	Sensor.settings.tStandby = 5;
        	
        	//filter can be off or number of FIR coefficients to use:
        	//  0, filter off
        	//  1, coefficients = 2
        	//  2, coefficients = 4
        	//  3, coefficients = 8
        	//  4, coefficients = 16
        	Sensor.settings.filter = 0;
        	
        	//tempOverSample can be:
        	//  0, skipped
        	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
        	Sensor.settings.tempOverSample = 1;
        
        	//pressOverSample can be:
        	//  0, skipped
        	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
            Sensor.settings.pressOverSample = 1;
        	
        	//humidOverSample can be:
        	//  0, skipped
        	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
        	Sensor.settings.humidOverSample = 1;
        	
        //	Serial.begin(57600);
        	Serial.print("Program Started\n");
        	Serial.print("Starting BME280... result of .begin(): 0x");
        	
        	//Calling .begin() causes the settings to be loaded
        	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
        	Serial.println(Sensor.begin(), HEX);
        
        	Serial.print("Displaying ID, reset and ctrl regs\n");
        	
        	Serial.print("ID(0xD0): 0x");
        	Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
        	Serial.print("Reset register(0xE0): 0x");
        	Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
        	Serial.print("ctrl_meas(0xF4): 0x");
        	Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
        	Serial.print("ctrl_hum(0xF2): 0x");
        	Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
        
        	Serial.print("\n\n");
        
        	Serial.print("Displaying all regs\n");
        	uint8_t memCounter = 0x80;
        	uint8_t tempReadData;
        	for(int rowi = 8; rowi < 16; rowi++ )
        	{
        		Serial.print("0x");
        		Serial.print(rowi, HEX);
        		Serial.print("0:");
        		for(int coli = 0; coli < 16; coli++ )
        		{
        			tempReadData = Sensor.readRegister(memCounter);
        			Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
        			Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
        			Serial.print(" ");
        			memCounter++;
        		}
        		Serial.print("\n");
        	}
        	
        	
        	Serial.print("\n\n");
        	
        	Serial.print("Displaying concatenated calibration words\n");
        	Serial.print("dig_T1, uint16: ");
        	Serial.println(Sensor.calibration.dig_T1);
        	Serial.print("dig_T2, int16: ");
        	Serial.println(Sensor.calibration.dig_T2);
        	Serial.print("dig_T3, int16: ");
        	Serial.println(Sensor.calibration.dig_T3);
        	
        	Serial.print("dig_P1, uint16: ");
        	Serial.println(Sensor.calibration.dig_P1);
        	Serial.print("dig_P2, int16: ");
        	Serial.println(Sensor.calibration.dig_P2);
        	Serial.print("dig_P3, int16: ");
        	Serial.println(Sensor.calibration.dig_P3);
        	Serial.print("dig_P4, int16: ");
        	Serial.println(Sensor.calibration.dig_P4);
        	Serial.print("dig_P5, int16: ");
        	Serial.println(Sensor.calibration.dig_P5);
        	Serial.print("dig_P6, int16: ");
        	Serial.println(Sensor.calibration.dig_P6);
        	Serial.print("dig_P7, int16: ");
        	Serial.println(Sensor.calibration.dig_P7);
        	Serial.print("dig_P8, int16: ");
        	Serial.println(Sensor.calibration.dig_P8);
        	Serial.print("dig_P9, int16: ");
        	Serial.println(Sensor.calibration.dig_P9);
        	
        	Serial.print("dig_H1, uint8: ");
        	Serial.println(Sensor.calibration.dig_H1);
        	Serial.print("dig_H2, int16: ");
        	Serial.println(Sensor.calibration.dig_H2);
        	Serial.print("dig_H3, uint8: ");
        	Serial.println(Sensor.calibration.dig_H3);
        	Serial.print("dig_H4, int16: ");
        	Serial.println(Sensor.calibration.dig_H4);
        	Serial.print("dig_H5, int16: ");
        	Serial.println(Sensor.calibration.dig_H5);
        	Serial.print("dig_H6, uint8: ");
        	Serial.println(Sensor.calibration.dig_H6);
        		
        	Serial.println();
        
                pinMode(8,OUTPUT);  //pin8 as output for battcheck
                digitalWrite(8,LOW); //see to that pin is low to save power
                analogReference(INTERNAL);  //internal 1.1V reference for battcheck
        
                
        }
        
        void presentation() {
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
        
          // Register binary input sensor to sensor_node (they will be created as child devices)
          // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
          // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
          present(CHILD_ID_1, S_TEMP);  
          present(CHILD_ID_2, S_HUM);  
          present(CHILD_ID_3, S_BARO);  
        
        }
        
        
        
                double  temperature;
                double  humidity;
                double  pressure;
                double  oldtemperature;
                double  oldhumidity;
                double  oldpressure;
                unsigned char fail;
        
        
        void loop()
        {
        	//Each loop, take a reading.
        	//Start with temperature, as that data is needed for accurate compensation.
        	//Reading the temperature updates the compensators of the other functions
        	//in the background.
        
        
        
                float  batt;
        
        
                digitalWrite(8,HIGH);
                delay(10);
               	
                batt=analogRead(0);
                batt=batt-900;
                batt=batt/1.23;
               
               
                Serial.print("Batt%: ");
               	Serial.println(batt);
               digitalWrite(8,LOW);
               
                sendBatteryLevel(batt);
               
                temperature=Sensor.readTempC();
                humidity=Sensor.readFloatHumidity();
                pressure=Sensor.readFloatPressure()/100;
        
                if(temperature != oldtemperature){
                
                if(!send(msg1.set(temperature,2))){fail++;}
                  else{ fail=0;}
                oldtemperature=temperature;     
        
                }
        
                if(humidity != oldhumidity){
        
                if(!send(msg2.set(humidity,2))){fail++;}
                  else{ fail=0; }
                oldhumidity=humidity;
                
                }
        
                if(pressure != oldpressure){
        
                if(!send(msg3.set(pressure,2))){fail++;}
                  else{ fail=0; }
                oldpressure=pressure;
                
                }
             
                if (fail>6){fail=0; Serial.print("Transmit error, Reseting!");soft_restart();}
        
                Serial.print("Number of errors before reset: "); Serial.println(fail);
        
             sleep(30000);
        
        }
        
        tekkaT 1 Reply Last reply
        0
        • kk02067K kk02067

          I have read that thread Before but it doesn't explain what:

          !TSP:SEND:TNR => Transport:SEND:Transport Not Ready

          really means. What has happend and what needs to be done.

          I have corrected my sketch regarding the autoreset of the node. I hope that helps to keep the node communicating.

          #include <SoftReset.h>
          
          /******************************************************************************
          I2C_ReadAllData.ino
          BME280 Arduino and Teensy example
          Marshall Taylor @ SparkFun Electronics
          May 20, 2015
          https://github.com/sparkfun/SparkFun_BME280_Arduino_Library
          
          This sketch configures the BME280 to read all measurements.  The sketch also
          displays the BME280's physical memory and what the driver perceives the
          calibration words to be.
          
          Resources:
          Uses Wire.h for I2C operation
          Uses SPI.h for SPI operation
          
          Development environment specifics:
          Arduino IDE 1.6.4
          Teensy loader 1.23
          
          This code is released under the [MIT License](http://opensource.org/licenses/MIT).
          Please review the LICENSE.md file included with this example. If you have any questions 
          or concerns with licensing, please contact techsupport@sparkfun.com.
          Distributed as-is; no warranty is given.
          ******************************************************************************/
          
          #include <stdint.h>
          #include "SparkFunBME280.h"
          //Library allows either I2C or SPI, so include both.
          #include "Wire.h"
          #include "SPI.h"
          
          #define MY_DEBUG
          #define MY_DEBUG_VERBOSE_RF24
          #define MY_RADIO_NRF24
          #include <MySensors.h>
          
          #define SKETCH_NAME "Min väderstation"
          #define SKETCH_MAJOR_VER "1"
          #define SKETCH_MINOR_VER "1"
          #define CHILD_ID_1 1
          #define CHILD_ID_2 2
          #define CHILD_ID_3 3
          
          
          //Global sensor object
          BME280 Sensor;
          
          
          MyMessage msg1(CHILD_ID_1, V_TEMP);
          MyMessage msg2(CHILD_ID_2, V_HUM);
          MyMessage msg3(CHILD_ID_3, V_PRESSURE);
          
          
          void setup()
          {
          	//***Driver settings********************************//
          	//commInterface can be I2C_MODE or SPI_MODE
          	//specify chipSelectPin using arduino pin names
          	//specify I2C address.  Can be 0x77(default) or 0x76
          	
          	//For I2C, enable the following and disable the SPI section
          	Sensor.settings.commInterface = I2C_MODE;
          	Sensor.settings.I2CAddress = 0x76;
          	
          	//For SPI enable the following and dissable the I2C section
          	//Sensor.settings.commInterface = SPI_MODE;
          	//Sensor.settings.chipSelectPin = 10;
          
          
          	//***Operation settings*****************************//
          	
          	//renMode can be:
          	//  0, Sleep mode
          	//  1 or 2, Forced mode
          	//  3, Normal mode
          	Sensor.settings.runMode = 3; //Normal mode
          	
          	//tStandby can be:
          	//  0, 0.5ms
          	//  1, 62.5ms
          	//  2, 125ms
          	//  3, 250ms
          	//  4, 500ms
          	//  5, 1000ms
          	//  6, 10ms
          	//  7, 20ms
          	Sensor.settings.tStandby = 5;
          	
          	//filter can be off or number of FIR coefficients to use:
          	//  0, filter off
          	//  1, coefficients = 2
          	//  2, coefficients = 4
          	//  3, coefficients = 8
          	//  4, coefficients = 16
          	Sensor.settings.filter = 0;
          	
          	//tempOverSample can be:
          	//  0, skipped
          	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
          	Sensor.settings.tempOverSample = 1;
          
          	//pressOverSample can be:
          	//  0, skipped
          	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
              Sensor.settings.pressOverSample = 1;
          	
          	//humidOverSample can be:
          	//  0, skipped
          	//  1 through 5, oversampling *1, *2, *4, *8, *16 respectively
          	Sensor.settings.humidOverSample = 1;
          	
          //	Serial.begin(57600);
          	Serial.print("Program Started\n");
          	Serial.print("Starting BME280... result of .begin(): 0x");
          	
          	//Calling .begin() causes the settings to be loaded
          	delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
          	Serial.println(Sensor.begin(), HEX);
          
          	Serial.print("Displaying ID, reset and ctrl regs\n");
          	
          	Serial.print("ID(0xD0): 0x");
          	Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX);
          	Serial.print("Reset register(0xE0): 0x");
          	Serial.println(Sensor.readRegister(BME280_RST_REG), HEX);
          	Serial.print("ctrl_meas(0xF4): 0x");
          	Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX);
          	Serial.print("ctrl_hum(0xF2): 0x");
          	Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX);
          
          	Serial.print("\n\n");
          
          	Serial.print("Displaying all regs\n");
          	uint8_t memCounter = 0x80;
          	uint8_t tempReadData;
          	for(int rowi = 8; rowi < 16; rowi++ )
          	{
          		Serial.print("0x");
          		Serial.print(rowi, HEX);
          		Serial.print("0:");
          		for(int coli = 0; coli < 16; coli++ )
          		{
          			tempReadData = Sensor.readRegister(memCounter);
          			Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble
          			Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble
          			Serial.print(" ");
          			memCounter++;
          		}
          		Serial.print("\n");
          	}
          	
          	
          	Serial.print("\n\n");
          	
          	Serial.print("Displaying concatenated calibration words\n");
          	Serial.print("dig_T1, uint16: ");
          	Serial.println(Sensor.calibration.dig_T1);
          	Serial.print("dig_T2, int16: ");
          	Serial.println(Sensor.calibration.dig_T2);
          	Serial.print("dig_T3, int16: ");
          	Serial.println(Sensor.calibration.dig_T3);
          	
          	Serial.print("dig_P1, uint16: ");
          	Serial.println(Sensor.calibration.dig_P1);
          	Serial.print("dig_P2, int16: ");
          	Serial.println(Sensor.calibration.dig_P2);
          	Serial.print("dig_P3, int16: ");
          	Serial.println(Sensor.calibration.dig_P3);
          	Serial.print("dig_P4, int16: ");
          	Serial.println(Sensor.calibration.dig_P4);
          	Serial.print("dig_P5, int16: ");
          	Serial.println(Sensor.calibration.dig_P5);
          	Serial.print("dig_P6, int16: ");
          	Serial.println(Sensor.calibration.dig_P6);
          	Serial.print("dig_P7, int16: ");
          	Serial.println(Sensor.calibration.dig_P7);
          	Serial.print("dig_P8, int16: ");
          	Serial.println(Sensor.calibration.dig_P8);
          	Serial.print("dig_P9, int16: ");
          	Serial.println(Sensor.calibration.dig_P9);
          	
          	Serial.print("dig_H1, uint8: ");
          	Serial.println(Sensor.calibration.dig_H1);
          	Serial.print("dig_H2, int16: ");
          	Serial.println(Sensor.calibration.dig_H2);
          	Serial.print("dig_H3, uint8: ");
          	Serial.println(Sensor.calibration.dig_H3);
          	Serial.print("dig_H4, int16: ");
          	Serial.println(Sensor.calibration.dig_H4);
          	Serial.print("dig_H5, int16: ");
          	Serial.println(Sensor.calibration.dig_H5);
          	Serial.print("dig_H6, uint8: ");
          	Serial.println(Sensor.calibration.dig_H6);
          		
          	Serial.println();
          
                  pinMode(8,OUTPUT);  //pin8 as output for battcheck
                  digitalWrite(8,LOW); //see to that pin is low to save power
                  analogReference(INTERNAL);  //internal 1.1V reference for battcheck
          
                  
          }
          
          void presentation() {
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
          
            // Register binary input sensor to sensor_node (they will be created as child devices)
            // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
            // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
            present(CHILD_ID_1, S_TEMP);  
            present(CHILD_ID_2, S_HUM);  
            present(CHILD_ID_3, S_BARO);  
          
          }
          
          
          
                  double  temperature;
                  double  humidity;
                  double  pressure;
                  double  oldtemperature;
                  double  oldhumidity;
                  double  oldpressure;
                  unsigned char fail;
          
          
          void loop()
          {
          	//Each loop, take a reading.
          	//Start with temperature, as that data is needed for accurate compensation.
          	//Reading the temperature updates the compensators of the other functions
          	//in the background.
          
          
          
                  float  batt;
          
          
                  digitalWrite(8,HIGH);
                  delay(10);
                 	
                  batt=analogRead(0);
                  batt=batt-900;
                  batt=batt/1.23;
                 
                 
                  Serial.print("Batt%: ");
                 	Serial.println(batt);
                 digitalWrite(8,LOW);
                 
                  sendBatteryLevel(batt);
                 
                  temperature=Sensor.readTempC();
                  humidity=Sensor.readFloatHumidity();
                  pressure=Sensor.readFloatPressure()/100;
          
                  if(temperature != oldtemperature){
                  
                  if(!send(msg1.set(temperature,2))){fail++;}
                    else{ fail=0;}
                  oldtemperature=temperature;     
          
                  }
          
                  if(humidity != oldhumidity){
          
                  if(!send(msg2.set(humidity,2))){fail++;}
                    else{ fail=0; }
                  oldhumidity=humidity;
                  
                  }
          
                  if(pressure != oldpressure){
          
                  if(!send(msg3.set(pressure,2))){fail++;}
                    else{ fail=0; }
                  oldpressure=pressure;
                  
                  }
               
                  if (fail>6){fail=0; Serial.print("Transmit error, Reseting!");soft_restart();}
          
                  Serial.print("Number of errors before reset: "); Serial.println(fail);
          
               sleep(30000);
          
          }
          
          tekkaT Offline
          tekkaT Offline
          tekka
          Admin
          wrote on last edited by tekka
          #4

          @kk02067 the issue is that you send the node to sleep before the communication is fully re-established. Please post the complete debug log for verification.

          1 Reply Last reply
          0
          • kk02067K Offline
            kk02067K Offline
            kk02067
            wrote on last edited by
            #5

            I'm having trouble to log the node since it is in a remote place when it stops working.

            Can you please explain a little more what you mean with "send the node to sleep before the communication is fully re-established"?

            I'm a bit lost in all this it seems. I must have missed someting when reading about sending new values to the controller. But I thought that when the "send()" is executed the program is waiting here until Everything is finished for that transmission and we can move on to the transmission.

            Is there something I must do before sending the cpu to sleep?

            Sorry for my slow understanding.

            tekkaT 1 Reply Last reply
            1
            • kk02067K kk02067

              I'm having trouble to log the node since it is in a remote place when it stops working.

              Can you please explain a little more what you mean with "send the node to sleep before the communication is fully re-established"?

              I'm a bit lost in all this it seems. I must have missed someting when reading about sending new values to the controller. But I thought that when the "send()" is executed the program is waiting here until Everything is finished for that transmission and we can move on to the transmission.

              Is there something I must do before sending the cpu to sleep?

              Sorry for my slow understanding.

              tekkaT Offline
              tekkaT Offline
              tekka
              Admin
              wrote on last edited by
              #6

              @kk02067 If your node is out of range, all uplink messages will fail and after 5 consecutive uplink fails, the node will search for a new parent and try to (re)establish the link to the GW.
              If you put your node asleep while the link is being established (last line in loop() ), the node won't reconnect. You can prevent this from happening by substituting

              sleep(30000);
              
              

              with

              if(isTransportOK()){
                  sleep(30000);  // transport is OK, node can sleep
                } 
                else {
                  wait(5000); // transport is not operational, allow the transport layer to fix this
                }
              
              mfalkviddM corbinC 2 Replies Last reply
              1
              • tekkaT tekka

                @kk02067 If your node is out of range, all uplink messages will fail and after 5 consecutive uplink fails, the node will search for a new parent and try to (re)establish the link to the GW.
                If you put your node asleep while the link is being established (last line in loop() ), the node won't reconnect. You can prevent this from happening by substituting

                sleep(30000);
                
                

                with

                if(isTransportOK()){
                    sleep(30000);  // transport is OK, node can sleep
                  } 
                  else {
                    wait(5000); // transport is not operational, allow the transport layer to fix this
                  }
                
                mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by
                #7

                @tekka wouldn't it be better if the library handled that automatically? The library is so good at taking care of everything else. Or maybe I'm just getting spoiled :)

                tekkaT 1 Reply Last reply
                1
                • kk02067K Offline
                  kk02067K Offline
                  kk02067
                  wrote on last edited by
                  #8

                  Ok. Will try something like that.

                  Is mysensors libraryfunctions interuptdriven? If so I understand why my sketch fails. Is there a complete list of useful functions besides going thru the sourcecode?

                  Thanks alot for your support.

                  TheoLT tekkaT 2 Replies Last reply
                  0
                  • kk02067K kk02067

                    Ok. Will try something like that.

                    Is mysensors libraryfunctions interuptdriven? If so I understand why my sketch fails. Is there a complete list of useful functions besides going thru the sourcecode?

                    Thanks alot for your support.

                    TheoLT Offline
                    TheoLT Offline
                    TheoL
                    Contest Winner
                    wrote on last edited by
                    #9

                    @kk02067 Haven't played with 2.0 yet. But looked at the Api which doesn't say what the return value of msg means. In your code you presume that the return values of msg states the success of sending the message. I'm however not sure whether msg() is a blocking call. Meaning that the message is immediately send when you call send. It might be queued until MySensors is ready to handle the sending of messages. And in that case it just can't predict whether it might be able to send a msg in the future. If it could, I'd hire the engineer who developed that algorithm. He'd probably make me rich in no time ;-)

                    If msg is a non-blocking call, than determining whether the msg was successfully by MySensors, by checking the return value of the call to msg doesn't make sense. And you actually disturb the whole resend and connect mechanism by doing a soft restart after 6 consecutive fails.

                    But then again haven't played with it. But thought this might help. I think I'd would first try to improve the sending range and try to find out what the cause is. Because it might be a hardware problem. And if you can tackle it, it might solve all of your problems.

                    1 Reply Last reply
                    0
                    • kk02067K Offline
                      kk02067K Offline
                      kk02067
                      wrote on last edited by
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • kk02067K kk02067

                        Ok. Will try something like that.

                        Is mysensors libraryfunctions interuptdriven? If so I understand why my sketch fails. Is there a complete list of useful functions besides going thru the sourcecode?

                        Thanks alot for your support.

                        tekkaT Offline
                        tekkaT Offline
                        tekka
                        Admin
                        wrote on last edited by
                        #11

                        @kk02067 As @TheoL pointed out, there is no need to reset the node after 6 failed messages, the transport layer takes care of that:

                        • After 5 consecutive uplink fails, the node search for a new parent (with an established GW-link)
                        • After 3 unsuccessful find parent attempts, the radio is re-initialised.

                        Send() returns true if the message was successfully delivered to the next (i.e. parent node), however, this does not imply that the GW/controller received the message.

                        kk02067K 1 Reply Last reply
                        0
                        • tekkaT tekka

                          @kk02067 As @TheoL pointed out, there is no need to reset the node after 6 failed messages, the transport layer takes care of that:

                          • After 5 consecutive uplink fails, the node search for a new parent (with an established GW-link)
                          • After 3 unsuccessful find parent attempts, the radio is re-initialised.

                          Send() returns true if the message was successfully delivered to the next (i.e. parent node), however, this does not imply that the GW/controller received the message.

                          kk02067K Offline
                          kk02067K Offline
                          kk02067
                          wrote on last edited by
                          #12

                          @tekka Thanks for the info, I will now rework the sketch after this new information.

                          My understanding of the library grows with every question.

                          This is so fun. So much to build, so little time.

                          tekkaT 1 Reply Last reply
                          0
                          • kk02067K kk02067

                            @tekka Thanks for the info, I will now rework the sketch after this new information.

                            My understanding of the library grows with every question.

                            This is so fun. So much to build, so little time.

                            tekkaT Offline
                            tekkaT Offline
                            tekka
                            Admin
                            wrote on last edited by
                            #13

                            @kk02067 Welcome to the club :) Too little time...

                            1 Reply Last reply
                            0
                            • mfalkviddM mfalkvidd

                              @tekka wouldn't it be better if the library handled that automatically? The library is so good at taking care of everything else. Or maybe I'm just getting spoiled :)

                              tekkaT Offline
                              tekkaT Offline
                              tekka
                              Admin
                              wrote on last edited by
                              #14

                              @mfalkvidd Yes, you are spoiled :stuck_out_tongue: - I already implemented that after reading a few comments, just have to push the PR.

                              1 Reply Last reply
                              1
                              • kk02067K Offline
                                kk02067K Offline
                                kk02067
                                wrote on last edited by
                                #15

                                I have now implemented the changes discussed here. It now seems to work flawlessly. I tested the node to see its behaviour when i powered down the gateway. As it said in the thread the node tried to reconnect after a couple of failed transmissions. And when I powered up the gateway again the node reconnected and started to go to sleep again.

                                Thanks for the help on this.

                                A Quick question a bit of topic Before I go build new nodes. If I want to run the cpu at only 1 MHz, do I have to do something else other then define the cpu frequency in the sketch? Is it possible to set the cpuclk prescaler at runtime?

                                TheoLT 1 Reply Last reply
                                2
                                • kk02067K kk02067

                                  I have now implemented the changes discussed here. It now seems to work flawlessly. I tested the node to see its behaviour when i powered down the gateway. As it said in the thread the node tried to reconnect after a couple of failed transmissions. And when I powered up the gateway again the node reconnected and started to go to sleep again.

                                  Thanks for the help on this.

                                  A Quick question a bit of topic Before I go build new nodes. If I want to run the cpu at only 1 MHz, do I have to do something else other then define the cpu frequency in the sketch? Is it possible to set the cpuclk prescaler at runtime?

                                  TheoLT Offline
                                  TheoLT Offline
                                  TheoL
                                  Contest Winner
                                  wrote on last edited by
                                  #16

                                  @kk02067 if I remember correctly, the example Sensebender sketch (MS 1.5) switches between 8mHz to 1Mhz 1. And there was a reason for that, which I can't remember. You could look at that sketch. Hope it helps you.

                                  1 Reply Last reply
                                  1
                                  • tekkaT tekka

                                    @kk02067 If your node is out of range, all uplink messages will fail and after 5 consecutive uplink fails, the node will search for a new parent and try to (re)establish the link to the GW.
                                    If you put your node asleep while the link is being established (last line in loop() ), the node won't reconnect. You can prevent this from happening by substituting

                                    sleep(30000);
                                    
                                    

                                    with

                                    if(isTransportOK()){
                                        sleep(30000);  // transport is OK, node can sleep
                                      } 
                                      else {
                                        wait(5000); // transport is not operational, allow the transport layer to fix this
                                      }
                                    
                                    corbinC Offline
                                    corbinC Offline
                                    corbin
                                    wrote on last edited by
                                    #17

                                    @tekka said:

                                    if(isTransportOK()){
                                        sleep(30000);  // transport is OK, node can sleep
                                      } 
                                      else {
                                        wait(5000); // transport is not operational, allow the transport layer to fix this
                                      }
                                    

                                    I've only just found this post, and these lines of code have me excited! fixes my problem, thank you!

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


                                    6

                                    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