st:fail sometimes and sometimes OK



  • Controller:
    Domoticz, version 2.3867

    Sensor:
    Arduino Nano Clone, nRF24L01+(maybe clone) with one sensor BMP180, battery powered by a LiPo 300 mAh directly to Arduino, no step-down- PWR LED removed, regulator for RAW removed
    BMP180 and NRF is connected via a step-down, 3.3 volt
    Battery level right now is 4 volt

    Gateway:
    Arduino Pro Mini Clone, nRF24L01+(maybe clone). Powered by USB
    Serial gateway

    /////

    Sensor code, added Battery reading from Arduino VCC, not analog input

    /**
     * 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.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     * 
     * DESCRIPTION
     * Pressure sensor example using BMP085 module  
     * http://www.mysensors.org/build/pressure
     *
     */
     
    #include <SPI.h>
    #include <MySensor.h>  
    #include <Wire.h>
    #include <Adafruit_BMP085.h>
    
    #define BARO_CHILD 0
    #define TEMP_CHILD 1
    #define BATT_CHILD 2
    
    const float ALTITUDE = 8; // <-- adapt this value to your own location's altitude.
    
    // Sleep time between reads (in seconds). Do not change this value as the forecast algorithm needs a sample every minute.
    const unsigned long SLEEP_TIME = 60000; 
    
    const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
    enum FORECAST
    {
    	STABLE = 0,			// "Stable Weather Pattern"
    	SUNNY = 1,			// "Slowly rising Good Weather", "Clear/Sunny "
    	CLOUDY = 2,			// "Slowly falling L-Pressure ", "Cloudy/Rain "
    	UNSTABLE = 3,		// "Quickly rising H-Press",     "Not Stable"
    	THUNDERSTORM = 4,	// "Quickly falling L-Press",    "Thunderstorm"
    	UNKNOWN = 5			// "Unknown (More Time needed)
    };
    
    Adafruit_BMP085 bmp = Adafruit_BMP085();      // Digital Pressure Sensor 
    
    //int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    //int oldBatteryPcnt = 0;
    long result;
    
    MySensor gw;
    
    float lastPressure = -1;
    float lastTemp = -1;
    int lastForecast = -1;
    
    const int LAST_SAMPLES_COUNT = 5;
    float lastPressureSamples[LAST_SAMPLES_COUNT];
    
    // this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
    // get kPa/h be dividing hPa by 10 
    #define CONVERSION_FACTOR (1.0/10.0)
    
    int minuteCount = 0;
    bool firstRound = true;
    // average value is used in forecast algorithm.
    float pressureAvg;
    // average after 2 hours is used as reference value for the next iteration.
    float pressureAvg2;
    
    float dP_dt;
    boolean metric;
    MyMessage tempMsg(TEMP_CHILD, V_TEMP);
    MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
    MyMessage forecastMsg(BARO_CHILD, V_FORECAST);
    MyMessage battMsg(BATT_CHILD, V_VOLTAGE);
    
    void setup() 
    {
      /*
         // use the 1.1 V internal reference
    #if defined(__AVR_ATmega2560__)
       analogReference(INTERNAL1V1);
    #else
       analogReference(INTERNAL);
    #endif
    */
    	gw.begin();
    
    	// Send the sketch version information to the gateway and Controller
    	gw.sendSketchInfo("Pressure Sensor", "1.1");
    
    	if (!bmp.begin()) 
    	{
    		Serial.println("Could not find a valid BMP085 sensor, check wiring!");
    		while (1) {}
    	}
    
    	// Register sensors to gw (they will be created as child devices)
    	gw.present(BARO_CHILD, S_BARO);
    	gw.present(TEMP_CHILD, S_TEMP);
      gw.present(BATT_CHILD, S_MULTIMETER);
    	metric = gw.getConfig().isMetric;
    }
    
    void loop() 
    {
      /*
       // get the battery Voltage
       int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef DEBUG
       Serial.println(sensorValue);
       #endif
       
       // 1M, 470K divider across battery and using internal ADC ref of 1.1V
       // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
       // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
       // ((305400+100000)/100000)*1.1 = Vmax = 4.46 Volts
       // 3.44/1023 = Volts per bit = 0.003363075
       // 4.46/1023 = Volts per bit = 0.0043591398
       //float batteryV  = sensorValue * 0.004359140;
       float batteryV  = sensorValue * 4.2 / 1023;
       int batteryPcnt = sensorValue / 10;
    
       #ifdef DEBUG
       Serial.print("Battery Voltage: ");
       Serial.print(batteryV);
       Serial.println(" V");
    
       Serial.print("Battery percent: ");
       Serial.print(batteryPcnt);
       Serial.println(" %");
       #endif
    */  
    	float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
    	float temperature = bmp.readTemperature();
    
    	if (!metric) 
    	{
    		// Convert to fahrenheit
    		temperature = temperature * 9.0 / 5.0 + 32.0;
    	}
    
    	int forecast = sample(pressure);
    
    	Serial.print("Temperature = ");
    	Serial.print(temperature);
    	Serial.println(metric ? " *C" : " *F");
    	Serial.print("Pressure = ");
    	Serial.print(pressure);
    	Serial.println(" hPa");
    	Serial.print("Forecast = ");
    	Serial.println(weather[forecast]);
    
    
    	if (temperature != lastTemp) 
    	{
    		gw.send(tempMsg.set(temperature, 1));
    		lastTemp = temperature;
    	}
    
    	if (pressure != lastPressure) 
    	{
    		gw.send(pressureMsg.set(pressure, 1));
    		lastPressure = pressure;
    	}
    
    	if (forecast != lastForecast)
    	{
    		gw.send(forecastMsg.set(weather[forecast]));
    		lastForecast = forecast;
    	}
      //if (oldBatteryPcnt != batteryPcnt) {
       // Power up radio after sleep
       //gw.sendBatteryLevel(batteryPcnt);
       readVcc();
       Serial.println(result/10);
       gw.send(battMsg.set(result/1000.000, 3));
    //   oldBatteryPcnt = batteryPcnt;
      //}
    	gw.sleep(SLEEP_TIME);
    }
    
    float getLastPressureSamplesAverage()
    {
    	float lastPressureSamplesAverage = 0;
    	for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
    	{
    		lastPressureSamplesAverage += lastPressureSamples[i];
    	}
    	lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;
    
    	return lastPressureSamplesAverage;
    }
    
    
    
    // Algorithm found here
    // http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
    // Pressure in hPa -->  forecast done by calculating kPa/h
    int sample(float pressure)
    {
    	// Calculate the average of the last n minutes.
    	int index = minuteCount % LAST_SAMPLES_COUNT;
    	lastPressureSamples[index] = pressure;
    
    	minuteCount++;
    	if (minuteCount > 185)
    	{
    		minuteCount = 6;
    	}
    
    	if (minuteCount == 5)
    	{
    		pressureAvg = getLastPressureSamplesAverage();
    	}
    	else if (minuteCount == 35)
    	{
    		float lastPressureAvg = getLastPressureSamplesAverage();
    		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
    		if (firstRound) // first time initial 3 hour
    		{
    			dP_dt = change * 2; // note this is for t = 0.5hour
    		}
    		else
    		{
    			dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
    		}
    	}
    	else if (minuteCount == 65)
    	{
    		float lastPressureAvg = getLastPressureSamplesAverage();
    		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
    		if (firstRound) //first time initial 3 hour
    		{
    			dP_dt = change; //note this is for t = 1 hour
    		}
    		else
    		{
    			dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
    		}
    	}
    	else if (minuteCount == 95)
    	{
    		float lastPressureAvg = getLastPressureSamplesAverage();
    		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
    		if (firstRound) // first time initial 3 hour
    		{
    			dP_dt = change / 1.5; // note this is for t = 1.5 hour
    		}
    		else
    		{
    			dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
    		}
    	}
    	else if (minuteCount == 125)
    	{
    		float lastPressureAvg = getLastPressureSamplesAverage();
    		pressureAvg2 = lastPressureAvg; // store for later use.
    		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
    		if (firstRound) // first time initial 3 hour
    		{
    			dP_dt = change / 2; // note this is for t = 2 hour
    		}
    		else
    		{
    			dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
    		}
    	}
    	else if (minuteCount == 155)
    	{
    		float lastPressureAvg = getLastPressureSamplesAverage();
    		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
    		if (firstRound) // first time initial 3 hour
    		{
    			dP_dt = change / 2.5; // note this is for t = 2.5 hour
    		}
    		else
    		{
    			dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
    		}
    	}
    	else if (minuteCount == 185)
    	{
    		float lastPressureAvg = getLastPressureSamplesAverage();
    		float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
    		if (firstRound) // first time initial 3 hour
    		{
    			dP_dt = change / 3; // note this is for t = 3 hour
    		}
    		else
    		{
    			dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
    		}
    		pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
    		firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
    	}
    
    	int forecast = UNKNOWN;
    	if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
    	{
    		forecast = UNKNOWN;
    	}
    	else if (dP_dt < (-0.25))
    	{
    		forecast = THUNDERSTORM;
    	}
    	else if (dP_dt > 0.25)
    	{
    		forecast = UNSTABLE;
    	}
    	else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
    	{
    		forecast = CLOUDY;
    	}
    	else if ((dP_dt > 0.05) && (dP_dt < 0.25))
    	{
    		forecast = SUNNY;
    	}
    	else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
    	{
    		forecast = STABLE;
    	}
    	else
    	{
    		forecast = UNKNOWN;
    	}
    
    	// uncomment when debugging
    	//Serial.print(F("Forecast at minute "));
    	//Serial.print(minuteCount);
    	//Serial.print(F(" dP/dt = "));
    	//Serial.print(dP_dt);
    	//Serial.print(F("kPa/h --> "));
    	//Serial.println(weather[forecast]);
    
    	return forecast;
    }
    
    long readVcc() {
      
      // Read 1.1V reference against AVcc
      ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      delay(2); // Wait for Vref to settle
      ADCSRA |= _BV(ADSC); // Convert
      while (bit_is_set(ADCSRA,ADSC));
      result = ADCL;
      result |= ADCH<<8;
      result = 1126400L / result; // Back-calculate AVcc in mV
      return result;
    }
    

    Sensor output:

    **Temperature = 20.90 C
    Pressure = 1005.88 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=fail:1005.9
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=fail:4.037
    Temperature = 20.90 C
    Pressure = 1005.90 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=fail:1005.9
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=fail:4.037
    Temperature = 20.90 C
    Pressure = 1005.81 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=fail:1005.8
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=fail:4.037
    find parent
    send: 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
    read: 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    parent=0, d=1
    Temperature = 20.90 C
    Pressure = 1005.92 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1005.9
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:4.037
    Temperature = 21.20 *C
    Pressure = 1005.95 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1006.0
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:4.037
    Temperature = 21.20 *C
    Pressure = 1005.96 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1006.0
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:4.037
    Temperature = 21.20 *C
    Pressure = 1005.93 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1005.9
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:4.037
    Temperature = 21.20 C
    Pressure = 1006.01 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1006.0
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=fail:4.037
    Temperature = 21.20 C
    Pressure = 1005.89 hPa
    Forecast = stable
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1005.9
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=fail:4.037

    /////

    Gateway code, without any change from original sketch

    /**
     * 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 WITH_LEDS_BLINKING in MyConfig.h
     * - 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 
     * 
     */
    
    #define NO_PORTB_PINCHANGES  
    
    #include <MySigningNone.h>
    #include <MyTransportRFM69.h>
    #include <MyTransportNRF24.h>
    #include <MyHwATMega328.h>
    #include <MySigningAtsha204Soft.h>
    #include <MySigningAtsha204.h>
    
    #include <SPI.h>  
    #include <MyParserSerial.h>  
    #include <MySensor.h>  
    #include <stdarg.h>
    #include <PinChangeInt.h>
    #include "GatewayUtil.h"
    
    #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
    #define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button
    #define RADIO_ERROR_LED_PIN 4  // Error led pin
    #define RADIO_RX_LED_PIN    6  // Receive led pin
    #define RADIO_TX_LED_PIN    5  // the PCB, on board LED
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
    //MyTransportRFM69 transport;
    
    // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    //MySigningNone signer;
    //MySigningAtsha204Soft signer;
    //MySigningAtsha204 signer;
    
    // Hardware profile 
    MyHwATMega328 hw;
    
    // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
    #ifdef WITH_LEDS_BLINKING
    MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
    #else
    MySensor gw(transport, hw /*, signer*/);
    #endif
    
    char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
    int inputPos = 0;
    boolean commandComplete = false;  // whether the string is complete
    
    void parseAndSend(char *commandBuffer);
    
    void output(const char *fmt, ... ) {
       va_list args;
       va_start (args, fmt );
       vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
       va_end (args);
       Serial.print(serialBuffer);
    }
    
      
    void setup()  
    { 
      gw.begin(incomingMessage, 0, true, 0);
    
      setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
    
      // Add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
    
    
      // Send startup log message on serial
      serial(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
    }
    
    void loop()  
    { 
      gw.process();
    
      checkButtonTriggeredInclusion();
      checkInclusionFinished();
      
      if (commandComplete) {
        // A command wass issued from serial interface
        // We will now try to send it to the actuator
        parseAndSend(gw, inputString);
        commandComplete = false;  
        inputPos = 0;
      }
    }
    
    
    /*
      SerialEvent occurs whenever a new data comes in the
     hardware serial RX.  This routine is run between each
     time loop() runs, so using delay inside loop can delay
     response.  Multiple bytes of data may be available.
     */
    void serialEvent() {
      while (Serial.available()) {
        // get the new byte:
        char inChar = (char)Serial.read(); 
        // if the incoming character is a newline, set a flag
        // so the main loop can do something about it:
        if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) { 
          if (inChar == '\n') {
            inputString[inputPos] = 0;
            commandComplete = true;
          } else {
            // add it to the inputString:
            inputString[inputPos] = inChar;
            inputPos++;
          }
        } else {
           // Incoming message too long. Throw away 
            inputPos = 0;
        }
      }
    }
    

    Output from Gateway not possible since it is in use by Domoticz. Of course I can disconnect it for test but I don't think Sensor will work correctly without a controller.

    Domoticz log:

    2016-01-05 14:06:15.639 (Test_First) General/Voltage (Voltage_strom)
    2016-01-05 14:08:26.481 (Test_First) General/Voltage (Voltage_strom)
    2016-01-05 14:09:32.184 (Test_First) General/Voltage (Voltage_strom)

    Missing minute 7

    Questions:

    1. Any ideas what this can be or is this normal?

    2. Why do it suddenly says Find parent, is it because it fails for both data that sensor should send? I have seen that if one fails it doesn't say Find parent.

    3. Why does it send Pressure when the code say, IF new is same as last don't send.

    Thanks

    EDIT: added more Sensor output
    EDIT2: distance between sensor and gateway is 1 meter
    EDIT3: add question 3
    EDIT4: Gateway as Pro Mini



  • I disconnected Serial gateway from Domoticz and it seems to work anyway, but not receive the data in Domoticz of course

    I aslo added delay(100) after each gw.send

    It seems that Gateway gets the data but not tells the sensor OK

    I also saw that there is an extra -0 at sensor data but not in gateway, BOLD below

    Gateway:
    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;read: 2-2-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.0
    2;1;1;0;0;21.0
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=4,pt=7,l=5,sg=0:1006.3
    2;0;1;0;4;1006.3
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=4,pt=7,l=5,sg=0:1006.3
    2;0;1;0;4;1006.3
    0;0;3;0;9;read: 2-2-0 s=2,c=1,t=38,pt=7,l=5,sg=0:4.037
    2;2;1;0;38;4.037

    Sensor:
    Temperature = 21.00 *C
    Pressure = 1006.31 hPa
    Forecast = unknown
    send: 2-2-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:21.0
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1006.3
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=fail:4.037
    Temperature = 21.00 *C
    Pressure = 1006.29 hPa
    Forecast = unknown
    send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=fail:1006.3
    403
    send: 2-2-0-0 s=2,c=1,t=38,pt=7,l=5,sg=0,st=ok:4.037


  • Hardware Contributor

    Hi!
    Do you have any caps on the radio(s)?



  • @sundberg84
    Yes, on both



  • @flopp said:

    I aslo added delay(100) after each gw.send

    I saw that I had forgot to put the delay for TEMP, i add it and now it seems to be better



  • @flopp said:

    Questions:
    3.Why does it send Pressure when the code say, IF new is same as last don't send.

    I read the code again, and I have not change this part of the code

    float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
    
    Serial.print("Pressure = ");
        Serial.print(pressure);
    

    Pressure is a float so it will get decimals when it reads from BMP.

    
    if (pressure != lastPressure) 
        {
            gw.send(pressureMsg.set(pressure, 1));
            lastPressure = pressure;
        }
    

    This will almost every time send data because there are two decimals which will change.

    I changed it to INT instead of FLOAT and now I get value without decimals and it will not send data every loop, if it not changes of course



  • did you change the caps? I had massive problem with 4,7nF Caps at my gateway: random fails when transmitting. I now use 100nF and 4,7nF at the gateway and it works like a charm



  • @dakky said:

    did you change the caps? I had massive problem with 4,7nF Caps at my gateway: random fails when transmitting. I now use 100nF and 4,7nF at the gateway and it works like a charm

    I have not solder them there, will do now.

    I saw some fails again 😔 after it worked for 10-15 minutes without any fail

    I think you mean uF not nF? Guide says uF.



  • of course u're right. was a little brainf*ck 😉
    soldering or not does not change anything as long as the parts are fixed.



  • I know but I just put the cap pin in a hole of the dupont cable.


  • Hero Member

    Once I had similar problems, a 4.7nF cap and gw.wait(100) after each transmit did the trick for me... Hope it helps somehow.



  • @rvendrame
    Where did you put ge.wait, sensor code or gateway code?


  • Hero Member

    @flopp said:

    @rvendrame
    Where did you put ge.wait, sensor code or gateway code?

    Sensor. And capacitors on both.



  • @rvendrame said:

    Sensor. And capacitors on both.

    sorry for asking so much 😄
    after each gw.send?


  • Hero Member

    @flopp said:

    sorry for asking so much
    after each gw.send?

    Yes



  • @rvendrame said:

    @flopp said:

    sorry for asking so much
    after each gw.send?

    Yes

    Thanks



  • It have now been running for 35 minutes without any error, 100uF on both NRF. Delay(100); after each gw.send. Will try later to remove that and see it the problem was the caps.

    Thanks everyone 👊



  • During I wrote above reply it reported 3 fails!!!
    I hope that was just a glitch and will let it run without any changes


  • Hardware Contributor

    What do you power the nodes with? Since it seems to work better with caps on, there might be something to your power or wiring you can do to make it better.



  • @sundberg84 said:

    What do you power the nodes with? Since it seems to work better with caps on, there might be something to your power or wiring you can do to make it better.

    I wrote it in first post, no hard feelings

    sensor, lipo batt
    gateway, usb from PC


  • Hardware Contributor

    Sorry m8. My thought was that depending how you run power and ground in your ciriut it can disturb the radio. For example i had a 5v arduino with a 5v relay and if i didn run the ground through the arduino but instead direct to ground the radio got to many spikes and i got really much st:fails.



  • @sundberg84

    no worries, I done it my self my times.

    Right now I think the problem was a loose cap or bad/small cap. Before I used a 4.7uF, no I have one 100uF on each NRF.


  • Hardware Contributor

    Yea, thats kind of interesting... i have 25+ nodes and everyone except the gateway runs on 4.7 only and it works great... but if that works for you im glad!



  • @rvendrame said:

    Once I had similar problems, a 4.7nF cap and gw.wait(100) after each transmit did the trick for me... Hope it helps somehow.

    I also got to this solution when experienced the same 'st:fail' issue. The arduino's delay wont help, because it wont receive anything from radio during the delay.

    As i got mutch less or no error with ack = false, I thing its linked to receiving some ACK packets. I have no deeper information or debugging possibilities at the moment.


Log in to reply
 

Suggested Topics

  • 3
  • 8
  • 2
  • 6
  • 6

7
Online

11.4k
Users

11.1k
Topics

112.7k
Posts