Skip to content
  • 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
P

palmerfarmer

@palmerfarmer
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
17
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • My 2AA battery sensor
    P palmerfarmer

    I got it from CPC in the UK which are owned by Farnell
    https://cpc.farnell.com/hammond/1593qgy/case-with-bat-compart-110x66x28mm/dp/EN82140
    You may have to make a slight mod to the board or enclosure to make it fit.
    good luck

    My Project

  • 2 or more DHT22 on 1 node with Domoticz
    P palmerfarmer

    I wonder if any one can help with my (hacked and borrowed) sketch that inlcudes x2 DHT22 sensors on one node. Before I start I think my problem is the way Domoticz handles the data so this post probably shouldn't even be on here.
    My sketch below works in the Mysensors serial monitor and i even have a version with a TFT lcd display, all correct. The problem is when it appears in domoticz the humidity from one sensor appears on the other and the 2nd hum is ignored.... for a few seconds it then randomly appears on the correct sensor. There seems to be a few posts problems but with no solution. Can anyone help?

    Mysensors 2.3.1
    Domoticz 4.11506
    Tested on Arduino nano and NodeMcu (same results)

    #define MY_RADIO_RF24
    #define MY_RF24_PA_LEVEL (RF24_PA_MIN)
    #define MY_NODE_ID 114
    
    //taken from the original and mysensors forum
    //http://forum.mysensors.org/topic/1393/2-or-more-dht11-sensors-on-one-arduino-nano-mysensor/8
    //http://forum.mysensors.org/topic/1462/getting-node-id-0-after-erasing-eeprom
    
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>           //dht22 
    
    
    //Definition of sensor
    #define CHILD_ID1_HUM 1
    #define CHILD_ID1_TEMP 3
    #define CHILD_ID2_HUM 2
    #define CHILD_ID2_TEMP 4
    
    const int HUMIDITY_SENSOR1_DIGITAL_PIN = D0;
    const int HUMIDITY_SENSOR2_DIGITAL_PIN = D1;
    
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    //MySensor;
    DHT dht1;
    DHT dht2;
    float lastTemp1;
    float lastHum1;
    float lastTemp2;
    float lastHum2;
    
    boolean metric = true; 
    MyMessage msgHum1(CHILD_ID1_HUM, V_HUM);
    MyMessage msgTemp1(CHILD_ID1_TEMP, V_TEMP);
    MyMessage msgHum2(CHILD_ID2_HUM, V_HUM);
    MyMessage msgTemp2(CHILD_ID2_TEMP, V_TEMP);
    
    void setup()  
    { 
      
     // begin();
      dht1.setup(HUMIDITY_SENSOR1_DIGITAL_PIN); 
      dht2.setup(HUMIDITY_SENSOR2_DIGITAL_PIN);
    
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo("2DHT22_ESP8266", "V2");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID1_HUM, S_HUM);
      present(CHILD_ID1_TEMP, S_TEMP);
      present(CHILD_ID2_HUM, S_HUM);
      present(CHILD_ID2_TEMP, S_TEMP);
    
    
     // metric = getConfig().isMetric;
        
    }
    
    void loop()      
      {
        
    //DHT 11 Sensor 1
    
      delay(dht1.getMinimumSamplingPeriod());
    
      float temperature1 = dht1.getTemperature();
      if (isnan(temperature1)) {
        Serial.println("Failed reading temperature from DHT 1");
      } else if (temperature1 != lastTemp1) {
        lastTemp1 = temperature1;
        if (!metric) {
        temperature1 = dht1.toFahrenheit(temperature1);
        }
        send(msgTemp1.set(temperature1, 1));
        Serial.print("T1: ");
        Serial.println(temperature1);
      
      }
      float humidity1 = dht1.getHumidity();
      if (isnan(humidity1)) {
        Serial.println("Failed reading humidity from DHT 1");
      } else if (humidity1 != lastHum1) {
        lastHum1 = humidity1;
        send(msgHum1.set(humidity1, 1));
        Serial.print("H1: ");
        Serial.println(humidity1);
    
      }
    
    delay(500);
    
    // DHT11 Sensor 2
    {
      delay(dht2.getMinimumSamplingPeriod());
    
      float temperature2 = dht2.getTemperature();
      if (isnan(temperature2)) {
        Serial.println("Failed reading temperature from DHT 2");
      } else if (temperature2 != lastTemp2) {
        lastTemp2 = temperature2;
        if (!metric) {
        temperature2 = dht2.toFahrenheit(temperature2);
        }
        send(msgTemp2.set(temperature2, 1));
        Serial.print("T2: ");
        Serial.println(temperature2);
    
      }
      float humidity2 = dht2.getHumidity();
      if (isnan(humidity2)) {
        Serial.println("Failed reading humidity from DHT 2");
      } else if (humidity2 != lastHum2) {
        lastHum2 = humidity2;
        send(msgHum2.set(humidity2, 1));
        Serial.print("H2: ");
        Serial.println(humidity2);
    
        }
      
       
      sleep(SLEEP_TIME); //sleep a bit
    
      delay (2000);
    }
    }
    
    Troubleshooting

  • Why are the measured values so different? Are my humidity sensors faulty?
    P palmerfarmer

    @benhub do you have the code the links seem dead? Ive been trying to get 2 temp/hum sensors (DHT22) working in domoticz for quite a while now with no luck. The temp/hum data in domotcz keeps swapping around from one sensor to the other and i cant work out why.

    Hardware

  • Multiple BME280 sensor for Domoticz
    P palmerfarmer

    Thanks for the reply and spotting one of my many errors (now corrected amongst others!).
    Managed to get one of them showing up in Domoticz, lets see if i can get them both in there without the temp hum being crossed over between physical sensors. There seems to be a few posts about this problem.

    Troubleshooting

  • Multiple BME280 sensor for Domoticz
    P palmerfarmer

    Hi,
    I'm trying to build a node that uses x2 BME280 sensors for a whole house fan controller, one inside temp/hum and one outside. The BME280 has a selectable I2C address by grounding the SDO pin on the sensor. I have successfully tested this using the BlueDot_BME280.h library and sketches.
    Problem I am having is turning this sketch into a working Mysensors node I can use in domoticz. I think I'm almost there but cannot see why i am getting an 'invalid use of non-static member function' message.
    here is my hacked code...

    I thought i would try and get it working with one BME280 first..

    
    /***************************************************************************
      Example for BME280 Weather Station using two Sensors with I2C Protocol
      written by Thiago Barros for BlueDot UG (haftungsbeschränkt)
      BSD License
    
      This sketch was written for the Bosch Sensor BME280.
      The BME280 is a MEMS device for measuring temperature, humidity and atmospheric pressure.
      For more technical information on the BME280, please go to ------> http://www.bluedot.space
    
     ***************************************************************************/
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    //#define MY_RF24_CE_PIN 49 //only required for Mega
    //#define MY_RF24_CS_PIN 53 //only required for Mega
    #define MY_RF24_PA_LEVEL (RF24_PA_MIN)
    #define MY_NODE_ID 57
    
    #include <SPI.h>
    #include <Wire.h>
    #include "BlueDot_BME280.h"
    #include <MySensors.h>
    
    
    
    #define BARO_CHILD 0 //these will appear in domoticz child list for this node
    #define TEMP_CHILD 1
    #define HUM_CHILD 2
    
    long interval = 60000;           // interval at which to send (milliseconds)
    long previousMillis = interval;        // will store last time data was sent
    
    BlueDot_BME280 bme1;                                     //Object for Sensor 1
    BlueDot_BME280 bme2;                                     //Object for Sensor 2
    
    int bme1Detected = 0;
    ///int bme2Detected = 0;
    
    float dP_dt;
    boolean metric;
    MyMessage tempMsg(TEMP_CHILD, V_TEMP);
    MyMessage humMsg(HUM_CHILD, V_HUM);
    MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
    
    void setup() {
    
    metric = getControllerConfig().isMetric;  // was getConfig().isMetric; before MySensors v2.1.1
      Wire.begin(); // Wire.begin(sda, scl)
      // use the 1.1 V internal reference
    #if defined(__AVR_ATmega2560__)
      analogReference(INTERNAL1V1);
    #else
      analogReference(INTERNAL);
    #endif
    
      Serial.begin(115200);
     
    
      bme1.parameter.communication = 0;                    //Setting communication for Sensor 1 (bme1)
     // bme2.parameter.communication = 0;                    //Setting communication for Sensor 2 (bme2)
      bme1.parameter.I2CAddress = 0x77;                    //I2C Address for Sensor 1 (bme1)
     // bme2.parameter.I2CAddress = 0x76;                    //I2C Address for Sensor 2 (bme2)
      bme1.parameter.sensorMode = 0b11;                    //In normal mode the sensor measures continually (default value)
    //  bme2.parameter.sensorMode = 0b11;
      bme1.parameter.IIRfilter = 0b000;                   //factor 0 (filter off)
     // bme2.parameter.IIRfilter = 0b000;                   //factor 16 (default value)
      bme1.parameter.humidOversampling = 0b101;            //factor 16
     // bme2.parameter.humidOversampling = 0b101;            //factor 16
      bme1.parameter.tempOversampling = 0b101;              //factor 16
     // bme2.parameter.tempOversampling = 0b101;              //factor 16
      bme1.parameter.pressOversampling = 0b101;             //factor 16
    //  bme2.parameter.pressOversampling = 0b101;             //factor 16
      bme1.parameter.tempOutsideCelsius = 10;               //default value of 15°C
     // bme2.parameter.tempOutsideCelsius = 10;               //default value of 15°C
    
      if (bme1.init() != 0x60)
      {
        Serial.println(F("First BME280 Sensor not found!"));
        Serial.println(F("Please check your connections."));
        bme1Detected = 0;
      }
      else
      {
        Serial.println(F("First BME280 Sensor detected!"));
        bme1Detected = 1;
      }
     
      
      Serial.println();
      Serial.println();
    
    }
    
    
    void presentation() {
      sendSketchInfo("BME x2 I2C master ", "V2.a");
    
      // Register sensors to gw (they will be created as child devices)
      present(BARO_CHILD, S_BARO);
      present(TEMP_CHILD, S_TEMP);
      present(HUM_CHILD, S_HUM);
    
    }
    
    void loop() {
    
    
      Serial.print(F("Duration in Seconds:\t\t\t\t"));
      Serial.println(float(millis()) / 1000);
    
      if (bme1Detected)
      {
        Serial.print(F("Temperature in Celsius from Sensor 1:\t\t"));
        Serial.println(bme1.readTempC());
        Serial.print(F("Humidity in % from Sensor 1:\t\t\t"));
        Serial.println(bme1.readHumidity());
        Serial.print(F("Pressure in hPa from Sensor 1:\t\t\t"));
        Serial.println(bme1.readPressure());
      }
      else
      {
        Serial.print(F("Temperature in Celsius from Sensor 1:\t\t"));
        Serial.println(F("Null"));
        Serial.print(F("Humidity in % from Sensor 1:\t\t\t"));
        Serial.println(F("Null"));
        Serial.print(F("Pressure in hPa from Sensor 1:\t\t\t"));
        Serial.println(F("Null"));
      {
    
    
        send(humMsg.set(bme1.readHumidity, 1));
    wait(50);
    
      //  send(humMsg.set(humidity, 1));
    //wait(50);
    
      delay(5000);
    }
    }}
    
    Troubleshooting

  • Clock Sketch (RTC) modified for 1.8" LCD
    P palmerfarmer

    Thanks for the speedy reply, I owe you a beer! works perfectly.
    UTFT clockB (2).jpg

    Troubleshooting

  • Clock Sketch (RTC) modified for 1.8" LCD
    P palmerfarmer

    Just embarking on making the 'Real Time Clock Module, LCD Display and Controller Time' sketch to use with a 1.8" lcd 128x160 ST7735. Problem i have is trying to get it to display the correct format of time.
    eg I would like to display:-
    06:03:09 instead of 6: 3: 9 for the time and equivelant for the date too. This is a problem when the numbers reach double figures as you get false times because it doenst clear.

    I think i need to use something similar to this;

    if (digits < 10)
    myGLCD.printNumI('0');

    I am using the UTFT libraires but cannot work out the correct syntax.
    the pic below is not a great example as the time when i took this was all double digit numbers the date and month are single. but need it to say 06/01/20

    UTFT clock (2).jpg
    below is my code

    /**
       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.
    
     *******************************
    
      NB uses 1.8inch LCD rememeber to edit the memorysaver.h file and only leave ST7735
    
       REVISION HISTORY
       Version 1.0 - Henrik Ekblad
    
       DESCRIPTION
       Example sketch showing how to request time from controller which is stored in RTC module
       The time and temperature (DS3231/DS3232) is shown on an attached Crystal LCD display
    
    
       Wiring (radio wiring on www.mysensors.org)
       ------------------------------------
       Arduino   RTC-Module     I2C Display
       ------------------------------------
       GND       GND            GND
       +5V       VCC            VCC
       A4        SDA            SDA
       A5        SCL            SCL
    
       http://www.mysensors.org/build/display
    
    */
    
    // Enable debug prints to serial monitor
    //#define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_RF24
    #define MY_RF24_PA_LEVEL (RF24_PA_MIN)
    #define MY_NODE_ID 40
    
    
    //#define MY_RADIO_RFM69
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <TimeLib.h> //this is where tm.Hour tm.Min comes from
    #include <DS3232RTC.h>  // A  DS3231/DS3232 library
    #include <Wire.h>
    #include <UTFT.h>
    
    extern uint8_t BigFont[];
    //extern uint8_t SmallFont[];
    extern uint8_t Grotesk16x32[];
    
    
    UTFT myGLCD(ITDB18SP, 5, 4, 8, 7, 6); //remember to edit the memorysaver.h file and only leave ST7735XX
    
    
    bool timeReceived = false;
    unsigned long lastUpdate = 0, lastRequest = 0;
    
    
    void setup()
    {
      // the function to get the time from the RTC
      setSyncProvider(RTC.get);
    
      // Request latest time from controller at startup
      requestTime();
    
      // initialize the lcd fort
    
      myGLCD.InitLCD(LANDSCAPE);// or PORTRAIT
      myGLCD.clrScr();
    
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Clock Basic Master", "2.0");
    }
    
    // This is called when a new time value was received
    void receiveTime(unsigned long controllerTime) {
      // Ok, set incoming time
      //Serial.print("Time value received: ");
      //Serial.println(controllerTime);
      RTC.set(controllerTime); // this sets the RTC to the time from controller - which we do want periodically
      timeReceived = true;
    }
    
    void loop()
    {
    
      myGLCD.setColor(255, 255, 255);
    
      unsigned long now = millis();
    
      // If no time has been received yet, request it every 10 second from controller
      // When time has been received, request update every hour
      if ((!timeReceived && (now - lastRequest) > (10UL * 1000UL))
          || (timeReceived && (now - lastRequest) > (60UL * 1000UL * 60UL))) {
        // Request time from controller.
        //Serial.println("requesting time");
        requestTime();
        lastRequest = now;
      }
    
      // Update display every second
      if (now - lastUpdate > 1000) {
        updateDisplay();
        lastUpdate = now;
      }
    }
    
    
    void updateDisplay() {
      tmElements_t tm;
      RTC.read(tm);
    
    
      // Print date and time
      //lcd.home();
    
      myGLCD.setColor(80, 80, 200);
      myGLCD.setFont(Grotesk16x32);
      myGLCD.printNumI(tm.Hour, 10 , 20);
      myGLCD.print(":", 45, 20);
      myGLCD.printNumI(tm.Minute, CENTER, 20);
      myGLCD.print(":", 100, 20);
      myGLCD.printNumI(tm.Second, 115, 20);
    
    
      myGLCD.setFont(BigFont);
      myGLCD.setColor(255, 255, 0);
      myGLCD.printNumI(tm.Day, 15 , 65);
      myGLCD.print("/", 45, 65);
      myGLCD.printNumI(tm.Month, CENTER, 65);
      myGLCD.print("/" , 90, 65);
      myGLCD.printNumI(tmYearToCalendar(tm.Year) - 2000, 110, 65);
    
    
      myGLCD.print("T: ", 30, 95);
      myGLCD.printNumI(RTC.temperature() / 4, CENTER, 95 );
      myGLCD.print("o", 95, 90); // Degree-sign
      myGLCD.print("C", 107, 95);
    
    
    }
    
    /*
      void print2digits(int number) {
      if (number >= 0 && number < 10) {
        myGLCD.print("0",CENTER, 65 );
      }
      //   myGLCD.print(number);
      }
    
    
    
    
      /*
    
      void printNumI(int digits) {
      if (digits < 10)
      myGLCD.printNumI('0');
      myGLCD.print(digits);
    
      /*
      original sketch had this below for 16x4 LCD
    
      void printDigits(int digits) {
      if (digits < 10)
        lcd.print('0');
      lcd.print(digits);
    
    
    
    
      }
    */
    Troubleshooting

  • Multiple DHT22 in one sensor for greenhouse (newbee question)
    P palmerfarmer

    Is there a way i could display the temp and hum for each sensor on an lcd screen?
    I know how to do this for data that is not using pointers.
    below is my sketch that flips between 2 sensors on the LCD

    /* test modified from a v1 basic mutliple multi dht22 sketch
    
        Gives correct temp and humidity readings for each dht22 in domoticz (ie not crossed between 1 and 2)
    
        Not displaying properly on the LCD yet
    
        Domoticz ver 4.11558 beta
        Gateway 3.2.1
        node 3.2.1
        09/12/2019
    
         Arduino Mega
         1.8 inch TFT LCD Display 128x160 8/16Bit ST7735S
         x2 DHT22
         NRF24
    */
    
    #define MY_DEBUG
    #define MY_RADIO_NRF24    //Mega Pins 49 CE, 53 CSN/CS, 52 SCK, 51  MOSI, 50  MISO
    #define MY_RF24_CE_PIN 49
    #define MY_RF24_CS_PIN 53
    #define MY_RF24_PA_LEVEL (RF24_PA_MIN)
    #define MY_NODE_ID 103
    
    
    #include <UTFT.h>          //LCD 1.8
    #include <SPI.h>
    #include <MySensors.h>
    #include <DHT.h>
    
    #define RELAY1 44
    #define RELAY2 45
    
    
    //static const uint8_t FORCE_UPDATE_N_READS = 10;
    extern uint8_t BigFont[];
    extern uint8_t SmallFont[];
    
    #define NUM_SENSORS 2
    
    unsigned long SLEEP_TIME = 6000; // Sleep time between reads (in milliseconds)
    
    //MySensor gw;
    MyMessage tempMssg(0, V_TEMP);
    MyMessage humMssg(NUM_SENSORS, V_HUM);
    
    byte tempID[NUM_SENSORS] = {0, 1};
    byte humID[NUM_SENSORS] = {2, 3};
    
    DHT* dht[NUM_SENSORS];
    byte sensorPin[NUM_SENSORS] = {40, 42};
    float lastTemp[NUM_SENSORS] = {0.0, 0.0};
    float lastHum[NUM_SENSORS] = {0.0, 0.0};
    
    boolean metric = true;
    
    
    //LCD setup
    UTFT myGLCD(ITDB18SP, 11, 12, 8, 9, 10); // lcd pins 3,2,6,5,4
    
    
    
    void setup()
    {
    
      myGLCD.InitLCD(LANDSCAPE);// or PORTRAIT
      myGLCD.clrScr();
      myGLCD.setColor(200, 255, 255);
      myGLCD.setBackColor(0, 0, 0);
      myGLCD.setFont(SmallFont);
      myGLCD.print("Version & Sketch", LEFT, 3);
      myGLCD.print("V.2 TEST5", LEFT, 16);
      delay(1000);
      myGLCD.clrScr();
      myGLCD.setFont(SmallFont);
      myGLCD.setColor(255, 255, 255);
    
      myGLCD.print("TH1 OUTSIDE", 2, 2);
      myGLCD.print("o", 67, 12);
      myGLCD.print("C", 74, 15);
      myGLCD.print("%", 150, 15);
    
      myGLCD.print("TH2 INSIDE", 2, 36);
      myGLCD.print("o", 67, 46);
      myGLCD.print("C", 74, 49);
      myGLCD.print("%", 150, 49);
    
    
    
      Serial.begin(9600);
      // begin();
      for (int i = 0; i < NUM_SENSORS; i++)
      {
        dht[i] = new DHT;
        dht[i]->setup(sensorPin[i]);
      }
    
      sendSketchInfo("DHT22 Humidity test5", "2.0");
    
      for (int i = 0; i < NUM_SENSORS; i++)
      {
        present(tempID[i], S_TEMP);
        present(humID[i], S_HUM);
      }
      metric = getControllerConfig().isMetric;
    
      Serial.println(F("Setup Complete."));
    }
    
    void loop()
    {
      for (int i = 0; i < NUM_SENSORS; i++)
      {
        delay(dht[i]->getMinimumSamplingPeriod());
        float temperature = dht[i]->getTemperature();
        if (isnan(temperature))
        {
          Serial.print(F("Failed reading temperature from DHT"));
          Serial.println(i);
        }
        else if (temperature != lastTemp[i])
        {
          lastTemp[i] = temperature;
          if (!metric)
          {
            temperature = dht[i]->toFahrenheit(temperature);
          }
          send(tempMssg.setSensor(i).set(temperature, false));  // no ack
          Serial.print(F("T"));
          Serial.print(i);
          Serial.print(F("= "));
          Serial.println(temperature);
        }
        myGLCD.setFont(BigFont);
        myGLCD.setColor(100, 255, 255);
        myGLCD.printNumF(temperature, 1, 1, 15);  // this where something needs to be changed to get it to display each temp separately
    
    
    
        float humidity = dht[i]->getHumidity();
        if (isnan(humidity))
        {
          Serial.print("Failed reading humidity from DHT");
          Serial.println(i);
        }
        else if (humidity != lastHum[i])
        {
          lastHum[i] = humidity;
          send(humMssg.setSensor(i).set(humidity, false));  // no ack
          Serial.print(F("H"));
          Serial.print(i);
          Serial.print(F("= "));
          Serial.println(humidity); // this where something needs to be changed to get it to display each hum separately
    
          myGLCD.setFont(BigFont);
          myGLCD.setColor(100, 255, 255);
          myGLCD.printNumF(humidity, 1, 85, 15);
    
        }
      }
      sleep(SLEEP_TIME); //sleep a bit
    }```
    Troubleshooting multiple dht22

  • AC Dimmer with OpenHab
    P palmerfarmer

    How easy is this to convert to work with domoticz?

    OpenHAB

  • Anyone help with 4 relays please?
    P palmerfarmer

    Ah ok, good to know. I also spoke too soon....
    Today they were unstable, I noticed that some of the on /off commands were not being recieved (small LED flash on the arduino) looked at the logs on domoricz they were fine, however the serial monitor on the arduino node confirmed they weren't always being seen.
    Have changed the mysensors libraries on the node to be the same as the usb gateway and its all stable again.
    next action will be to monitor the logs on the gateway, node and domoticz at the same time

    I have one of those blue 4 relay units from ebay, the jumper has been removed so only the LED lights when i activate the channel.

    Troubleshooting

  • My 2AA battery sensor
    P palmerfarmer

    11months on battery at 87%... still working!0_1574260268012_BME280 battery.JPG

    My Project

  • Anyone help with 4 relays please?
    P palmerfarmer

    I Know this is quite an old topic now but mine is working quite stable (for at least one day)
    I noticed the sketch has
    #define MY_RF24_PA_LEVEL RF24_PA_HIGH
    If you are too close to the gateway or using a capacitor across the 3v rail on the NRF24L01 and switching quickly you really have no chance of it being stable. (or any of one these 3 things)
    I have mine set to:-
    #define MY_RF24_PA_LEVEL (RF24_PA_MIN)
    and using a 5v to 3v NRF plugin module, search ebay for 'NRF24L01 Wireless RF Transceiver Socket Adapter Board 3.3v'

    Troubleshooting

  • My 2AA battery sensor
    P palmerfarmer

    Any Ver 2.xx,
    So I have cobbled together/hacked this and it seem to work, battery has stayed at 97% for 2 weeks now. Feel free to Hack about and improve i have this mounted on an easyPCB board, x2AA batteries, NRF radio, BME280 with a 3.3v convertor .

    /*   
    * use mysensors library 2.2.0
    * ALL WORKING AND TESTED ON EASY PCB BOARD WITH BATTERY SAVING CODE 29/11/18
    *
    * Time SET to 15 mins
    * also added BME280.writeMode (smSleep); to reduce quisecent to current to 40uA
    * BME280 sensor connections: 3.3v, 0V, SCL to A5, SDA to A4, BAT to A0
    **/
    
    //Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    #define MY_RF24_PA_LEVEL RF24_PA_MIN //settings are MIN, LOW, HIGH, MAX
    #define MY_NODE_ID 18
    //#define MY_RADIO_RFM69
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <Wire.h>
    #include <BME280_MOD-1022.h>
    
    // BME280 libraries and variables
    // Bosch BME280 Embedded Adventures MOD-1022 weather multi-sensor Arduino code
    // Written originally by Embedded Adventures
    // https://github.com/embeddedadventures/BME280
    
    
    #define BARO_CHILD 0
    #define TEMP_CHILD 1
    #define HUM_CHILD 2
    
    
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    
    unsigned long SLEEP_TIME = 15*60000;  // sleep time between reads (seconds x*1000 milliseconds)
    //unsigned long SLEEP_TIME = 20000;  // Debug test time 20 seconds
    int oldBatteryPcnt = 0;
    
        
    long interval = 1000;                // 1 min interval at which to send (milliseconds)
    long previousMillis = interval;        // will store last time data was sent
    
    const float ALTITUDE = 0; // <-- adapt this value to your location's altitude (in m). Use your smartphone GPS to get an accurate value!
    
    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)
    };
    
    
    const int LAST_SAMPLES_COUNT = 5;
    float lastPressureSamples[LAST_SAMPLES_COUNT];
    
    
    // this CONVERSION_FACTOR is used to convert from Pa to kPa in the forecast algorithm
    // get kPa/h by 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 humMsg(HUM_CHILD, V_HUM);
    MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
    
    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;
      }
    
      return forecast;
    }
    
    
    
    void setup() 
    
    {
       // use the 1.1 V internal reference
    #if defined(__AVR_ATmega2560__)
       analogReference(INTERNAL1V1);
    #else
       analogReference(INTERNAL);
    #endif
    
      metric = getControllerConfig().isMetric;  // was getConfig().isMetric; before MySensors v2.1.1
      Wire.begin(); // Wire.begin(sda, scl)
      // use the 1.1 V internal reference
      #if defined(__AVR_ATmega2560__)
      analogReference(INTERNAL1V1);
      #else
      analogReference(INTERNAL);
      #endif
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("BME280_BAT_V2", "V2e.");
    
      // Register sensors to gw (they will be created as child devices)
      present(BARO_CHILD, S_BARO);
      present(TEMP_CHILD, S_TEMP);
      present(HUM_CHILD, S_HUM);
    
    }
    
    // Loop
    void loop() {
    
    {
       // get the battery Voltage
       int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef MY_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
       // 3.44/1023 = Volts per bit = 0.003363075
    
       int batteryPcnt = sensorValue / 10;
    
       #ifdef MY_DEBUG
       float batteryV  = sensorValue * 0.003363075;
       Serial.print("Battery Voltage: ");
       Serial.print(batteryV);
       Serial.println(" V");
    
       Serial.print("Battery percent: ");
       Serial.print(batteryPcnt);
       Serial.println(" %");
       #endif
    
       if (oldBatteryPcnt != batteryPcnt) {
         // Power up radio after sleep
         sendBatteryLevel(batteryPcnt);
         oldBatteryPcnt = batteryPcnt;
       }
     //  sleep(SLEEP_TIME);
    }
    
    
    unsigned long currentMillis = millis();  
    
    if(currentMillis - previousMillis > interval) {
        // save the last time sent the data
        previousMillis = currentMillis;
    
      analogReference(INTERNAL);
      wait(500);
      
      // need to read the NVM compensation parameters
      BME280.readCompensationParams();
    
      // Normal mode for regular automatic samples
      BME280.writeStandbyTime(tsb_0p5ms);         // tsb = 0.5ms
      BME280.writeFilterCoefficient(fc_16);       // IIR Filter coefficient 16
      BME280.writeOversamplingPressure(os16x);    // pressure x16
      BME280.writeOversamplingTemperature(os8x);  // temperature x8
      BME280.writeOversamplingHumidity(os8x);     // humidity x8
      
      BME280.writeMode(smNormal);
    
        // Just to be sure, wait until sensor is done mesuring  
        while (BME280.isMeasuring()) {
      }
    
      // Read out the data - must do this before calling the getxxxxx routines
      BME280.readMeasurements();
    
      float temperature = BME280.getTemperatureMostAccurate();                    // must get temp first
      float humidity = BME280.getHumidityMostAccurate();
      float pressure_local = BME280.getPressureMostAccurate();                    // Get pressure at current location
      float pressure = pressure_local/pow((1.0 - ( ALTITUDE / 44330.0 )), 5.255); // Adjust to sea level pressure using user altitude
      int forecast = sample(pressure);
    
      if (!metric) 
      {
        // Convert to fahrenheit
        temperature = temperature * 9.0 / 5.0 + 32.0;
      }
    //**/
      Serial.println();
      Serial.print("Temperature = ");
      Serial.print(temperature);
      Serial.println(metric ? " °C" : " °F");
      Serial.print("Humidity = ");
      Serial.print(humidity);
      Serial.println(" %");
      Serial.print("Pressure = ");
      Serial.print(pressure);
      Serial.println(" hPa");
      Serial.print("Forecast = ");
      Serial.println(weather[forecast]);
      Serial.println();
    //*/
    
        send(tempMsg.set(temperature, 1));
    wait(50);
        send(humMsg.set(humidity, 1));
    wait(50);
        send(pressureMsg.set(pressure, 2));
    wait(50);
    
    BME280.writeMode (smSleep);
    sleep(SLEEP_TIME);
    
    }
    
    }
    
    My Project

  • My 2AA battery sensor
    P palmerfarmer

    Has anyone got a V2 version working for this?

    My Project

  • Power One Aurora Inverter RS485
    P palmerfarmer

    Thanks both I will try

    Domoticz

  • Power One Aurora Inverter RS485
    P palmerfarmer

    Dear all thinkers and clever people,

    Just been pondering over a possible way to monitor my solar inverter using domoticz.

    I have a 3kw power one inverter which are now made by ABB. I would like to monitor the output using the RS485 protocol from the inverter.
    So rs485 wired from inverter to an arduino nano (this will have an NRF radio module attached to speak to my GW). Does anyone know of such a node or similar?
    An other simpler method would be to build a node with a Current Transformer and just measure ac power.

    Thanks

    Domoticz
  • Login

  • Don't have an account? Register

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