Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. st:fail sometimes and sometimes OK

st:fail sometimes and sometimes OK

Scheduled Pinned Locked Moved Troubleshooting
24 Posts 5 Posters 6.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    flopp
    wrote on last edited by flopp
    #1

    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

    F 1 Reply Last reply
    0
    • F Offline
      F Offline
      flopp
      wrote on last edited by flopp
      #2

      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

      F 1 Reply Last reply
      0
      • sundberg84S Offline
        sundberg84S Offline
        sundberg84
        Hardware Contributor
        wrote on last edited by
        #3

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

        Controller: Proxmox VM - Home Assistant
        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

        F 1 Reply Last reply
        0
        • sundberg84S sundberg84

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

          F Offline
          F Offline
          flopp
          wrote on last edited by
          #4

          @sundberg84
          Yes, on both

          1 Reply Last reply
          0
          • F flopp

            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

            F Offline
            F Offline
            flopp
            wrote on last edited by
            #5

            @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

            1 Reply Last reply
            0
            • F flopp

              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

              F Offline
              F Offline
              flopp
              wrote on last edited by flopp
              #6

              @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

              1 Reply Last reply
              0
              • dakkyD Offline
                dakkyD Offline
                dakky
                wrote on last edited by
                #7

                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

                Controller: Raspberry Pi 2 :: Openhab2 :: with @TimO MySensors Binding
                Gateway: Arduino MEGA 2560 R3 :: W5100 :: Ethernet GW

                Software: MySensors 2.0development

                F 1 Reply Last reply
                0
                • dakkyD dakky

                  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

                  F Offline
                  F Offline
                  flopp
                  wrote on last edited by
                  #8

                  @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 :pensive: after it worked for 10-15 minutes without any fail

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

                  1 Reply Last reply
                  0
                  • dakkyD Offline
                    dakkyD Offline
                    dakky
                    wrote on last edited by
                    #9

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

                    Controller: Raspberry Pi 2 :: Openhab2 :: with @TimO MySensors Binding
                    Gateway: Arduino MEGA 2560 R3 :: W5100 :: Ethernet GW

                    Software: MySensors 2.0development

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      flopp
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • rvendrameR Offline
                        rvendrameR Offline
                        rvendrame
                        Hero Member
                        wrote on last edited by
                        #11

                        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.

                        Home Assistant / Vera Plus UI7
                        ESP8266 GW + mySensors 2.3.2
                        Alexa / Google Home

                        F M 2 Replies Last reply
                        0
                        • rvendrameR rvendrame

                          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.

                          F Offline
                          F Offline
                          flopp
                          wrote on last edited by
                          #12

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

                          1 Reply Last reply
                          0
                          • rvendrameR Offline
                            rvendrameR Offline
                            rvendrame
                            Hero Member
                            wrote on last edited by
                            #13

                            @flopp said:

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

                            Sensor. And capacitors on both.

                            Home Assistant / Vera Plus UI7
                            ESP8266 GW + mySensors 2.3.2
                            Alexa / Google Home

                            F 1 Reply Last reply
                            0
                            • rvendrameR rvendrame

                              @flopp said:

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

                              Sensor. And capacitors on both.

                              F Offline
                              F Offline
                              flopp
                              wrote on last edited by
                              #14

                              @rvendrame said:

                              Sensor. And capacitors on both.

                              sorry for asking so much :smile:
                              after each gw.send?

                              rvendrameR 1 Reply Last reply
                              0
                              • F flopp

                                @rvendrame said:

                                Sensor. And capacitors on both.

                                sorry for asking so much :smile:
                                after each gw.send?

                                rvendrameR Offline
                                rvendrameR Offline
                                rvendrame
                                Hero Member
                                wrote on last edited by
                                #15

                                @flopp said:

                                sorry for asking so much
                                after each gw.send?

                                Yes

                                Home Assistant / Vera Plus UI7
                                ESP8266 GW + mySensors 2.3.2
                                Alexa / Google Home

                                F 1 Reply Last reply
                                0
                                • rvendrameR rvendrame

                                  @flopp said:

                                  sorry for asking so much
                                  after each gw.send?

                                  Yes

                                  F Offline
                                  F Offline
                                  flopp
                                  wrote on last edited by
                                  #16

                                  @rvendrame said:

                                  @flopp said:

                                  sorry for asking so much
                                  after each gw.send?

                                  Yes

                                  Thanks

                                  1 Reply Last reply
                                  0
                                  • F Offline
                                    F Offline
                                    flopp
                                    wrote on last edited by
                                    #17

                                    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 👊

                                    1 Reply Last reply
                                    0
                                    • F Offline
                                      F Offline
                                      flopp
                                      wrote on last edited by
                                      #18

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

                                      1 Reply Last reply
                                      0
                                      • sundberg84S Offline
                                        sundberg84S Offline
                                        sundberg84
                                        Hardware Contributor
                                        wrote on last edited by
                                        #19

                                        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.

                                        Controller: Proxmox VM - Home Assistant
                                        MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                                        MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                                        RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                                        F 1 Reply Last reply
                                        0
                                        • sundberg84S sundberg84

                                          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.

                                          F Offline
                                          F Offline
                                          flopp
                                          wrote on last edited by
                                          #20

                                          @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

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


                                          21

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular