Navigation

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

    Technovation

    @Technovation

    43
    Reputation
    18
    Posts
    654
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Technovation Follow

    Best posts made by Technovation

    • nRF24Doctor

      Inspired by the connection quality meter found here: https://forum.mysensors.org/topic/3984/nrf24l01-connection-quality-meter
      I had an attempt on building an extended version. My goal with this device was to be able to diagnose many different nRF24 related topics, like a real doctor ;-).

      Goals:

      1. Check if nRF24 module is dead
      2. Qualify current consumption of different nRF24 modules in both standby and sleep (as some clones appear to have high current consumption during sleep)
      3. Evaluate “performance” (e.g. range) of different nRF24 modules
      4. Find the best settings in nRF24 Channel (Frequency Band), Power Level and Data Rate
      5. Diagnose transmission delays
      6. Determine the best location for your gateway
      7. Determine reception range, reception dead spots and new locations for a secondary gateway or repeater nodes => Portability
      8. …

      Hardware realization:

      • list itemAn Arduino Nano
      • 16x2 Character LCD
      • 2 Buttons
      • 2 Mosfets (e.g. IRLZ44 or comparable. Must be VGS logic level and preferably in a big package (e.g. TO-220) as smd mosfets will have a (too) high RDS(ON) and will impact your current measurement (especially for the 2.2Ohm).
      • 3 Resistors (2.2Ohm, 100Ohm, 10kOhm)
      • Some wire, socket for the radio and hot glue.
        0_1522176659192_Prototype.png

      Features:

      1. On the top you can swap the radio’s with the common 8-pin interface.
      2. On the left is the USB connector to power it from a Powerbank for Portability (and of course to re-program the device if necessary)
      3. The central LCD screen…to provide the necessary feedback to the user.
      4. White button 1:
        a. Short Click: To accept changes made in a menu and continue to the next menu
        b. Long Press: To Escape without storing changes to EEPROM and Return to main menu window
      5. Orange button 2:
        a. Short Click or Hold: To Change setting in a menu.

      So what it can do so far is probably best demonstrated by showing the available menu’s:

      1. Start Up Screen
      0_1522176852484_LCD1.png
      It attempts to connect to your Gateway with the settings stored in its EEPROM (Channel, Data rate, PA-Level and Base Radio ID).

      2. Main Quality Connection Overview
      0_1522176937722_LCD2.png

      • First Line: Parent Node (P0) = Gateway and the number of transmitted messages by the nRF24 Doctor node which FAIL to acknowledge the first HOP transmit (if no repeater nodes are present, then the first HOP will be the Gateway).
      • Second Line: The set Destination Node (D?) and the number of transmitted messages by the nRF24 Doctor node which did NOT receive an Acknowledge back from the Destination Node.

      3. Acknowledge Delay Overview
      0_1522177012096_LCD3.png

      • First Line: Max. delta time (of last 10 messages) between the transmit and accompanying acknowledge in [ms] for the first HOP.
      • Second Line: Max. delta time (of last 10 messages) between the transmit and accompanying acknowledge in [ms] from the Destination Node (=full round trip).

      4. Total of Transmitted Messages
      0_1522177227838_LCD4.png

      • First Line: Average current consumption of the nRF24 Radio during Standby
      • Second Line: Average current consumption of the nRF24 Radio during Sleep.
      • Notes:
        • Units will scale accordingly to [mA] or [uA].
        • Requires Current Measurement circuitry to be added.
          0_1522177341326_Circuit.PNG

      6. Reset Buffers & Counters
      0_1522177371682_LCD6.png

      • If Confirmed it clears the Message Count (Menu 4) and the counters from the Main Quality Connection Overview (Menu 2)

      Next menu items will configure the Radio.
      Note that these settings are only stored to EEPROM when completing all the following step up to and including step 13. Once stored in EEPROM they will be used to configure the radio on the next (automatic) reboot of the node.
      Also note that settings like the Channel, DataRate must match between Node and Gateway for communication to be successful. To facilitate in this I made a modified nRF24DoctorGateway.ino, which receives the required changes (Channel, DataRate and Gateway PA-Level) from the node and will automatically change them when an update request from the nRF24 Doctor Node is received. This gateway configuration is mainly intended for diagnostics. If for some reason you loose the connection to this gateway you can either check in the monitor window the currently used radio settings (will be printed at regular intervals), or by restarting the gateway it will reset itself to the default radio configuration.

      7. Set Destination Node
      0_1522177576346_LCD7.png

      • Select the destination node for your message (0…255). Typically this is 0 for the gateway.

      8. Set RF24 CHANNEL
      0_1522177605684_LCD8.png

      • Select a different RF24 Channel (0…125) without the need to re-compile & upload. This can be helpful in testing which frequency band (Channel number) gives you the best reception at your location.

      9. Set Node Power Amplification Level
      0_1522177641236_LCD9.png

      • Select the PA level of the Node (MIN, LOW,HIGH or MAX).

      10. Set Gateway Power Amplification Level
      0_1522177670198_LCD10.png

      • Select the PA level of the Gateway (MIN, LOW,HIGH or MAX).

      11. Set Data Rate
      0_1522177709724_LCD11.png

      • Select the Data Rate of the Node & Gateway (250KBPS, 1MBPS & 2MBPS ).

      12. Set Base Radio ID
      0_1522177765906_LCD12.png

      • list itemSelect the Base Radio ID of your network. If you have multiple Base Radio ID’s at your home (i.e. multiple gateways) you can add your Base Radio ID’s before compilation of the code and then directly select them from this menu (this will not be updated to the nRF24DoctorGateway).

      13. Update Gateway
      0_1522177811962_LCD13.png

      • No: If you only want to update the settings of the nRF24Doctor Node and NOT the Gateway
      • YES: If you want to update the settings for both the Node and Gateway. The node will send out a request to the gateway to update the Channel, Data Rate and PA_Level of the Gateway. The nRF24Doctor Node will wait for an acknowledge and once received will reboot with the new radio settings and show the start-up screen (1) again.
        0_1522177889094_LCD13_1.png
        If the nRF24Doctor node does not receive the acknowledge from the gateway, it will prompt with the following menu:
        0_1522177905984_LCD13_2.png
        This will give you the options to:
      • RETRY GATEWAY: Send the update request again to the gateway.
      • CANCEL ALL: None of the settings will be applied to the node and gateway
      • SKIP GATEWAY: All Node settings will be applied, but the gateway will not be updated.
      posted in My Project
      Technovation
      Technovation
    • Sonoff Basic Wifi Gateway for NRF24

      INTRODUCTION
      I recently bought some Sonoff Basic switches and was thinking how I could get the most out of its potential. As the Sonoff is mains powered and does not go to sleep, it is the ideal candidate to act as a (secondary) MySensors gateway or repeater for those remote battery powered nodes which have poor reception.
      My first starting point was the MySensors website showing the Sonoff Relay. This page describes how to enable the Sonoff Relay in the MySensors framework as an ethernet gateway, but it does show how to enable it as a gateway or repeater for other MySensor nodes by for instance adding a NRF24 radio (the code example is already prepared, but there are conflicting pins as the GPIO used by the Sonoff overlaps with that of the MISO line for the radio).

      As I did not find anyone else who had yet described this "hack" I thought I would give it a go.
      0_1499618261403_SonoffBasic_NRF24.jpg

      Wiring Things Up
      As the Sonoff Basic is based on the ESP8266 we only need to locate the correct pinning of the HSPI to which we can connect the radio. Unfortunately the MISO line in the Sonoff is used to switch the relay and the default CSN/CS line can only be reached on the ESP8266 package.

      So an overview of the SPI lines on the Sonoff:
      0_1499612567633_Pinning1.png

      Possible Solutions:

      • The CSN/CS line can be remapped to any other available GPIO pin. An easily available GPIO is GPIO0 connected to the button. Note that the button can still be used to get the Sonoff into programming mode, but can no longer be used to switch the relay or as inclusion button. Other options could be the RX or TX pins on the programming header.
      • The MISO line is no problem if you have no need for the relay and you can simply remove resistor R19. If you do need the relay, then you either have to solder a wire directly to the ESP8266 or use one of the RX/TX pins on the programming header.

      I choose the option to directly solder to the ESP8266 package and did not test the option of using the RX and TX pins on the programming header as I wanted to keep them available for debugging purposes at this moment in time.

      Tested wiring in detail
      0_1499616019924_Capture1.JPG
      0_1499616025431_Capture2.JPG 0_1499616030203_Capture3.JPG

      Sketch adaptations
      I used the Sonoff Relay example on the MySensors website as a default and changed the following parts:

      • Enabled the radio: #define MY_RADIO_NRF24
      • Disabled the Inclusion mode feature: //#define MY_INCLUSION_MODE_FEATURE
      • Disabled the LED indicators:
        //#define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin
        //#define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin
        //#define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED
      • Remapped the SPI CE pin: #define MY_RF24_CE_PIN 0 //Using the button GPIO-0 as CE for the nRF24 radio
      • Remapped the Relay pin: #define RELAY_PIN 4 // Using pin16 on ESP8266 (=GPIO-4) to control the Relay
      • Removed the button related stuff
      • Removed the LED related stuff (e.g. blink)
      • Empty the void loop (as we no longer trigger the relay with the button)

      Additional Tests

      • The node was also tested with soft signing and works correctly. For soft signing you need the unconnected analog pin which is:
        #define MY_SIGNING_SOFT_RANDOMSEED_PIN A0 //!< Unconnected analog pin for random seed
      posted in Hardware
      Technovation
      Technovation
    • Software ack reponse too quick on nRF24

      MySensors Version: 2.2.0
      Hardware:

      • STM32 BluePill @72MHz (Serial) Gateway + any type of node
      • nRF24 radios

      What I'm doing: Bench marking different gateways (currently a STM32 Serial & Ehternet MQTT)

      Problem Encountered: Sending loads of messages from the node to the gateway. Each message send from the node requests an ack'd from the gateway.

      • When I Enable #define MY_DEBUG in the sketch everything works flawlessly and high message rates can be achieved without any loss of hardware (the automatic one from the nRF24 radio) or software acknowledge from the gateway.
      • When I Remove #define MY_DEBUG in the sketch I suddenly have loads of messages which do not appear to receive a hardware or software acknowledge from the gateway.

      Expected Cause:

      • It appears that the automatic hardware ack from the gateway radio gets too little time to complete due to the requested software acknowledge to be transmitted. I.e. without the additional debug messages (=delay) present in the code a high clock speed microcontroller (like the STM32) is too fast in pushing a software ack to the radio before it can properly complete the hardware ack message.

      According to the nRF24 datasheet (section 7.9) there must at least be 130us between the completion of the transmitted message and the hardware ack. response. On top of the 130us we also need some time to transmit the actual ack message. This total time must at < ARD (Auto Retransmit Delay), which is configures to be 1500us for MySensors.

      So in MyTransport.cpp in transportProcessMessage just before the (void)transportSendRoute(_msgTmp) I added a delay of 1500uS and it all worked reliably again (successful hardware and software ack's and significant reduction of auto re-transmits of 16 times). This delay can actually be smaller than the 1500us as there is of course some time consumed by all the other tasks (still appeared to work properly with only 150us).

      posted in Bug Reports
      Technovation
      Technovation
    • RE: nRF24Doctor

      My post was hitting the constraints of the Forum, so I had to cut it up into pieces...

      PART2: The sketch for the nRF24DoctorNode:

      /*
        PROJECT: 		MySensors nRF24 Doctor
        PROGRAMMER: 	Technovation (based on the work of AWI and Heizelmann)
        DATE: 		2018March27
        FILE: 		nRF24DoctorNode.ino
      
        Hardware: 	ATMega328p board
        MySensorsAPI: 2.2.0
      
        Summary:  	a portable nRF24 Radio Doctor to diagnose module performance
      
        Change log:
      	2018/03/27	New Release, based on: https://forum.mysensors.org/topic/3984/nrf24l01-connection-quality-meter
      */
      
      //**** CONNECTIONS *****
      #define BUTTON1_PIN A0
      #define BUTTON2_PIN A1
      #define MOSFET_2P2OHM_PIN A2
      #define MOSFET_100OHM_PIN A3
      #define CURRENT_PIN A5
      
      //**** DEBUG *****
      #define LOCAL_DEBUG
      
      #ifdef LOCAL_DEBUG
      #define Sprint(a) (Serial.print(a))           	// macro as substitute for print, enable if no print wanted
      #define Sprintln(a) (Serial.println(a))         
      #else											// macro for "no" debug print
      #define Sprint(a)                   			
      #define Sprintln(a)                   			
      #endif
      
      //**** MySensors *****
      //#define MY_DEBUG							// Enable debug prints to serial monitor
      #define MY_TRANSPORT_WAIT_READY_MS 10 		// [ms] Init timeout for gateway not reachable
      #define MY_NODE_ID 250						// Set a high node ID, which typically will not yet be used in the network
      #define MY_PARENT_NODE_IS_STATIC			// Fixed parent Node ID, else MySensors Transport will attempt automatic fix after successive failures...but we don't want that while diagnosing our connection
      #define MY_PARENT_NODE_ID 0              	// Typically 0 for Gateway
      
      #define DESTINATION_NODE 0                	// Default 0 = gateway, Settable in Menu
      #define MY_BAUD_RATE 115200
      
      //**** MySensors - Radio *****
      #define MY_RADIO_NRF24                  	// Enable and select radio type attached
      
      #include <SPI.h>
      #include <MySensors.h>
      //#include <LiquidCrystal_I2C.h>                // LCD display with I2C interface
      #include <LiquidCrystal.h>                      // LCD display with parallel interface
      #include <OneButton.h> 							//from https://github.com/mathertel/OneButton/blob/master/examples/TwoButtons/TwoButtons.ino
      
      //**** LCD *****
      #define LCD_COLS 16
      #define LCD_ROWS 2
      //LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  	// Set the LCD I2C address
      //LiquidCrystal_I2C lcd(0x27, 16, 2);  								// Set the LCD I2C address
      LiquidCrystal lcd(8, 7, 6, 5, 4, 3); 								// LCD with parallel interface
      
      //**** BUTTONS *****
      OneButton button1(BUTTON1_PIN, true); //PullUp, Activelow
      OneButton button2(BUTTON2_PIN, true); //PullUp, Activelow
      
      //**** EEPROM STORAGE LOCATIONS *****
      #define EEPROM_FLAG 0
      #define EEPROM_CHANNEL 1
      #define EEPROM_PA_LEVEL 2
      #define EEPROM_PA_LEVEL_GW 3
      #define EEPROM_DATARATE 4
      #define EEPROM_BASE_RADIO_ID 5
      #define EEPROM_DESTINATION_NODE 6
      #define EEPROM_SEND_REPEATS 7
      
      //**** MySensors Messages ****
      #define CHILD_ID_COUNTER 0
      #define CHILD_ID_UPDATE_GATEWAY 0
      MyMessage MsgCounter(CHILD_ID_COUNTER, V_CUSTOM);   				//Send Message Counter value
      MyMessage MsgUpdateGateway(CHILD_ID_UPDATE_GATEWAY, V_CUSTOM);   	//Send value for Gateway settings: xxxyz (xxx = Channel, y = PaLevel, z = DataRate)
      #define DELAY_BETWEEN_MESSAGES_MICROS 500000						//Normal Interval between messages
      
      //**** Monitoring Constants&Variables ****
      const int iMaxNumberOfMessages = 100 ;           					// Number of Messages Used for MA calculation
      boolean bArrayFailedMessages[iMaxNumberOfMessages] = { 0 };     	// Array for moving average storage
      boolean bArrayNAckMessages[iMaxNumberOfMessages] = { 0 };			// Array for moving average storage
      uint16_t iNrFailedMessages = 0;            							// total of Failed Messages
      uint16_t iNrNAckMessages = 0;              							// total of Not Acknowledged Messages
      uint16_t iMessageCounter = 0;
      
      //**** LCD MENU Constants&Variables ****
      enum mode {STATE_RUN, STATE_RUN2, STATE_RUN3, STATE_CURLEVEL, STATE_SET_RESET, STATE_SET_DESTINATION_NODE, STATE_SET_CHANNEL, STATE_SET_BASE_RADIO_ID, STATE_SET_PALEVEL, STATE_SET_PALEVEL_GW, STATE_SET_DATARATE, STATE_ASK_GATEWAY, STATE_UPDATE_GATEWAY };
      mode opState = STATE_RUN;											// Default Mode
      boolean bDspRefresh = true;
      
      //nRF24 Settings
      const uint8_t iNrPaLevels = 4;
      const char *pcPaLevelNames[iNrPaLevels] 		= { "MIN", "LOW", "HIGH", "MAX" };
      const uint8_t iNrDataRates = 3;
      const char *pcDataRateNames[iNrDataRates] 		= { "1MBPS", "2MBPS" , "250KBPS"};
      
      //Define your available RF24_BASE_ID 
      const uint8_t iNrBaseRadioIds = 4;
      uint8_t RF24_BASE_ID_VAR[MY_RF24_ADDR_WIDTH]				= { 0x00,0xFC,0xE1,0xA8,0xA8 };		//Used to Store the active BASE_ID
      const uint8_t RF24_BASE_ID_VAR1[MY_RF24_ADDR_WIDTH] 		= { 0x00,0xFC,0xE1,0xA8,0xA8 };
      const uint8_t RF24_BASE_ID_VAR2[MY_RF24_ADDR_WIDTH] 		= { 0x00,0xA1,0xF3,0x09,0xB6 };
      const uint8_t RF24_BASE_ID_VAR3[MY_RF24_ADDR_WIDTH] 		= { 0x00,0xAA,0xA5,0xC4,0xD9 };
      const uint8_t RF24_BASE_ID_VAR4[MY_RF24_ADDR_WIDTH] 		= { 0x00,0xB1,0x47,0xEE,0x82 };
      
      //Load Default Radio values
      uint8_t iRf24Channel 		= MY_RF24_CHANNEL;
      uint8_t iRf24PaLevel 		= MY_RF24_PA_LEVEL;		//PA Level for the Node
      uint8_t iRf24PaLevelGw 		= MY_RF24_PA_LEVEL;		//PA Level for the Gateway
      uint8_t iRf24DataRate 		= MY_RF24_DATARATE;
      uint8_t iRf24BaseRadioId 	= 1;
      uint8_t iDestinationNode	= DESTINATION_NODE;
      
      //**** Timing ****
      const uint8_t iNrTimeDelays = 10;
      uint16_t iMessageIndexBuffer[iNrTimeDelays]={0};
      unsigned long lTimeOfTransmit_us[iNrTimeDelays]={0};
      unsigned long lTimeDelayBuffer_Destination_us[iNrTimeDelays]={0};
      unsigned long lTimeDelayBuffer_FirstHop_us[iNrTimeDelays]={0};
      uint16_t iMeanDelayFirstHop_ms = 0;
      uint16_t iMaxDelayFirstHop_ms = 0;
      uint16_t iMeanDelayDestination_ms = 0;
      uint16_t iMaxDelayDestination_ms = 0;
      
      //**** Current Measurement ****
      const uint8_t iNrCurrentMeasurements 	= 10;	//Nr of measurements for averaging
      uint8_t iPowerMode 		= 0;
      const uint8_t iNrPowerModes = 2;
      const char *pcPowerModeNames[iNrPowerModes] = { "SLEEP", "STANDBY" };
      
      const float uAperBit1 	= 488.2813;	//uAperBit = ((Vref/1024)/R1)*1e6 = ((1.1/1024)/2.2)*1e6				
      const float uAperBit2	= 10.74219;	//uAperBit = ((Vref/1024)/R2)*1e6 = ((1.1/1024)/100)*1e6
      const float uAperBit3 	= 0.107422;	//uAperBit = ((Vref/1024)/R3)*1e6 = ((1.1/1024)/10000)*1e6
      float SleepCurrent_uA 	= 0;
      float StandbyCurrent_uA = 0;
      
      //**** Remote Gateway Update ****
      uint8_t iRetryGateway 	= 0;
      bool bUpdateGateway 	= 0;
      bool bAckGatewayUpdate 	= 0;
      const uint8_t iNrGatwayRetryOptions = 3;
      const char *pcGatewayRetryNames[iNrGatwayRetryOptions] 		= { "SKIP GATEWAY", "RETRY GATEWAY" , "CANCEL ALL"};
      
      
      /*****************************************************************************/
      /************************************ STARTUP ********************************/
      /*****************************************************************************/
      void before() {						//Initialization before the MySensors library starts up
      	pinMode(CURRENT_PIN, INPUT);	//Analog Input for Current Usage Pin
      	pinMode(MOSFET_2P2OHM_PIN,OUTPUT);
      	pinMode(MOSFET_100OHM_PIN,OUTPUT);
      	digitalWrite(MOSFET_2P2OHM_PIN,HIGH);
      	analogReference(INTERNAL);
      
      	//****  LCD *****
      	//  Wire.begin();  // I2C
      	lcd.begin(LCD_COLS, LCD_ROWS);
      	//lcd.setBacklight(HIGH);
      
      	//****  BUTTON STATES *****
      	button1.attachClick(onButton1Pressed);
      	button1.attachLongPressStart(onButton1LongPressed);
      	button2.attachClick(onButton2Pressed);
      	button2.attachDuringLongPress(onButton2Hold);
      
      	//****  RELOAD SETTINGS FROM EEPROM *****
      	if (loadState(EEPROM_FLAG) == 0xFF) {
      		//RELOAD SETTINGS 
      		LoadStatesFromEEPROM();
      		switch (iRf24BaseRadioId) {
      			case 1:
      				memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR1,sizeof(RF24_BASE_ID_VAR));
      				break;
      			case 2:
      				memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR2,sizeof(RF24_BASE_ID_VAR));
      				break;				
      			case 3:
      				memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR3,sizeof(RF24_BASE_ID_VAR));
      				break;
      			case 4:
      				memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR4,sizeof(RF24_BASE_ID_VAR));
      				break;
      		}		
      	} else {
      		//LOAD DEFAULT IN CASE OF CLEAN EEPROM
      		saveState(EEPROM_FLAG, 0xFF);
      		SaveStatesToEEPROM();
      	}
      }
      
      void setup() {
      	loadNewRadioSettings();	//Load the Radio Settings as they are stored in EEPROM
      }
      
      void presentation() {
      	sendSketchInfo("nRF24_Doctor_N250", "1.0");
      	present(CHILD_ID_COUNTER, S_CUSTOM) ;  // "CUSTOM" counter
      }
      
      /*****************************************************************************/
      /*********************************** MAIN LOOP *******************************/
      /*****************************************************************************/
      void loop() {
      	
      	/************ Update Button State ************/
      	ButtonTick();
      
      	/************ Update LCD ************/
      	if (bDspRefresh) LCD_local_display();	
      	
      	/************ PROCESS DIFFERENT OPERATIONAL STATES ************/
      	// RUN, RUN2,RUN3: Are all similar with respect to processing, but show different results on the LCD
      	static unsigned long lLastTransmit = 0;
      	switch (opState) {
      		case STATE_RUN: case STATE_RUN2: case STATE_RUN3:{
      			// Transmit Message
      			transmit();	
      			lLastTransmit = micros();			
      
      			getMeanAndMaxFromArray(&iMeanDelayFirstHop_ms,&iMaxDelayFirstHop_ms,lTimeDelayBuffer_FirstHop_us,iNrTimeDelays);
      			getMeanAndMaxFromArray(&iMeanDelayDestination_ms,&iMaxDelayDestination_ms,lTimeDelayBuffer_Destination_us,iNrTimeDelays);
      
      			bDspRefresh = true;
      			break;
      		}
      		case STATE_CURLEVEL:{
      			//First round: Measure 10x Current in "Standby Mode", then do the same for "Sleep mode"			
      			iPowerMode = !iPowerMode;			//Toggle between modes: "Standby" & "Sleep"
      			if (iPowerMode == 1){			//Mode: Standby
      				transmit();
      				lLastTransmit = micros();
      				wait(50);
      				StandbyCurrent_uA = uAperBit1*GetAvgADCBits(iNrCurrentMeasurements);
      			}
      			else{							//Mode: Sleep
      				transportDisable();
      				SleepCurrent_uA = uAperBit1*GetAvgADCBits(iNrCurrentMeasurements);
      				if (SleepCurrent_uA < 10000){
      					//Set Higher Sensitivity: uAperBit2
      					digitalWrite(MOSFET_2P2OHM_PIN,LOW);
      					digitalWrite(MOSFET_100OHM_PIN,HIGH);
      					SleepCurrent_uA = uAperBit2*GetAvgADCBits(iNrCurrentMeasurements);
      				}
      				if (SleepCurrent_uA < 100){
      					//Set Higher Sensitivity: uAperBit3
      					digitalWrite(MOSFET_2P2OHM_PIN,LOW);
      					digitalWrite(MOSFET_100OHM_PIN,LOW);
      					SleepCurrent_uA = uAperBit3*GetAvgADCBits(iNrCurrentMeasurements);
      
      				}				
      				//Restore standby power state
      				digitalWrite(MOSFET_2P2OHM_PIN,HIGH);	//Enable 2.2Ohm
      				digitalWrite(MOSFET_100OHM_PIN,LOW);
      				transportStandBy();transmit();lLastTransmit = micros();
      			}
      			bDspRefresh = true;
      			break;
      		}		
      		default:{
      			lLastTransmit = micros()-DELAY_BETWEEN_MESSAGES_MICROS;
      			wait(25); // To limit LCD update rate
      			break;
      		}	
      	}
      	
      	//Wait before sending next message
      	while ((micros()- lLastTransmit) < DELAY_BETWEEN_MESSAGES_MICROS){// wait for things to settle and ack's to arrive
      		wait(1);
      		ButtonTick();	//Check for button changes....we must keep responsive
      	}
      }
      
      /*****************************************************************************/
      /************************ RECEIVE & TRANSMIT FUNCTIONS ***********************/
      /*****************************************************************************/
      void receive(const MyMessage &message) {
      	if (message.isAck() == 1 && message.type == V_CUSTOM && message.sensor==CHILD_ID_COUNTER){	//Acknowledge message & of correct type
      		uint16_t iNewMessage = message.getUInt();           // get received value
      		uint16_t iIndexInArray = iNewMessage % iMaxNumberOfMessages;
      		bArrayNAckMessages[iIndexInArray] = 0; 			// set corresponding flag to received.
      		
      		//Check Message (Round trip) Delay
      		uint8_t iIndexInTimeArray = IndexOfValueInArray(iNewMessage, iMessageIndexBuffer, iNrTimeDelays); //Look-up if message is present in MessageIndexBuffer for delay calculation
      		if ((iIndexInTimeArray >=0) && iIndexInTimeArray <=iNrTimeDelays){
      			lTimeDelayBuffer_Destination_us[iIndexInTimeArray] = micros()-lTimeOfTransmit_us[iIndexInTimeArray];
      		}
      		iNrNAckMessages--;	//Received an Acknowledge Message (so one less No Ack)
      	}
      	
      	//Gateway Update Acknowledge - if we have received this we can "safely" apply the new settings to this node
      	if (message.isAck() == 1 && message.type == V_CUSTOM && message.sensor==CHILD_ID_UPDATE_GATEWAY){	//Acknowledge message & of correct type & Sensor
      		bAckGatewayUpdate = 1;
      	}
      }
      
      void transmit() {
      	static int iIndexInArrayFailedMessages  = 0 ;
      	static int iIndexInArrayTimeMessages  = 0 ;	
      
      	iMessageCounter++;
      	//Cyclic Index counters of arrays
      	iIndexInArrayFailedMessages = iMessageCounter % iMaxNumberOfMessages;
      	iIndexInArrayTimeMessages 	= iMessageCounter % iNrTimeDelays;
      
      	bArrayNAckMessages[iIndexInArrayFailedMessages] = 1; 			// set corresponding flag to "Not Received Yet"
      
      	//Prepare time stamp logging for transmit
      	lTimeDelayBuffer_Destination_us[iIndexInArrayTimeMessages] = 0; 		// Clear Buffer value, new value will be written when message is received
      	iMessageIndexBuffer[iIndexInArrayTimeMessages]=iMessageCounter;		// To link the Time Stamp to the correct message when we receive the acknowledge
      	iNrNAckMessages++;													// Add one to the Not Acknowledged Message counter and remove it again if/when it is received.
      	lTimeOfTransmit_us[iIndexInArrayTimeMessages] = micros();
      	
      	//Transmit message with software ack request (returned in "receive function"), the boolean returned here is a Hardware hop-to-hop Ack
      	boolean success = send(MsgCounter.setDestination(iDestinationNode).set(iMessageCounter), true);
      	if (!success) {
      		lTimeDelayBuffer_FirstHop_us[iIndexInArrayTimeMessages] = 0;	//It failed, so I can't use it to determine a First Hop Delay (i.e. it is "infinite" delay as it failed)
      		bArrayFailedMessages[iIndexInArrayFailedMessages] = true;	//Log it as a failed message (for rolling average)
      		iNrFailedMessages++ ;
      	}
      	else{
      		lTimeDelayBuffer_FirstHop_us[iIndexInArrayTimeMessages] = micros() - lTimeOfTransmit_us[iIndexInArrayTimeMessages];	//Log First Hop Delay in buffer
      		bArrayFailedMessages[iIndexInArrayFailedMessages] = false;	//Log it as a not-failed = succesful message (for rolling average)
      	}
      }
      
      /********************************************************************************/
      /************************ CONFIGURE nRF24 RADIO FUNCTIONS ***********************/
      /********************************************************************************/
      void loadNewRadioSettings() {
      	ClearStorageAndCounters();
      	uint8_t iTempVar0 = RF24_BASE_ID_VAR[0];
      	uint8_t rfsetup = ( ((iRf24DataRate & 0b10 ) << 4) | ((iRf24DataRate & 0b01 ) << 3) | (iRf24PaLevel << 1) ) + 1;		//!< RF24_RF_SETUP, +1 for Si24R1 and LNA
      
      	RF24_setChannel(iRf24Channel);
      	RF24_setRFSetup(rfsetup);
      	RF24_enableFeatures();
      
      	RF24_BASE_ID_VAR[0] = RF24_BROADCAST_ADDRESS;
      	RF24_setPipeAddress(RF24_REG_RX_ADDR_P0 + RF24_BROADCAST_PIPE, (uint8_t*)&RF24_BASE_ID_VAR,
      	                    RF24_BROADCAST_PIPE > 1 ? 1 : MY_RF24_ADDR_WIDTH);
      	RF24_setPipeAddress(RF24_REG_RX_ADDR_P0, (uint8_t*)&RF24_BASE_ID_VAR, MY_RF24_ADDR_WIDTH);
      	RF24_setPipeAddress(RF24_REG_TX_ADDR, (uint8_t*)&RF24_BASE_ID_VAR, MY_RF24_ADDR_WIDTH);
      	
      	RF24_BASE_ID_VAR[0] = iTempVar0;
      	
      	//lcd.home();
      	lcd.setCursor(0, 0);
      	lcd.print("nRF24 DOCTOR");
      	lcd.setCursor(0, 1);
      	lcd.print("Connecting...");
      	transportWaitUntilReady(10000);		// Give it 10[s] to connect, else continue to allow user to set new connection settings
      }
      
      void loadNewRadioSettingsGateway() {
      	switch (iRetryGateway){
      		case 0:	//Skip Gateway update (= only update this Node)
      			//Store new values to EEPROM & Restart the program
      			SaveStatesToEEPROM();
      			asm volatile ("  jmp 0");	//Do a Soft Reset - This allows for the radio to correctly reload with the new settings from EEPROM
      			break;				
      		case 1:	{
      			//(Re-)try Gateway update
      			uint16_t iMessageToGateway = iRf24Channel*100+iRf24PaLevelGw*10+iRf24DataRate;
      			boolean success = send(MsgUpdateGateway.setDestination(0).setSensor(250).set(iMessageToGateway), true);		//Transmit message with software ack request (returned in "receive function")
      			int nRepeats = 0;
      			while (!success && nRepeats<10) {	//Re-try
      				nRepeats++;
      				success = send(MsgUpdateGateway.setDestination(0).set(iMessageToGateway), true);
      			}
      			wait(2000);	//wait for ACK from Gateway
      			if (bAckGatewayUpdate){
      				//Store new values to EEPROM & Restart the program
      				SaveStatesToEEPROM();
      				asm volatile ("  jmp 0");	//Do a Soft Reset - This allows for the radio to correctly reload with the new settings from EEPROM					
      			}
      			break;
      		}					
      		case 2:	//Cancel All
      			opState = STATE_RUN;
      			LoadStatesFromEEPROM();
      			bDspRefresh = true;					
      			break;
      	}
      }
      /*****************************************************************/
      /************************ EEPROM FUNCTIONS ***********************/
      /*****************************************************************/
      void LoadStatesFromEEPROM() {
      	iRf24Channel 		= loadState(EEPROM_CHANNEL);
      	iRf24PaLevel 		= loadState(EEPROM_PA_LEVEL);
      	iRf24PaLevelGw 		= loadState(EEPROM_PA_LEVEL_GW);
      	iRf24DataRate 		= loadState(EEPROM_DATARATE);
      	iRf24BaseRadioId	= loadState(EEPROM_BASE_RADIO_ID);
      	iDestinationNode 	= loadState(EEPROM_DESTINATION_NODE);
      }
      
      void SaveStatesToEEPROM() {
      	saveState(EEPROM_CHANNEL, iRf24Channel);
      	saveState(EEPROM_PA_LEVEL, iRf24PaLevel);
      	saveState(EEPROM_PA_LEVEL_GW, iRf24PaLevelGw);
      	saveState(EEPROM_DATARATE, iRf24DataRate);
      	saveState(EEPROM_BASE_RADIO_ID, iRf24BaseRadioId);
      	saveState(EEPROM_DESTINATION_NODE, iDestinationNode);
      }
      
      /*****************************************************************/
      /************************ BUTTON FUNCTIONS ***********************/
      /*****************************************************************/
      void ButtonTick() {
      	//Check Button States (should be done Frequently
      	button1.tick();
      	button2.tick();
      }
      
      void onButton1Pressed() {			//Scroll through the menu items
      	lcd.clear();
      	bDspRefresh = true;
      	switch (opState) {
      		case STATE_RUN:
      			opState = STATE_RUN2;
      			break;
      		case STATE_RUN2:
      			opState = STATE_RUN3;
      			break;			
      		case STATE_RUN3:
      			opState = STATE_CURLEVEL;
      			break;			
      		case STATE_CURLEVEL:
      			opState = STATE_SET_RESET;
      			break;
      		case STATE_SET_RESET:
      			opState = STATE_SET_DESTINATION_NODE;
      			break;
      		case STATE_SET_DESTINATION_NODE:
      			opState = STATE_SET_CHANNEL;
      			break;
      		case STATE_SET_CHANNEL:
      			opState = STATE_SET_PALEVEL;
      			break;
      		case STATE_SET_PALEVEL:
      			opState = STATE_SET_PALEVEL_GW;
      			break;
      		case STATE_SET_PALEVEL_GW:
      			opState = STATE_SET_DATARATE;
      			break;		
      		case STATE_SET_DATARATE:
      			opState = STATE_SET_BASE_RADIO_ID;
      			break;
      		case STATE_SET_BASE_RADIO_ID:
      			opState = STATE_ASK_GATEWAY;
      			break;
      		case STATE_ASK_GATEWAY:
      			opState = STATE_UPDATE_GATEWAY;
      			loadNewRadioSettingsGateway();
      			break;
      		case STATE_UPDATE_GATEWAY:
      			loadNewRadioSettingsGateway();
      			break;		
      	}
      }
      
      void onButton2Pressed() {	//Apply/Select change (if available). In Viewing windows: toggle (reversed)
      	bDspRefresh = true;
      	switch (opState) {
      		case STATE_RUN:
      			//Do nothing
      			break;
      		case STATE_RUN2:
      			//Do nothing
      			break;
      		case STATE_RUN3:
      			//Do nothing
      			break;			
      		case STATE_CURLEVEL:
      			//Do nothing
      			break;
      		case STATE_SET_RESET:
      			ClearStorageAndCounters();
      			opState = STATE_RUN;
      			break;
      		//Select Radio changes:
      		case STATE_SET_DESTINATION_NODE:
      			iDestinationNode++;
      			break;				
      		case STATE_SET_CHANNEL:
      			iRf24Channel++; if (iRf24Channel > 125) iRf24Channel = 0;
      			break;
      		case STATE_SET_PALEVEL:
      			iRf24PaLevel++; if (iRf24PaLevel > (iNrPaLevels-1)) iRf24PaLevel = 0;
      			break;
      		case STATE_SET_PALEVEL_GW:
      			iRf24PaLevelGw++; if (iRf24PaLevelGw > (iNrPaLevels-1)) iRf24PaLevelGw = 0;
      			break;			
      		case STATE_SET_DATARATE:
      			iRf24DataRate++; if (iRf24DataRate > (iNrDataRates-1)) iRf24DataRate = 0;
      			break;			
      		case STATE_SET_BASE_RADIO_ID:
      			iRf24BaseRadioId++; if (iRf24BaseRadioId > iNrBaseRadioIds) iRf24BaseRadioId = 1;
      			switch (iRf24BaseRadioId) {
      				case 1:
      					memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR1,sizeof(RF24_BASE_ID_VAR));
      					break;
      				case 2:
      					memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR2,sizeof(RF24_BASE_ID_VAR));
      					break;				
      				case 3:
      					memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR3,sizeof(RF24_BASE_ID_VAR));
      					break;
      				case 4:
      					memcpy(RF24_BASE_ID_VAR,RF24_BASE_ID_VAR4,sizeof(RF24_BASE_ID_VAR));
      					break;
      			}
      			break;			
      		case STATE_ASK_GATEWAY:
      			bUpdateGateway= !bUpdateGateway;
      			if (bUpdateGateway){
      				iRetryGateway = 1;
      			}
      			else{
      				iRetryGateway = 0;
      			}
      			break;
      		case STATE_UPDATE_GATEWAY:
      			iRetryGateway++; if (iRetryGateway > (iNrGatwayRetryOptions-1)) iRetryGateway = 0;
      /* 			switch(iRetryGateway){
      				case 0: 
      					bUpdateGateway = 0;
      					break;
      				case 1:
      					bUpdateGateway = 1;
      					break;
      				case 2:
      					bUpdateGateway = 0;
      					break;				
      			} */
      			break;
      	}
      }
      
      void onButton1LongPressed() {
      	// Return to normal RUN state without changing any settings (recall last set from EEPROM)
      	opState = STATE_RUN;
      	LoadStatesFromEEPROM();
      	bDspRefresh = true;
      }
      
      void onButton2Hold() {	//Scroll through numbers quickly
      	switch (opState) {
      		case STATE_SET_CHANNEL:
      			iRf24Channel++; if (iRf24Channel > 125) iRf24Channel = 0;
      			bDspRefresh = true;
      			break;
      		case STATE_SET_DESTINATION_NODE:
      			iDestinationNode++;
      			bDspRefresh = true;
      			break;
      	}		
      }
      
      /*****************************************************************/
      /**************** ARRAY PROCESSING FUNCTIONS *********************/
      /*****************************************************************/
      
      uint8_t IndexOfValueInArray(uint16_t val, uint16_t *array, uint8_t size){
      	// Find the (first) array element which equals val and return the index.
      	// If val not found in the array return 255
          for (int i=0; i < size; i++) {
              if (array[i] == val){
      			return i;
      		}
          }
          return 255;	//Not Found
      }
      
      int GetNrOfTrueValuesInArray(boolean countArray[], int size) {
      	// Calculate number of TRUE values in array
      	int Counter = 0 ;
      	for (int i = 0 ; i < size ; i++) {Counter += countArray[i];}
      	return Counter;
      }
      
      void ClearStorageAndCounters() {
      	for (int n = 0; n < iMaxNumberOfMessages; n++){
      		bArrayFailedMessages[n] = 0;
      		bArrayNAckMessages[n] = 0;
      	}
      	iNrNAckMessages = iMessageCounter = iNrFailedMessages = 0;
      	bAckGatewayUpdate = 0;
      }
      
      void getMeanAndMaxFromArray(uint16_t *mean_value, uint16_t *max_value, unsigned long *buffer, uint8_t size) {
      	//Note: excluding 0 values from mean calculation
      	uint8_t iNrOfSamples=0;		//max equals size
      	unsigned long lMaxValue=0;	//max Array value
      	float sum=0;
      	for (int i=0; i < size; i++)
      	{
      		if (buffer[i] != 0){
      			sum 		= sum + (float)buffer[i];	
      			lMaxValue	= max(lMaxValue,buffer[i]);
      			iNrOfSamples++;
      		}
      	}
      	if (iNrOfSamples !=0){
      		*mean_value 	= (uint16_t) ((sum / (float)iNrOfSamples)/1000);
      		*max_value		= (uint16_t) (lMaxValue/1000L);
      	}
      	else {
      		*mean_value = 65535;	//INF identifier
      		*max_value 	= 65535;	//INF identifier
      	}	
      }
      
      float GetAvgADCBits(int iNrSamples) {
      	float sum = 0;
      	for (int i=0; i < iNrSamples; i++) {
      		sum = sum + analogRead(CURRENT_PIN);
      		wait(1);	// Need some time for the high impedance measurement @ 10kOhm
      	}
      	return ((float)sum/(float)iNrSamples);
      }
      
      
      /*****************************************************************/
      /************************* LCD FUNCTIONS *************************/
      /*****************************************************************/
      
      void print_LCD_line(const char *string,int row, int col) {
      	lcd.setCursor(col-1,row-1);
      	lcd.print(string);
      }
      
      void LCD_local_display(void) {
      	static mode prevOpState = STATE_RUN;	//Remember previous state to allow for partial LCD updates
      	char buf[LCD_COLS+1];
      	bDspRefresh = false;
      	
      	switch (opState) {
      		case STATE_RUN:
      		{
      			snprintf(buf, sizeof buf, "P%-3dFAIL%4d%3d%%", MY_PARENT_NODE_ID, iNrFailedMessages, GetNrOfTrueValuesInArray(bArrayFailedMessages, iMaxNumberOfMessages));
      			print_LCD_line(buf,1, 1);
      			snprintf(buf, sizeof buf, "D%-3dNACK%4d%3d%%", iDestinationNode , iNrNAckMessages, GetNrOfTrueValuesInArray(bArrayNAckMessages, iMaxNumberOfMessages));
      			print_LCD_line(buf,2, 1);
      			break;
      		}
      		case STATE_RUN2:
      		{
      			if (iMaxDelayFirstHop_ms>9999){
      				snprintf(buf, sizeof buf, "HOP1 dTmax   INF");
      			}
      			else{
      				snprintf(buf, sizeof buf, "HOP1 dTmax%4dms",iMaxDelayFirstHop_ms);
      			}
      			print_LCD_line(buf,1, 1);
      			if (iMaxDelayDestination_ms>9999){
      				snprintf(buf, sizeof buf, "D%-3d dTmax   INF",iDestinationNode,iMaxDelayDestination_ms);
      			}
      			else{
      				snprintf(buf, sizeof buf, "D%-3d dTmax%4dms",iDestinationNode,iMaxDelayDestination_ms);
      			}
      			print_LCD_line(buf,2, 1);
      			break;
      		}
      		case STATE_RUN3:
      		{
      			snprintf(buf, sizeof buf, "MESSAGE COUNT:  ");
      			print_LCD_line(buf,1, 1);
      			snprintf(buf, sizeof buf, "           %5d",iMessageCounter);
      			print_LCD_line(buf,2, 1);
      			break;
      		}		
      		case STATE_CURLEVEL:
      		{
      			float fCurrent_uA = 0;
      			if (iPowerMode == 1){
      				fCurrent_uA = StandbyCurrent_uA;
      			}
      			else{
      				fCurrent_uA = SleepCurrent_uA;	
      			}
      			Sprint("iPowerMode:");Sprintln(iPowerMode);
      			Sprint("fCurrent_uA:");Sprintln(fCurrent_uA);
      			
      			if (fCurrent_uA > 1000){
      				int Current_mA = (int)(fCurrent_uA/1000);
      				if (Current_mA>=300){
      					snprintf(buf, sizeof buf, "%s[mA]= ERR",pcPowerModeNames[iPowerMode],Current_mA);
      				}
      				else if (Current_mA>=100){
      					snprintf(buf, sizeof buf, "%s[mA]=%4d",pcPowerModeNames[iPowerMode],Current_mA);
      				}
      				else if (Current_mA>=10){
      					int iDecCurrent = (int)(((fCurrent_uA/1000)-(float)Current_mA)*10+0.5);
      					snprintf(buf, sizeof buf, "%s[mA]=%2d.%1d",pcPowerModeNames[iPowerMode],Current_mA,iDecCurrent);
      				}
      				else {				
      					int iDecCurrent = (int)(((fCurrent_uA/1000)-(float)Current_mA)*100+0.5);
      					snprintf(buf, sizeof buf, "%s[mA]=%1d.%2d",pcPowerModeNames[iPowerMode],Current_mA,iDecCurrent);
      				}
      			}
      			else if (fCurrent_uA < 100){		
      				int iCurrent_uA = (int)fCurrent_uA;
      				int iDecCurrent_uA = (int)((fCurrent_uA-(float)iCurrent_uA)*10+0.5);
      					snprintf(buf, sizeof buf, "%s[uA]=%2d.%1d",pcPowerModeNames[iPowerMode],iCurrent_uA,iDecCurrent_uA);
      				}
      			else{
      				snprintf(buf, sizeof buf, "%s[uA]=%4d",pcPowerModeNames[iPowerMode],(int)fCurrent_uA);
      			}
      			if (iPowerMode == 1){
      				print_LCD_line(buf,1, 1);				
      			}
      			else{
      				print_LCD_line(buf,2, 1);
      			}
      			break;
      		}
      		case STATE_SET_RESET:
      		{
      			snprintf(buf, sizeof buf, "RESET BUFFERS?");
      			print_LCD_line(buf,1, 1);
      			break;
      		}	
      		case STATE_SET_DESTINATION_NODE:
      		{
      			if(opState==prevOpState){
      				char buf2[4];
      				lcd.setCursor(13, 0);
      				snprintf(buf2, sizeof buf2, "%3d", iDestinationNode);
      				lcd.print(buf2);
      			}
      			else{
      				snprintf(buf, sizeof buf, "DEST. NODE = %3d", iDestinationNode);
      				print_LCD_line(buf,1, 1);
      			}
      			break;
      		}
      		case STATE_SET_CHANNEL:
      		{
      			if(opState==prevOpState){
      				char buf2[4];
      				lcd.setCursor(13, 0);
      				snprintf(buf2, sizeof buf2, "%3d", iRf24Channel);
      				lcd.print(buf2);
      			}
      			else{
      				snprintf(buf, sizeof buf, "CHANNEL NR = %3d", iRf24Channel);
      				print_LCD_line(buf,1, 1);
      			}
      			break;
      		}
      		case STATE_SET_PALEVEL:
      		{
      			lcd.clear();
      			snprintf(buf, sizeof buf, "NODE");
      			print_LCD_line(buf,1, 1);
      			snprintf(buf, sizeof buf, "PA Level = %s", pcPaLevelNames[iRf24PaLevel]);
      			print_LCD_line(buf,2, 1);
      			break;
      		}
      		case STATE_SET_PALEVEL_GW:
      		{
      			lcd.clear();
      			snprintf(buf, sizeof buf, "GATEWAY");
      			print_LCD_line(buf,1, 1);
      			snprintf(buf, sizeof buf, "PA Level = %s", pcPaLevelNames[iRf24PaLevelGw]);
      			print_LCD_line(buf,2, 1);
      			break;
      		}
      		case STATE_SET_DATARATE:
      		{
      			lcd.clear();
      			snprintf(buf, sizeof buf, "DataRate=%s", pcDataRateNames[iRf24DataRate]);
      			print_LCD_line(buf,1, 1);
      			break;
      		}
      		case STATE_SET_BASE_RADIO_ID:
      		{
      			lcd.clear();
      			snprintf(buf, sizeof buf, "Base Radio ID=  ");
      			print_LCD_line(buf,1, 1);
      			snprintf(buf, sizeof buf, "%02X:%0.2X:%0.2X:%0.2X:%0.2X",RF24_BASE_ID_VAR[0],RF24_BASE_ID_VAR[1],RF24_BASE_ID_VAR[2],RF24_BASE_ID_VAR[3],RF24_BASE_ID_VAR[4]);
      			print_LCD_line(buf,2, 1);
      			break;
      		}		
      		case STATE_ASK_GATEWAY:
      		{
      			lcd.clear();
      			snprintf(buf, sizeof buf, "UPDATE GATEWAY?:");
      			print_LCD_line(buf,1, 1);
      			if (bUpdateGateway){
      				snprintf(buf, sizeof buf, "YES");
      				print_LCD_line(buf,2, 14);
      			}
      			else{
      				snprintf(buf, sizeof buf, "NO");
      				print_LCD_line(buf,2, 15);
      			}
      			break;
      		}			
      		case STATE_UPDATE_GATEWAY:
      		{
      			lcd.clear();
      			snprintf(buf, sizeof buf, "FAILED GATEWAY!");
      			print_LCD_line(buf,1, 1);
      			snprintf(buf, sizeof buf,"%s",pcGatewayRetryNames[iRetryGateway]);
      			print_LCD_line(buf,2, 1);
      			break;								
      		}	
      	}
      	prevOpState = opState;
      }
      
      posted in My Project
      Technovation
      Technovation
    • ESP32 + Signing fails after xxx msg as result of memory leak

      MySensors Version: 2.3.2 (and prior versions)
      Hardware: ESP32

      Summary of Issue: ESP32 in combination with signing enabled will result in signing failure after fixed number of messages (signing events).

      Detailed description:
      I was performing some benchmark tests with different boards in combination with MY_SECURITY_SIMPLE_PASSWD enabled to analyse the impact on message delays (responsiveness). During these tests with an ESP32 (esp32doit-devkit-v1)
      I experienced that the first set of messages were going all OK, but after a while I stopped receiving messages at the controller.

      Diving deeper into the problem I found:

      • The ESP32 was at fault - resetting the device was sufficient to get things running again (for a while)
      • The problem occurs for both ESP32 configured as Gateway or Node
      • It fails repeatably after the same number of messages after a restart of the ESP32 (and the number of successful messages is sketch dependent - e.g. after 520 messages for my GW sketch and 725 messages for my test node).

      Solution:
      quite some steps of debugging later I found that the signing was failing and the root cause appeared to be a memory leak at:

      MyCryptoESP32.cpp in the SHA256 and the SHA256HMAC functions, which perform a
      mbedtls_md_init(&ctx);, but no call to mbedtls_md_free(&ctx); is present to clear the internal structure created at the end of the function.
      After adding mbedtls_md_free(&ctx); at the end of both SHA256 and SHA256HMAC functions the bug appears to be solved (I stopped testing after 133.000 successful messages 😁 ).

      Another point I noticed in my debugging quest is that I also think I spotted a small "typo" in MySigning.cpp in the signerInternalProcessNonceRequest function.
      In the debug message it reports the SGN:NCE:XMT,TO=xxx, where for xxx now the msg.getSender() is being used, but I suppose that should be msg.getDestination(), i.e. the location (= target Node) TO which the nonce is send.

      I initially wanted to try and make (my first) pull request with this fix, but got stranded at the CLA agreement for now (I don't know if my employer will agree to all the terms in the agreement on the patent licensing stuff and legal stuff is not my strong suit).

      Hope this solution will in the meantime help other MySensors users using an ESP32 and also have signing enabled.

      posted in Bug Reports
      Technovation
      Technovation
    • RE: nRF24Doctor

      And finally PART3 the sketch for the nRF24DoctorGateway

      /**
      * The MySensors Arduino library handles the wireless radio link and protocol
      * between your home built sensors/actuators and HA controller of choice.
      * The sensors forms a self healing radio network with optional repeaters. Each
      * repeater and gateway builds a routing tables in EEPROM which keeps track of the
      * network topology allowing messages to be routed to nodes.
      *
      * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
      * Copyright (C) 2013-2015 Sensnology AB
      * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
      *
      * Documentation: http://www.mysensors.org
      * Support Forum: http://forum.mysensors.org
      *
      * This program is free software; you can redistribute it and/or
      * modify it under the terms of the GNU General Public License
      * version 2 as published by the Free Software Foundation.
      *
      *******************************
      *
      * DESCRIPTION
      * The ArduinoGateway prints data received from sensors on the serial link.
      * The gateway accepts input on seral which will be sent out on radio network.
      *
      * The GW code is designed for Arduino Nano 328p / 16MHz
      *
      * Wire connections (OPTIONAL):
      * - Inclusion button should be connected between digital pin 3 and GND
      * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
      *
      * LEDs (OPTIONAL):
      * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs
      * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
      * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
      * - ERR (red) - fast blink on error during transmission error or recieve crc error
      *
      */
      
      //---------------- SET SPECIFIC MY SENSORS SETTINGS ---------------------//
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      #define MY_DEBUG_VERBOSE_SIGNING
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      
      
      //#define MY_RF24_CHANNEL 1
      //#define MY_RF24_DATARATE RF24_1MBPS
      
      //If you are using an Arduino Mega
      #define MY_RF24_CE_PIN 49
      #define MY_RF24_CS_PIN 53
      //Enable receiving buffer feature.
      //#define MY_RF24_IRQ_PIN 2
      //#define MY_RX_MESSAGE_BUFFER_FEATURE
      
      // 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_MAX
      
      // Signing settings
      //#define MY_SIGNING_SOFT
      //#define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
      //#define MY_SIGNING_REQUEST_SIGNATURES
      //These codes should be programmed in EEPROM through SecurityPersonalizer.ino with USB connection once (will be maintained with reprogramming of new sketches) and preferably not send over the air)
      //#define MY_SOFT_HMAC_KEY 0xFC,0x7E,0xA0,0x9F,0xEA,0x20,0x14,0xD0,0xC4,0x5F,0xBB,0xA3,0x70,0xE8,0xA1,0xDD,0x72,0x3E,0xBB,0x19,0x50,0x8E,0x35,0x7D,0x44,0x25,0xBB,0x7A,0xF4,0xAA,0x28,0x76
      //#define MY_SOFT_SERIAL 0x2C,0xA0,0x3F,0x21,0x08,0x80,0xF5,0x8A,0xC4
      //#define MY_AES_KEY 0x8F,0x87,0x9B,0x25,0xEE,0xAC,0x6A,0x36,0x3D,0xD3,0xF8,0x35,0x5F,0xD5,0xCB,0x96
      
      // RF24 encryption is enabled in MyConfig.h (all nodes and gateway must have this enabled, and all must be personalized with the same AES key)
      //#define MY_RF24_ENABLE_ENCRYPTION
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      // Define a lower baud rate for Arduino's 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_TX_LED_PIN  5  // the PCB, on board LED
      #define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
      
      //**** MySensors Messages ****
      #define MY_TRANSPORT_SANITY_CHECK_INTERVAL_MS 3000000000			//To Prevent the MySensors library from resetting back to default radio settings
      #include <MySensors.h>
      #define CHILD_ID_UPDATE_GATEWAY 250
      MyMessage MsgUpdateGateway(CHILD_ID_UPDATE_GATEWAY, V_CUSTOM);   	//Send value for Gateway settings: xxxyz (xxx = Channel, y = PaLevel, z = DataRate)
      uint8_t iRf24Channel 		= MY_RF24_CHANNEL;
      uint8_t iRf24PaLevelGw 		= MY_RF24_PA_LEVEL;
      uint8_t iRf24DataRate 		= MY_RF24_DATARATE;
      bool bLoadNewRadioSettings 	= 0;
      const uint8_t iNrPaLevels = 4;
      const char *pcPaLevelNames[iNrPaLevels] 		= { "MIN", "LOW", "HIGH", "MAX" };
      const uint8_t iNrDataRates = 3;
      const char *pcDataRateNames[iNrDataRates] 		= { "1MBPS", "2MBPS" , "250KBPS"};
      #define DELAY_BETWEEN_RADIO_SETTINGS_PRINT 20000	//Print Radio Settings to Serial Monitor every x[ms]
      
      //**** DEBUG *****
      #define LOCAL_DEBUG
      
      #ifdef LOCAL_DEBUG
      #define Sprint(a) (Serial.print(a))           	// macro as substitute for print, enable if no print wanted
      #define Sprintln(a) (Serial.println(a))         
      #else											// macro for "no" debug print
      #define Sprint(a)                   			
      #define Sprintln(a)                   			
      #endif
      
      
      //-----------------------------------------------------------------------//
      
      
      void setup()
      {
      	//loadNewRadioSettings();	//Load the Radio Settings as transmitted by the nRF24 Doctor Node
      }
      
      void presentation()
      {
      	// Present locally attached sensors
      }
      
      void loop()
      {
      	static unsigned long lLastRadioSettingsPrint = millis();
      	wait(1);	
      	//Set new Radio settings by nRF24 Doctor Node
      	if (bLoadNewRadioSettings){
      		bLoadNewRadioSettings = 0;
      		loadNewRadioSettings();
      	}
      	//Regularly print the Radio Settings we are using
      	if ((millis()- lLastRadioSettingsPrint) > DELAY_BETWEEN_RADIO_SETTINGS_PRINT){// wait for things to settle and ack's to arrive
      		lLastRadioSettingsPrint = millis();
      		PrintRadioSettings();
      	}	
      }
      
      /*****************************************************************************/
      /************************ RECEIVE & TRANSMIT FUNCTIONS ***********************/
      /*****************************************************************************/
      void receive(const MyMessage &message) {
      	if (message.type == V_CUSTOM && message.sensor==CHILD_ID_UPDATE_GATEWAY){	//Acknowledge message & of correct type & Sensor
      		uint16_t iNewMessage = message.getUInt();           // get received value
      		//Extract the new Gateway settings
      		iRf24Channel 	= (uint16_t)(iNewMessage/100U);
      		iRf24PaLevelGw 	= (uint16_t)((iNewMessage/10U)%10);
      		iRf24DataRate 	= (uint16_t)(iNewMessage%10);
      		bLoadNewRadioSettings = 1;
      		Sprintln("Received new Radio settings.");
      	}
      }
      
      /********************************************************************************/
      /************************ CONFIGURE nRF24 RADIO FUNCTIONS ***********************/
      /********************************************************************************/
      void loadNewRadioSettings() {
      	uint8_t rfsetup = ( ((iRf24DataRate & 0b10 ) << 4) | ((iRf24DataRate & 0b01 ) << 3) | (iRf24PaLevelGw << 1) ) + 1;		//!< RF24_RF_SETUP, +1 for Si24R1 and LNA
      	RF24_setChannel(iRf24Channel);
      	RF24_setRFSetup(rfsetup);
      	RF24_enableFeatures();
      	Sprint("Updated Radio Settings!\t");
      	PrintRadioSettings();
      }
      
      /********************************************************************************/
      /******************************** SERIAL OUTPUT *********************************/
      /********************************************************************************/
      void PrintRadioSettings() {
      	Sprint("Channel:");Sprint(iRf24Channel);Sprint("\t");
      	Sprint("PaLevel:");Sprint(pcPaLevelNames[iRf24PaLevelGw]);Sprint("\t");
      	Sprint("DataRate:");Sprint(pcDataRateNames[iRf24DataRate]);Sprintln("\t");
      }
      

      I hope this will be helpful to others to diagnose and doctor their nRF24 Connections.

      posted in My Project
      Technovation
      Technovation
    • RE: ESP32 + Signing fails after xxx msg as result of memory leak

      @tekka thanks for submitting the PR.
      No blaming needed 🙂 , just happy that there are people like you that contribute to this nice project.

      posted in Bug Reports
      Technovation
      Technovation
    • RE: transportPowerDown() with v2.2.0

      Try transportDisable();

      posted in Development
      Technovation
      Technovation
    • RE: DIY CNC mill from mainly salvaged and 3D printed parts

      @dbemowsk they should work if used as intended. These couplings are supposed to be stiff in only one direction of freedom: Rotation of the axis (=transfer the torque of the motor to the axis). The other 5 degrees of freedom should be of low stiffness to absorb misalignment between motor and axis. So the correct type of bearings should actually constrain the axis to only rotate in one DoF and not translate into the coupling.

      posted in My Project
      Technovation
      Technovation
    • RE: Problem with NRF24L01+PA+LNA (Gateway - Sensor Connection)

      I've also had some issues with these nRF24L01+PA+LNA versions, while not having any issues with the regular nRF24L01 modules.
      I found that if I set the transmitter power (MY_RF24_PA_LEVEL) to a lower setting the problem generally reduced or disappeared completely.
      Of course it is not really nice to use a lower power setting on these modules as it was intended to get maximum range, but it does point in two likely causes:

      • As stated by others, it can be due to poor power at the radio and this must be fixed first:
        1. Make sure to use an adequate external power supply (most arduino's are not up to the task of delivering sufficient current for this type of radio).
        2. Use a (low voltage drop out) regulator near the radio, note that the external power supply delivers sufficient voltage for the regulator to operate correctly.
        3. add a decent size (10~100uF) capacitor near or on the radio's power line
      • At least some of the nRF24+PA+LNA appear sensitive for picking up noise (transmitted by its own antenna). To solve this you will need to shield your radio. The easiest way is if your radio and other parts are in a case and the antenna is sticking out to run to the kitchen and grap the aluminium or tin foil and wrap the entire casing (excluding the antenna) in (multiple layers of) aluminium or tin foil.

      If the latter works (which it did for me), you can look into a cleaner solution of shielding the module (maybe a metal casing?).

      posted in Hardware
      Technovation
      Technovation

    Latest posts made by Technovation

    • RE: NRF24+ Module: Spontaneous 5A heating mode?

      @The-Grue: Don't be embarrassed by it...pretty sure you are not the first one that fell for this trap and certainly not the last one. Hopefully also other readers on the forum can benefit from your (bad) experience in this way.

      Thanks for reporting back and good to hear that some of your trust has returned towards the nrf24 and your part shops with a "good name" 🙂 .

      posted in Troubleshooting
      Technovation
      Technovation
    • RE: NRF24+ Module: Spontaneous 5A heating mode?

      @The-Grue
      That yellow capacitor looks like a tantalum capacitor (hard to be certain from the top view, but I guess it is the same type as the other yellow one on the board on which you can read the printing). In the case of it actually being a tantalum cap, you may have by accident installed it in the wrong orientation. Tantalum caps have a polarity and if wrongly applied (i.e. reverse polarity/voltage) it will typically show a gradual increase in leakage current - what appears to match with your description.

      So that is probably one of the reasons why you see tantalum caps being used less nowadays as it is easy to put them in the wrong way and hard to troubleshoot afterwards (visually quickly overlooked).

      posted in Troubleshooting
      Technovation
      Technovation
    • RE: nRF24Doctor

      @benbidouille said in nRF24Doctor:

      I thought the percentage shown corresponds to Nbr_of_fail / Total_Counter, but it is not and i assume percentage is rather calculated over last X

      It is indeed calculated over the last 100 msg's. In that way you have some "real-time" feedback on your connection quality (i.e. suppose you would have had 10.000 good msg's and it would start to fail - it will take +/-100 failed msg's to drop a single 1%).

      You can calculate the percentage based on the total nr of msg's by getting the total MESSAGE COUNT displayed at Counters page and combine that with the values from FAIL and NACK on the Statistics page.

      posted in My Project
      Technovation
      Technovation
    • RE: nRF24Doctor

      @benbidouille

      I do not follow you, to me we have 3.3V output regulation + 1,2V regulation margin which remains well under the 5V input of the regulator ( doesn't includes the 0,44v drop )

      You're right. I knew there was something additional in the order of about that shunt voltage drop, but should have checked the layout to spark my memory a bit better. It is not the voltage drop of the shunt but if you use the 5V output from the nano board you may have to account for a reverse voltage protection diode that may be present (i.e. your 5V pin does not really 5V). That's why there is a jumper to directly supply from the Vin pin.

      What is the FAIL and NACK % corresponding to

      • As in the description with the first post it should report percentage of FAILED acknowledges for the first HOP transmit (if no repeater nodes are present, then the first HOP will be the Gateway). This is actually the confirmation at "nrf24 radio level" to report if the message was received by another radio.
      • NACK : The gateway is requested an ACK message for every message the node transmits. So that means the round trip of the message from NODE-> GATEWAY -> NODE.

      So it can be that you have no FAIL but a lot of NACK, which would mean that your test node can send out a message and was received by another radio, but never receives an ACK back for the transmitted message.

      posted in My Project
      Technovation
      Technovation
    • RE: nRF24Doctor

      @Yveaux:

      @Technovation, maybe he can chip in.
      I can remember we struggled with grounding issues, as different Nanos have different quality in grounding, leading to deviations in measured current. We ended up manually patching a Nano to improve the ground layout.

      Indeed the depending on the nano board you may experience ground layout problems which are generally a problem for any accurate ADC measurement. The nano boards have GND pins on both left and right pin headers. In the poor designs they have no ground plane and simply use a thin trace to those pins. If you then have a bit of (varying) current draw flowing through those GND pins, the burden voltage on that thin trace will swing your GND reference for your ADC measurement up and down.

      @benbidouille

      I mean is clear Rds ON of MOSfet is chosen as low as possible, but the voltage drop across the 2.2ohm shunt might becomes critical especially along transcients when radio operates.

      The 2.2Ohm was a balance between current measurement resolution and the maximum current draw of a module during transmit. The worst case power consumption I measured was for a PA+LNA module at POWER = MAX (0dBm) setting and it consumed around 200mA bursts during transmit (these bursts are short and if you use a filtering cap it will average out those spikes to for example the 150mA you measured).

      So a 2.2Ohm x 200mA = 0.44V drop.

      Design considerations

      • Drop out voltage nRF24:
        This 0.44V will subtract from the 3V3 supply voltage to the nRF24 chip, leaving about 2.8V. According to the datasheet the nRF chip allows operation down to 2.7V for input signals >3.6V (e.g. 5V nano).
      • 3V3 Regulation
        Also the voltage regulation to the nRF needs some attention. Using the 3V3 regulation from the nano itself may not suffice, because at some boards the voltage regulator will not be able to sustain a stable 3V3 at those current peaks. For that purpose there is the external regulator present. Here you may have to opt for a low drop-out regulator, because a "standard" regulators drop out voltage will typically be 1.2V or larger and will not have sufficient voltage available in combo with the 0.44V burden voltage is in this budget: 3V3 output regulation + 0.44Vdrop + 1.2V regulation margin > 5V input to regulator.

      So all and all the design should be able to handle the PA+LNA in the worst case conditions (max power) and it did with all the units I tested, but it may require a bit of attention in the regulation. However some attention to the supply regulation is in general required with the PA+LNA variants in any design.

      posted in My Project
      Technovation
      Technovation
    • RE: ESP32 + Signing fails after xxx msg as result of memory leak

      @tekka thanks for submitting the PR.
      No blaming needed 🙂 , just happy that there are people like you that contribute to this nice project.

      posted in Bug Reports
      Technovation
      Technovation
    • ESP32 + Signing fails after xxx msg as result of memory leak

      MySensors Version: 2.3.2 (and prior versions)
      Hardware: ESP32

      Summary of Issue: ESP32 in combination with signing enabled will result in signing failure after fixed number of messages (signing events).

      Detailed description:
      I was performing some benchmark tests with different boards in combination with MY_SECURITY_SIMPLE_PASSWD enabled to analyse the impact on message delays (responsiveness). During these tests with an ESP32 (esp32doit-devkit-v1)
      I experienced that the first set of messages were going all OK, but after a while I stopped receiving messages at the controller.

      Diving deeper into the problem I found:

      • The ESP32 was at fault - resetting the device was sufficient to get things running again (for a while)
      • The problem occurs for both ESP32 configured as Gateway or Node
      • It fails repeatably after the same number of messages after a restart of the ESP32 (and the number of successful messages is sketch dependent - e.g. after 520 messages for my GW sketch and 725 messages for my test node).

      Solution:
      quite some steps of debugging later I found that the signing was failing and the root cause appeared to be a memory leak at:

      MyCryptoESP32.cpp in the SHA256 and the SHA256HMAC functions, which perform a
      mbedtls_md_init(&ctx);, but no call to mbedtls_md_free(&ctx); is present to clear the internal structure created at the end of the function.
      After adding mbedtls_md_free(&ctx); at the end of both SHA256 and SHA256HMAC functions the bug appears to be solved (I stopped testing after 133.000 successful messages 😁 ).

      Another point I noticed in my debugging quest is that I also think I spotted a small "typo" in MySigning.cpp in the signerInternalProcessNonceRequest function.
      In the debug message it reports the SGN:NCE:XMT,TO=xxx, where for xxx now the msg.getSender() is being used, but I suppose that should be msg.getDestination(), i.e. the location (= target Node) TO which the nonce is send.

      I initially wanted to try and make (my first) pull request with this fix, but got stranded at the CLA agreement for now (I don't know if my employer will agree to all the terms in the agreement on the patent licensing stuff and legal stuff is not my strong suit).

      Hope this solution will in the meantime help other MySensors users using an ESP32 and also have signing enabled.

      posted in Bug Reports
      Technovation
      Technovation
    • RE: How to protect rain sensor from oxidation?

      @martim
      Instead of measuring resistive with contact to water, consider measuring contactless to water by for instance using a inductive or capacitive measuring method. The closest that aproaches your current sensor is a capacitive soil sensor (example: [https://www.dfrobot.com/wiki/index.php/Capacitive_Soil_Moisture_Sensor_SKU:SEN0193]) which I guess should also work to measure rain.
      Of course you should seal the top part of the pcb with the electric components from rain.
      But with some imagination and ingenuity you should be able to come up with different solutions.

      posted in Hardware
      Technovation
      Technovation
    • Software ack reponse too quick on nRF24

      MySensors Version: 2.2.0
      Hardware:

      • STM32 BluePill @72MHz (Serial) Gateway + any type of node
      • nRF24 radios

      What I'm doing: Bench marking different gateways (currently a STM32 Serial & Ehternet MQTT)

      Problem Encountered: Sending loads of messages from the node to the gateway. Each message send from the node requests an ack'd from the gateway.

      • When I Enable #define MY_DEBUG in the sketch everything works flawlessly and high message rates can be achieved without any loss of hardware (the automatic one from the nRF24 radio) or software acknowledge from the gateway.
      • When I Remove #define MY_DEBUG in the sketch I suddenly have loads of messages which do not appear to receive a hardware or software acknowledge from the gateway.

      Expected Cause:

      • It appears that the automatic hardware ack from the gateway radio gets too little time to complete due to the requested software acknowledge to be transmitted. I.e. without the additional debug messages (=delay) present in the code a high clock speed microcontroller (like the STM32) is too fast in pushing a software ack to the radio before it can properly complete the hardware ack message.

      According to the nRF24 datasheet (section 7.9) there must at least be 130us between the completion of the transmitted message and the hardware ack. response. On top of the 130us we also need some time to transmit the actual ack message. This total time must at < ARD (Auto Retransmit Delay), which is configures to be 1500us for MySensors.

      So in MyTransport.cpp in transportProcessMessage just before the (void)transportSendRoute(_msgTmp) I added a delay of 1500uS and it all worked reliably again (successful hardware and software ack's and significant reduction of auto re-transmits of 16 times). This delay can actually be smaller than the 1500us as there is of course some time consumed by all the other tasks (still appeared to work properly with only 150us).

      posted in Bug Reports
      Technovation
      Technovation
    • RE: transportPowerDown() with v2.2.0

      Try transportDisable();

      posted in Development
      Technovation
      Technovation