Navigation

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

    Posts made by rvendrame

    • RE: Combining a motion sensor with an led on one node

      @TonicCorvid basically you just replace this line:

      sleep(digitalPinToInterrupt(MOTION_DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      

      by this:

      wait( SLEEP_TIME );
      

      But as pointed by @rejoe2 , this will drain the battery quite fast, as the node will be always on-line. Usually for actuator nodes (such as lights), a power supply is used, instead of batteries.

      posted in Development
      rvendrame
      rvendrame
    • RE: Combining a motion sensor with an led on one node

      @TonicCorvid ,

      issue 1: The light node cannot receive messages from home assistant while it is sleeping. You may start by replacing the sleep command by a wait:

      wait( SLEEP_TIME );
      

      issue 2: Usually Home Assistant needs the light send its current status, in order to 'activate' it. Try adding a line in the end of presentation part:

      #ifdef ID_S_LIGHT
        Serial.println("  S_LIGHT");
        present(ID_S_LIGHT, S_LIGHT, "Kitchen Night Light");
        wait(SHORT_WAIT);
        send(msg_S_LIGHT.set(isLightOn));   <<<<<<<<<<<<<<
      #endif
      
      posted in Development
      rvendrame
      rvendrame
    • RE: Water level measurement - Ultrasonics V Pressure

      @zboblamont thanks a lot! I will try it and report back here.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Water level measurement - Ultrasonics V Pressure

      @zboblamont may I ask you what pressure sensor have you choosen? My ultrassonic sensor suffers from the same plague as yours...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @Thomas-Weeks I'm looking for alternatives, as I started with JSN04T. Scope is to measure house's water tank (2000 litres). The sensor is fixed at a hole in the tank cover (on top).

      The tank stays at roof. Once sun in at its peak, a lot of vapor and condesantion appears in the tank, and the sensor face gets completely covered by water drops. Both JSN04T and VL5310X then start to give very out-of-range readings. (and this happens almost every day, for multiple hours).

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: JSN-SR04T (distance sensor) Reliability Issue Fix?

      @Thomas-Weeks , in your scenario do you have to deal with condensation (water vapor moisture) on sensor head? I replaced my ultrassonic SN04T by a time-of-flight VL5310X , but still getting many erratic readings when drips form on sensor face...

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: What I must buy in order to measure mAh please

      @DenisJ I built one of these some years ago and I'm still happy with

      https://www.openhardware.io/view/380/Micro-nano-ampere-meter-double

      It covers the range you mentioned at least. Hope it helps.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: RGB Light: Custom Effects

      @electrik , thanks for the directions. Yes the S_CUSTOM does show up in HA --- But how to change its value there? I can set different values in dev tools UI, but that is known to be temporary (it lasts only until next refresh from integration), and changing it there does not trigger a V_VAR1 message from HA back to node...

      posted in Home Assistant
      rvendrame
      rvendrame
    • RGB Light: Custom Effects

      Anyone figured out how to trigger an update + sending of V_VAR1 / V_VAR2 from home assistant to a node?

      My goal is to trigger custom effects in a mysensor-RGB node.

      (Yes, I know my sketch could present switches to allow triggering of the effects but I wanted to learn more how HA mySensor integration works and maybe couple with HA's existing 'effect_list' attribute for RGB lights).

      posted in Home Assistant
      rvendrame
      rvendrame
    • RE: MH-Z14A CO2 senso

      @viti this forum is in English, please use that. For CO2 sensor you might starting looking at https://www.mysensors.org/build/gas

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Modifying A0 value to Percentage

      @mrhutchinsonmn said in Modifying A0 value to Percentage:

      @rvendrame That worked! I did need to change "float moisture_percentage" to init "moisture_percentage" to get passed the "Call of overloaded function is ambiguous" error. Not sure if that is the correct approach but I was able to compile and upload. Not sure how I missed the send msg but I did. Thanks again!

      I'm glad it worked! And right, the code I provided was to work with integers.

      if you want to keep using float (and have decimals places), you have to add the number of decimal places in send function ( I put 2 decimals in this example):

      send(msg.set( moisture_percentage , 2  ));
      
      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Modifying A0 value to Percentage

      @mrhutchinsonmn I think you just need to replace this line in the first sketch:

      send(msg.set(sensorValue));
      

      By this:

      float moisture_percentage;
      moisture_percentage = ( 100 - ( (sensorValue/1023.00) * 100 ) );
      send(msg.set( moisture_percentage ));
      

      I don't use HA so I don't know if something needs to be changed in HA side...

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: BME280/BMP280 high consumption when sleeping

      @bbastos , welcome to mySensors. Try to add these lines before the sleep():

      digitalWrite( A4 , LOW ); 
      digitalWrite( A5 , LOW ); 
      

      Stills unclear why, but it worked for me at least.

      Reference: https://forum.mysensors.org/post/99876

      posted in NodeManager
      rvendrame
      rvendrame
    • RE: sending an image without wifi / envoi d'une image hors wifi

      @rejoe2 if you have to run a wire to the place where the camera will be installed, you could use CAT-6 regular ethernet cable. That would carry TCP/IP signal and could also carry power (via POE). And you could use any ordinary IP-camera...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Pool Sensor (analog)

      @netbus I use the waterproof version of DS18B20 in my pool sensor and it works perfectly, 3 years now and counting 😉

      posted in Hardware
      rvendrame
      rvendrame
    • RE: MyS not working on solar sensor board

      @ramwal I'm glad you got it working!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: MyS not working on solar sensor board

      @ramwal

      f6eeb556-f957-4f82-95d2-c8be09b606d3-image.png

      These boards use a different CE and CS pins in Arduino. Try to add this BEFORE the #include <MySensors.h>:

      #define MY_RF24_CE_PIN 7 // Ceech Arista board 
      #define MY_RF24_CS_PIN 8 // Ceech Arista board
      // Includes -------------------------------------------
      #include <MySensors.h> 
      
      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: TV on/off monitor using TV USB port

      Just brainstorming: a Door/Window sensor with 2xAA batteries may last ~2 years, if you remove the led and regulator. You just need to connect the USB - to GND and USB + to D3 via a diode.

      Another option is to replace the 2xAA by a small lithium battery, with one of these cheap TP4056 charger boards, so the USB from TV will keep the battery charged. You just need to connect +VCC (from the USB connector side) to D3 via a diode.

      https://www.aliexpress.com/w/wholesale-board-tp4056.html
      https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20200427084513&SearchText=small+lithium

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Ceech Board MOSFET Pin DIGITALWRITE Problem

      @paqor I recently converted the sketch to 2.x . Here it goes:

      /**
       * 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 - Initial Version by rvendrame
       * 
       ******************************
       * DESCRIPTION
       * Floating Swiming pool sensor based on ceech's arista board 
       *   (see https://www.tindie.com/products/ceech/astri-arista/ ) 
       *   Solar-powered (+Li-ion 18650 battery backup)
       * PH Measurement via A3 pin,  using DFrobot SEN0161 PH sensor 
       *    (see https://www.dfrobot.com/wiki/index.php/PH_meter(SKU:_SEN0161)
       * ORP Measurement via A1 pin,  using Phidgets 1130_0 board + 3556_0 Electrode 
       *    (see http://www.phidgets.com/products.php?product_id=1130)
       *    (see http://www.phidgets.com/products.php?product_id=3556)
       * Temp sensor via D4 pin,  using DS18B20 sensor
       *    (see https://create.arduino.cc/projecthub/TheGadgetBoy/ds18b20-digital-temperature-sensor-and-arduino-9cc806 ) 
       *    
       *    Revisions: 
       *    1.0  ( ??? 2017 ) - Initial version 
       *    1.1  ( Jan 2020 ) - MySensors 2.x port 
       */
      
      // Enable debug prints to serial monitor
      //#define MY_DEBUG
      
      // CEECH BOARD
      #define CEECH 
      
      // Define a static node address, AUTO or 1-255 fixed
      #define MY_NODE_ID AUTO
      #define MY_PARENT_NODE_ID AUTO
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24  // MY_RADIO_RFM69
      
      // MySensors 
      #define SN "myPoolWater"
      #define SV "1.2"
      #ifdef CEECH 
      #define MY_RF24_CE_PIN 7 // Ceech Arista board 
      #define MY_RF24_CS_PIN 8 // Ceech Arista board
      #endif
      
      // Includes -------------------------------------------
      #include <MySensors.h> 
      #include <SPI.h>
      #include <OneWire.h>
      #include <DallasTemperature.h>
      
      // External IO Pins 
      #define PH_PIN           A3  // pH Sensor dfrobot SKU SEN0161
      #define ORP_PIN          A1  // ORP Sensor phidgets ASR2801 (3556_0) + 1103_0 
      #define ONE_WIRE_BUS     5   // One wire bus
      
      // Runtime constants
      #define day 86400000L // 86400000 milliseconds in a day
      #define hour 3600000L // 3600000 milliseconds in an hour
      #define minute 60000L // 60000 milliseconds in a minute
      #define second  1000L // 1000 milliseconds in a second
      
      // Ceech-Arista Internal connections 
      #define  current A6  // Charging current from Solar Panel 
      #define  cell    A2  // Voltage at Solar Panel 
      #define  lipo    A0  // Voltage at Battery 
      #define  CHRG    A7  // Charge indicator ( 0 means 'charging' ) 
      #define  POWER   4   // MOSFET driver on 5V Step up (to power the sensors) 
      #define  R1      47000.0  // resistance of R1
      #define  R2      10000.0  // resistance of R2
      
      // mySensors objects
      MyMessage ph_msg( 2, V_PH ),
                orp_msg( 3, V_ORP ),
                temp_msg( 1, V_TEMP ),
                bat_msg( 199 , V_VOLTAGE ),
                var1_msg( 0 , V_VAR1 ), 
                var2_msg( 0 , V_VAR2 ),
                var3_msg( 0 , V_VAR3 );  
      
      // Setup a oneWire instance to communicate with any OneWire devices 
      // (not just Maxim/Dallas temperature ICs)
      OneWire oneWire(ONE_WIRE_BUS);
       
      // Pass our oneWire reference to Dallas Temperature.
      DallasTemperature dallas(&oneWire);
      
      // Misc 
      #define pHOffset         0.00  // pH deviation compensate
      #define samplingInterval 20    // in miliseconds 
      #define arrayLenth       40    // times of collection
      
      // PH / ORP / Temp  Reading
      static unsigned long samplingTime = millis();
      static float temp, ph, orp, voltage;
      static float aux, dif, old_ph=999, old_orp=999, old_temp=999;
      int   battery, counter = -1, 
            old_bat=999, old_volt=9999; 
      
      
      int readings[arrayLenth];   //Store the average value of the sensor feedback
      int arrayIndex = 0;
      
      // Misc  
      float vout = 0.0;
      float vin = 0.0;
      int value = 0;
      
      //// SETUP
      void setup() {
      
        Serial.begin( MY_BAUD_RATE );
        Serial.println(F("Init..."));
      
        // IO PINS
        pinMode( POWER   , OUTPUT );
        pinMode( PH_PIN  , INPUT );
        pinMode( ORP_PIN , INPUT ); 
      
      }
      
      //// PRESENTATION 
      void presentation() { 
        
        sendSketchInfo(SN, SV);
      
        present( 1, S_TEMP );          // Temperature
        present( 2, S_WATER_QUALITY ); // PH
        present( 3, S_WATER_QUALITY ); // ORP
      
      }
      //// LOOP
      void loop() {
      
        // Force a refresh on each hour...
        if ( ++counter == 5 ) {
          old_ph = old_orp = old_temp = -999;
          old_bat = old_volt = -999;
          counter = 0;
        }
      
        // Internal board/battery status 
        digitalWrite( POWER , true );
        Serial.println("5V Power ON - Wait 5s");
        wait(5000); 
      
        float napetost = readVcc();
      
        Serial.println("*Internal:"); 
        
        value = analogRead(cell);
        vout = (value * napetost) / 1024.0;
        vin = vout / (R2 / (R1 + R2));
        if (vin < 0.09) vin = 0.0;
        
        float tok = ((analogRead(current) * napetost / 1024 ) * 250) / 3.3; // convert the ADC value to miliamps
        float baterija = ( analogRead(lipo) * napetost / 1024 ) * 2; // measuring battery voltage
        int polnjenje = analogRead(CHRG);
      
        Serial.print("Vcc = ");
        Serial.print(napetost);
        Serial.println("V");
        //delay(400);
        Serial.print("Charge current = ");
        Serial.print(tok);
        Serial.println("mA");
        //delay(400);
        Serial.print("Solar cell voltage = ");
        Serial.print(vin);
        Serial.println("V");
        //delay(400);
        Serial.print("Battery voltage = ");
        Serial.print(baterija);
        Serial.print("V  ");
        aux = constrain( map( baterija*1000 , 2200 , 4000 , 0 , 100 ) , 0 , 100 );
        Serial.print( aux , 0  );
        Serial.println("%");
        dif = aux - old_bat;
        if ( abs( dif ) > 0 ) {
          old_bat = aux;
          send( bat_msg.set(baterija,2) );
          sendBatteryLevel( aux) ;
          send ( var3_msg.set(vin,2) ); 
        }
        //delay(400);
        Serial.print("CHRG = ");
        Serial.println(polnjenje);
      
        Serial.println("*External:"); 
        
        //////// Temp Reading
        dallas.begin();  // Start up the library
        dallas.requestTemperatures();
        temp = dallas.getTempCByIndex(0); 
        Serial.print( "Temperature: "); 
        Serial.println( temp , 2 ); 
        dif = old_temp - temp;
        if ( abs( dif ) > 0.01 ) {
           old_temp = temp;
           send( temp_msg.set( temp , 2 ) ) ;
        }
        
        //////// PH Reading
        arrayIndex = 0;
        while ( arrayIndex < arrayLenth )
          if (millis() - samplingTime > samplingInterval)
          {
            readings[arrayIndex++] = analogRead(PH_PIN);
            samplingTime = millis();
          }
        
        voltage = avergearray( readings, arrayLenth ) * 3.30 / 1024.0;
        ph = 3.5 * ( voltage + pHOffset );
      
        Serial.print("PH Probe voltage:");
        Serial.print(voltage, 4);
        Serial.print("    pH value: ");
        Serial.println( ph , 2);
        dif = old_ph - ph;
        if ( abs( dif ) > 0.005 ) {
           old_ph = ph;
           send( ph_msg.set( ph , 2 ) ) ;
           send( var1_msg.set( voltage, 4) ); 
        }
      
      
        /////////// ORP 
        arrayIndex = 0;
        while ( arrayIndex < arrayLenth )
          if (millis() - samplingTime > samplingInterval)
          {
            readings[arrayIndex++] = analogRead(ORP_PIN);
            samplingTime = millis();
          }
      
        voltage = avergearray( readings, arrayLenth ) * 3.31 / 1024.0;
        orp = ( 2.5 - voltage ) / 1.037 ;
      
        Serial.print("ORP Probe voltage:");
        Serial.print( voltage, 4);
        Serial.print("    ORP value: ");
        Serial.println( orp, 2 );  
        dif = old_orp - orp;
        if ( abs( dif ) > 0.005 ) {
           old_orp = orp; 
           send( orp_msg.set( orp , 2 ) ) ;
           send( var2_msg.set( voltage, 4) ); 
        }
      
        /////////// Sleep
        digitalWrite( POWER , false );
        Serial.println("5V Power OFF");
      
        Serial.print("Runtime: ");
        time();
        Serial.println("Pausing...");
        Serial.println("----------------------------");
        
        //delay(715000);
        wait(500);
        sleep( 715000U );   // Sleeps for 12m
      
      }
      
      double avergearray(int* arr, int number) {
        int i;
        int max, min;
        double avg;
        long amount = 0;
        if (number <= 0) {
          Serial.println("Error number for the array to avraging!/n");
          return 0;
        }
        if (number < 5) { //less than 5, calculated directly statistics
          for (i = 0; i < number; i++) {
            amount += arr[i];
          }
          avg = amount / number;
          return avg;
        } else {
          if (arr[0] < arr[1]) {
            min = arr[0]; max = arr[1];
          }
          else {
            min = arr[1]; max = arr[0];
          }
          for (i = 2; i < number; i++) {
            if (arr[i] < min) {
              amount += min;      //arr<min
              min = arr[i];
            } else {
              if (arr[i] > max) {
                amount += max;  //arr>max
                max = arr[i];
              } else {
                amount += arr[i]; //min<=arr<=max
              }
            }//if
          }//for
          avg = (double)amount / (number - 2);
        }//if
        return avg;
      }
      
      
      void time() {
      
        long timeNow = millis();
      
        int days = timeNow / day ;                                //number of days
        int hours = (timeNow % day) / hour;                       //the remainder from days division (in milliseconds) divided by hours, this gives the full hours
        int minutes = ((timeNow % day) % hour) / minute ;         //and so on...
        int seconds = (((timeNow % day) % hour) % minute) / second;
      
        // digital clock display of current time
        Serial.print(days, DEC);
        printDigits(hours);
        printDigits(minutes);
        printDigits(seconds);
        Serial.println();
      
      }
      
      void printDigits(byte digits) {
        // utility function for digital clock display: prints colon and leading 0
        Serial.print(":");
        if (digits < 10)
          Serial.print('0');
        Serial.print(digits, DEC);
      }
      
      
      /* Read internal Vcc reference 
       *  
       */
      float readVcc()
      {
        signed long resultVcc;
        float resultVccFloat;
        // Read 1.1V reference against AVcc
        ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        delay(10);                           // Wait for Vref to settle
        ADCSRA |= _BV(ADSC);                 // Convert
        while (bit_is_set(ADCSRA, ADSC));
        resultVcc = ADCL;
        resultVcc |= ADCH << 8;
        resultVcc = 1126400L / resultVcc;    // Back-calculate AVcc in mV
        resultVccFloat = (float) resultVcc / 1000.0; // Convert to Float
      
        return resultVccFloat;
      }
      
      posted in Development
      rvendrame
      rvendrame
    • RE: Merge Help: Door+ BME280

      @Puneit-Thukral I have a similar sensor ( PIR + BMP280 + other stuff). I don't use smartSleep ( Since this code is old, only sleep was available ) so I can't speak about the sleep part. Maybe you could try with regular sleep just to see if brings some diference...

      Regarding the BME280 (BMP in my case) , I didn't have to use the Wire.begin() / end(), and I use the same library as yours (Adafruit).

      Code is bellow, in case you want to compare yourself.

      /**
       * 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
       * (adopted from 5in1 V2.1)
       * Version 3.0 - RV -  Shifted to BMP280 sensor, added pressure and water leakage (via ROPE  https://www.amazon.com/gp/product/B004FTFQ4W/ref=ppx_od_dt_b_asin_title_s01?ie=UTF8&psc=1 ) 
       * 
       * 
       * DESCRIPTION
       * BMP280 on std SDA/SDL pins  (Temp/Pressure) 
       * LDR on pin A1:  GND ---> 10k ---> A1 <-- LDR  <-- Vcc 
       * PIR on D3 and wakeup via interrupt (in case of PIR trigger) 
       * Smoke on D2 with interrupt wake up too. ( 4n25 4K7 on buzzer, 2M7 Pullup resistor recommended ) 
       * Water Sensing cable on A2:  GND --> 100k --> A2 <--  X--X <-- Vcc  
       * (https://www.amazon.com/gp/product/B004FTFQ4W/ref=ppx_od_dt_b_asin_title_s01?ie=UTF8&psc=1)
       * 
       * Battery voltage is as battery percentage (Internal message), and optionally as a sensor value (See defines below)
       *
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Board type 
      #define DRAGON  // PRO_MINI //  DRAGON / SENSEBENDER
      
      // Define a static node address, AUTO or 1-255 fixed
      #define MY_NODE_ID 25 // AUTO 
      #define MY_PARENT_NODE_ID AUTO 
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24  // MY_RADIO_RFM69
      
      // Uncomment the line below, to transmit battery voltage as a normal sensor value
      #define BATT_SENSOR    199
      
      #define NAME "8in1 Sensor"
      #define RELEASE "3.3"
      
      // Pin definitions for sensors
      #define SDA_PIN        A5    // Just to document std IC2 interface 
      #define SCL_PIN        A4    // Just to document std IC2 interface 
      #define LDR_PIN        A1    //  Analog Light sensor (LDR)
      #define WATER_PIN      A2    //  Analog Water Leak sensor (rope)
      #define SMOKE_PIN      2     //  Digital Smoke sensor (0/1)
      #define PIR_PIN        3     //  PIR Sensor (0/1) 
      #define TRIGGER_PIN    4     //  Trigger for HC-SR04 sensor 
      #define ECHO_PIN       5     //  Echo for HC-SR04 sensor 
      
      #ifdef DRAGON
      //   #define SPIFLASH_PIN   8 
         #define LED_PIN        9  
         #define TEST_PIN       A0
         #define MY_RF24_CE_PIN  7  
         #define MY_RF24_CS_PIN  10 
      //   #define MY_SOFTSPI
      //   #define MY_SOFT_SPI_SCK_PIN     13
      //   #define MY_SOFT_SPI_MISO_PIN    12
      //   #define MY_SOFT_SPI_MOSI_PIN    11
      #endif
      
      #ifdef SENSEBENDER
         #define SPIFLASH_PIN   8 
         #define TEST_PIN       A0
         #define OTA_ENABLE     A1
         #define LED_PIN        A2
         #define ATSHA204_PIN   17 // A3
      #endif
      
      #ifdef PRO_MINI
        #define LED_PIN 8
      #endif
      
      // Includes ///////////////////////////////////////////
      #include <SPIMemory.h> 
      #include <SPI.h>
      #include <MySensors.h>
      //#include <Wire.h>
      //#include <EEPROM.h>  
      //#include <sha204_library.h>
      //#include <Adafruit_Sensor.h>
      #include <Adafruit_BMP280.h>
      
      /// Sketch parameters SETUP ////////////////////////////
      // Child sensor ID's
      #define CHILD_ID_TEMP  1
      #define CHILD_ID_HUM   2
      #define CHILD_ID_PRESS 3
      #define CHILD_ID_LIGHT 4
      #define CHILD_ID_PIR   5
      #define CHILD_ID_SMOKE 6
      #define CHILD_ID_WATER 7 
      #define CHILD_ID_TANK  8 
      
      // How many milli seconds should we wait for OTA?
      #define OTA_WAIT_PERIOD 500
      
      // How many milli seconds between each measurement
      #define MEASURE_INTERVAL 720000   // 12min 
      
      // How many wakeups to send battery level 
      #define BAT_INTERVAL     100      //  around 20 hours 
      
      // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller
      #define FORCE_TRANSMIT_INTERVAL 10 //  around 2 hours 
      
      // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes.
      // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement
      
      // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with
      // TEMP_TRANSMIT_THRESHOLD for temperature threshold.
      #define HUMI_TRANSMIT_THRESHOLD 5
      #define TEMP_TRANSMIT_THRESHOLD 0.5
      #define LIGHT_TRANSMIT_THRESHOLD 5
      #define PRESS_TRANSMIT_THRESHOLD 50
      
      // Flash memory 
      #ifdef SPIFLASH_PIN 
      SPIFlash flash( SPIFLASH_PIN );
      #endif
      
      // ATSHA204
      #ifdef ATSHA204_PIN
      atsha204Class sha204( ATSHA204_PIN );
      #endif
      
      //Weather Sensor BMP280 on IC2 (Temp/Hum/Pressure):
      #ifdef SDA_PIN and SCL_PIN 
      Adafruit_BMP280 weather_sensor;
      #endif
      
      // Sensor messages
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgPressure(CHILD_ID_PRESS, V_PRESSURE ); 
      MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
      MyMessage msgMotion(CHILD_ID_PIR, V_TRIPPED); 
      MyMessage msgSmoke(CHILD_ID_SMOKE, V_TRIPPED ); 
      MyMessage msgWater(CHILD_ID_WATER, V_TRIPPED ); 
      MyMessage msgDist(CHILD_ID_TANK, V_DISTANCE ); 
      
      #ifdef BATT_SENSOR
      MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE);
      #endif
      
      // Global settings
      int measureCount;
      int sendBattery;
      boolean isMetric = true;
      boolean highfreq = true;
      boolean transmission_occured = false;
      
      // Storage of old measurements
      float lastTemperature = -100;
      float lastHumidity = -100;
      float lastPressure = -100; 
      long lastBattery = -100;
      int lastPir = -1;  
      int lastLight = -100; 
      int lastSmoke = -1; 
      int lastWater = -1; 
      int lastDist = -1; 
      
      /****************************************************
       *
       * Setup code 
       *
       ****************************************************/
      void setup() {
      
        #ifdef LED_PIN 
        pinMode(LED_PIN, OUTPUT);
        digitalWrite(LED_PIN, HIGH);
        #endif
        
        Serial.begin( MY_BAUD_RATE );  // Default for MySensors is 115200 
      
      // Test Mode  //////////////////////////
        #ifdef TEST_PIN
        pinMode(TEST_PIN,INPUT_PULLUP);
        if (!digitalRead(TEST_PIN)) testMode();
        pinMode(TEST_PIN,INPUT); 
        #endif
      
      // Pin Mode Setup //////////////////////
        #ifdef BAT_PIN 
        pinMode(BAT_PIN , INPUT);  // Ext. Batery meter (1M / 470K resistors) 
        #endif 
        #ifdef SMOKE_PIN
        pinMode(SMOKE_PIN , INPUT ); 
        #endif
        #ifdef PIR_PIN
        pinMode(PIR_PIN , INPUT);   
        #endif 
        #ifdef TRIGGER_PIN
        pinMode(PIR_PIN , OUTPUT);   
        #endif 
        #ifdef ECHO_PIN
        pinMode(ECHO_PIN , INPUT);   
        #endif 
          
      // Startup Info 
        Serial.print("Board:");
        Serial.print( ARDUINO ); 
        Serial.print( "\t" ); 
        Serial.print( F_CPU / 1000000 ); 
      
        Serial.print(" Mhz\t"); 
        Serial.print( NAME );
        Serial.print(" "); 
        Serial.println( RELEASE );
       
        Serial.print("Nrf24 CE/CS:");
        Serial.print( MY_RF24_CE_PIN);  
        Serial.print("/"); 
        Serial.print( MY_RF24_CS_PIN ); 
      
        Serial.print("\tNODE ID:");
        Serial.print(hwReadConfig(EEPROM_NODE_ID_ADDRESS));
        
        isMetric = getControllerConfig().isMetric;
        Serial.print(F("\tisMetric:")); Serial.println(isMetric);
        
        #ifdef OTA_WAIT_PERIOD
        Serial.print("OTA FW Enabled"); 
        #endif
      
        // SPI Flash 
        #ifdef SPIFLASH_PIN
        SPI.begin(); 
        Serial.print(F("\tFlash:")); 
        if ( flash.begin() ) { 
          Serial.print( flash.getCapacity() / 8000 , 0 );
          Serial.print( "KB"); 
          flash.powerDown(); 
        } else Serial.print( flash.error(VERBOSE) ); 
      
        #endif
      
        // BMP280 init ////////////////////////
        #ifdef SDA_PIN and SCL_PIN
        Serial.print(F("\tBMP280:")); 
        if ( weather_sensor.begin() ) { 
          Serial.print(F("OK"));
          /* Default settings from datasheet. */
          weather_sensor.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                        Adafruit_BMP280::SAMPLING_X1,       /* Temp. oversampling */
                        Adafruit_BMP280::SAMPLING_X1,       /* Pressure oversampling */
                        Adafruit_BMP280::FILTER_OFF );      /* Filtering. */
      
        } else Serial.print(F("ERROR!")); 
        #endif
      
        // Force 1st transmission of all sensors
        measureCount = FORCE_TRANSMIT_INTERVAL;
        sendBattery = BAT_INTERVAL; 
        
        #ifdef LED_PIN 
        digitalWrite(LED_PIN, LOW);
        #endif
          
        Serial.println(F("\n///////////////////// ONLINE /////////////////////"));
        Serial.flush(); 
      
      }
      
      void presentation() { 
      
        sendSketchInfo( NAME , RELEASE);
        #ifdef SDA_PIN 
          present(CHILD_ID_TEMP,S_TEMP);
          present(CHILD_ID_HUM,S_HUM);
          present(CHILD_ID_PRESS, S_BARO ); 
        #endif
        #ifdef LDR_PIN
          present(CHILD_ID_LIGHT,S_LIGHT_LEVEL);
        #endif
        #ifdef PIR_PIN 
          present(CHILD_ID_PIR,S_MOTION); 
        #endif
        #ifdef SMOKE_PIN 
          present(CHILD_ID_SMOKE, S_SMOKE); 
        #endif 
        #ifdef WATER_PIN
          present(CHILD_ID_WATER, S_WATER_LEAK ); 
        #endif
        #ifdef TRIGER_PIN
          present(CHILD_ID_TANK, S_DISTANCE ); 
        #endif
        #ifdef BATT_SENSOR
          present(BATT_SENSOR, S_POWER);
        #endif
       
      }
      
      /***********************************************
       *
       *  Main loop function
       *
       ***********************************************/
      void loop() {
      
        #ifdef LED_PIN
        digitalWrite( LED_PIN , HIGH ); 
        #endif
        
        boolean forceTransmit = false;
        transmission_occured = false; 
        
        if ( ++measureCount > FORCE_TRANSMIT_INTERVAL ) { // force a transmission
          forceTransmit = true;
          Serial.print(F("[Force Transmission]"));  
          measureCount = 0;
        }
      
        // Light, PIR, Smoke, Water leak 
        sendLight(forceTransmit); 
        sendPir(forceTransmit); 
        sendSmoke(forceTransmit); 
        sendWater(forceTransmit);
        sendWeather(forceTransmit);  
        sendDistance(forceTransmit); 
        
        // Battery level report 
        if ( ++sendBattery > BAT_INTERVAL ) {
             sendBattLevel(true); 
             sendBattery = 0;
        }
      
        // Wait for FW update... 
        if (transmission_occured) {
            wait(OTA_WAIT_PERIOD);
            measureCount = 0; 
        }
      
        #ifdef LED_PIN
        digitalWrite( LED_PIN , LOW ); 
        #endif
      
        Serial.println(); 
      
        // Trick to avoid false triggering on PIR 
        sleep(1000); 
        
        // Sleep until interval or PIR or smoke trigger 
        if ( lastSmoke == 1 )  // In case of Smoke Alarm, don't sleep too much... 
            sleep( 45000 ); 
        else if ( lastPir == 1 )  // In case of Motion, stop PIR detecting for 1 complete cycle... 
            sleep( 0 , CHANGE , MEASURE_INTERVAL ); 
        else 
            sleep( 0 , CHANGE , 1 , CHANGE, MEASURE_INTERVAL); // Default: Wake up on any PIR and Smoke... 
      
        // To avoid false Smoke alarm
        wait(100); 
      
        // Wake
        Serial.print( millis() ); 
        Serial.print("[WAKE]"); 
      
      }
      
      /*********************************************
       *
       * Sends Motion status 
       *
       *********************************************/
      void sendDistance(bool force)
      {
      
      long duration;
      int distance;
      
         #ifdef TRIGER_PIN
         digitalWrite( TRIGER_PIN, LOW);
         delayMicroseconds(2);
         digitalWrite( TRIGER_PIN , HIGH);
         delayMicroseconds(10);
         digitalWrite( TRIGER_PIN , LOW);
         // Reads the echoPin, returns the sound wave travel time in microseconds
         duration = pulseIn( ECHO_PIN , HIGH);
         // Calculating the distance
         distance = duration * 0.034 / 2;
         if ( distance != lastDist || force ) { 
            Serial.print(" D:");Serial.print(distance);
            send(msgDist.set(distance));
            transmission_occured = true; 
            lastDist = distance; 
         }
         #endif 
         
      }
      
      /*********************************************
       *
       * Sends Motion status 
       *
       *********************************************/
      void sendPir(bool force)
      {
      
         #ifdef PIR_PIN
         int currPir = digitalRead( PIR_PIN ); 
         if ( lastPir != currPir || force ) { 
            Serial.print(" M:");Serial.print(currPir);
            send(msgMotion.set(currPir));
            transmission_occured = true; 
            lastPir = currPir; 
         }
         #endif 
         
      }
        
      /*********************************************
       *
       * Sends Smoke status 
       *
       *********************************************/
      void sendSmoke(bool force)
      {
      
         #ifdef SMOKE_PIN
         int currSmoke = !digitalRead( SMOKE_PIN ); // Low = Smoke Triggered 
         if ( lastSmoke != currSmoke || force ) { 
            Serial.print(" S:");Serial.print(currSmoke);
            send(msgSmoke.set(currSmoke));
            transmission_occured = true; 
            lastSmoke = currSmoke;    
         }
         #endif 
      }
      
      /*********************************************
       *
       * Sends Smoke status 
       *
       *********************************************/
      void sendWater(bool force)
      {
      
         #ifdef WATER_PIN 
         int currWater = ( analogRead( WATER_PIN ) > 500 ? 1 : 0 ) ;  
         //Serial.println( analogRead( WATER_PIN ) ); 
         if ( lastWater != currWater || force ) { 
            Serial.print(" W:");Serial.print(currWater);
            send(msgWater.set(currWater));
            transmission_occured = true; 
            lastWater = currWater;    
         }
         #endif
      }
      
      /*********************************************
       *
       * Sends Light Level based on LDR 
       *
       * Parameters
       * - force : Forces transmission of a value (even if it's the same as previous measurement)
       *
       *********************************************/
      void sendLight(bool force)
      {
        #ifdef LDR_PIN 
        int currLight = map( analogRead( LDR_PIN ) , 0, 1024 , 0 , 100 ); 
        int diffLight = abs( lastLight - currLight );  
        if (isnan(diffLight) || diffLight >= LIGHT_TRANSMIT_THRESHOLD || force )  {
          Serial.print(" L:");Serial.print(currLight);
          send(msgLight.set(currLight));
          lastLight = currLight; 
          transmission_occured = true; 
        }
        #endif 
      }
      
      /*********************************************
       *
       * Sends temperature and humidity from Si7021 sensor
       *
       * Parameters
       * - force : Forces transmission of a value (even if it's the same as previous measurement)
       *
       *********************************************/
      void sendWeather(bool force)
      {
        #ifdef SDA_PIN and SCL_PIN 
        bool tx = force;
        
        // Sensor reading 
        float temp = weather_sensor.readTemperature();  
        //float humd = "N/A" ;  // Hum is not supported on BMP280  (But it is in BME280) 
        float pres = weather_sensor.readPressure(); 
        
         // Temperature delta 
        float diffTemp = abs( lastTemperature - temp );
        if (diffTemp >= TEMP_TRANSMIT_THRESHOLD) tx = true;
      
        // Humidity delta
        //float diffHum = abs( lastHumidity - humd ); 
        //if ( isnan(diffHum) || diffHum >= HUMI_TRANSMIT_THRESHOLD) tx = true;
      
        // Pressure delta 
        float diffPress = abs( lastPressure - pres );
        if (diffPress >= PRESS_TRANSMIT_THRESHOLD) tx = true;
      
        if (tx) {
          
          measureCount = 0;
           
          Serial.print(" T:");Serial.print(temp,1);
          //Serial.print(" H:");Serial.print(humd,1);
          Serial.print(" P:");Serial.print(pres,1); 
          
          send(msgTemp.set(temp,1));
          //send(msgHum.set(humd,1));
          send(msgPressure.set(pres,1)); 
         
          lastTemperature = temp;
          //lastHumidity = humd;
          lastPressure = pres; 
          
          transmission_occured = true;
               
        } 
      
        // BUG? High consumption ... 
        //digitalWrite( SDA_PIN , LOW ); 
        //digitalWrite( SCL_PIN , LOW ); 
        
        #endif 
      }
      
      /********************************************
       *
       * Sends battery information (battery percentage)
       *
       * Parameters
       * - force : Forces transmission of a value
       *
       *******************************************/
      void sendBattLevel(bool force)
      {
      
        #ifdef BAT_PIN
        long vcc = ( analogRead( BAT_PIN ) * 3300.0 / 1024.0 ) * 3.13; 
        #else
        long vcc = readVcc(); 
        #endif 
         
        if ( abs( ( vcc - lastBattery ) ) > 100 || force) {
      
          lastBattery = vcc;
      
          #ifdef BATT_SENSOR
          float send_voltage = float(vcc)/1000.0f;
          send(msgBatt.set(send_voltage,3));
          #endif
      
          // Calculate percentage
          vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at 
          long percent = vcc / 13.0;
          //long percent = constrain( map( vcc, 4000 , 9000, 0, 100 ) , 0 , 100 );  
          Serial.print(" Batt%:"); Serial.print( percent ); 
          sendBatteryLevel(percent);
          transmission_occured = true; 
          
        }
        
      }
      
      /*******************************************
       *
       * Internal battery ADC measuring 
       *
       *******************************************/
      long readVcc() {
        // Read 1.1V reference against AVcc
        // set the reference to Vcc and the measurement to the internal 1.1V reference
        #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
          ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
          ADMUX = _BV(MUX5) | _BV(MUX0);
        #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
          ADcdMUX = _BV(MUX3) | _BV(MUX2);
        #else
          ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        #endif  
       
        delay(2); // Wait for Vref to settle
        ADCSRA |= _BV(ADSC); // Start conversion
        while (bit_is_set(ADCSRA,ADSC)); // measuring
       
        uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
        uint8_t high = ADCH; // unlocks both
       
        long result = (high<<8) | low;
       
        result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
        return result; // Vcc in millivolts
      }
      
      
      /****************************************************
       *
       * Verify all peripherals, and signal via the LED if any problems.
       *
       ****************************************************/
      void testMode()
      {
        uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
        uint8_t ret_code;
        boolean fail = false; 
      
        #ifdef LED_PIN 
        digitalWrite(LED_PIN, HIGH); // Turn on LED.
        #endif
        
        Serial.println(F(" - TestMode"));
        Serial.println(F("Testing peripherals!"));
        Serial.flush();
      
        #ifdef SDA_PIN 
        Serial.print(F(" IC2 weather sensor ")); 
        Serial.flush();
        if ( weather_sensor.begin() && weather_sensor.readPressure() &&  
             weather_sensor.readTemperature() > 900 ) 
        {
          Serial.println(F("ok!"));
        }
        else
        {
          Serial.println(F("failed!"));
          fail = true; 
        }
        Serial.flush();
        #endif
        
        #ifdef SPIFLASH_PIN
        Serial.print(F("-> Flash : "));
        Serial.flush();
        if (flash.begin())
        {
          Serial.println(F("ok!"));
        }
        else
        {
          Serial.println(F("failed!"));
          fail = true; 
        }
        Serial.flush();
        #endif 
        
        #ifdef ATSHA204_PIN
        Serial.print(F("-> SHA204 : "));
        ret_code = sha204.sha204c_wakeup(rx_buffer);
        Serial.flush();
        if (ret_code != SHA204_SUCCESS)
        {
          Serial.print(F("Failed to wake device. Response: ")); Serial.println(ret_code, HEX);
        }
        Serial.flush();
        if (ret_code == SHA204_SUCCESS)
        {
          ret_code = sha204.getSerialNumber(rx_buffer);
          if (ret_code != SHA204_SUCCESS)
          {
            Serial.print(F("Failed to obtain device serial number. Response: ")); Serial.println(ret_code, HEX);
            fail = true; 
          }
          else
          {
            Serial.print(F("Ok (serial : "));
            for (int i=0; i<9; i++)
            {
              if (rx_buffer[i] < 0x10) Serial.print('0'); // Because Serial.print does not 0-pad HEX
              Serial.print(rx_buffer[i], HEX);
            }
            Serial.println(")");
          }
      
        }
        Serial.flush();
        #endif 
        
        Serial.println(F("Test finished"));
        
        if ( !fail ) 
        {
          Serial.println(F("Selftest ok!"));
          while (1) // Blink OK pattern!
          {
            #ifdef LED_PIN 
            digitalWrite(LED_PIN, HIGH);
            delay(200);
            digitalWrite(LED_PIN, LOW);
            delay(200);
            #endif
          }
        }
        else 
        {
          Serial.println(F("----> Selftest failed!"));
          while (1) // Blink FAILED pattern! Rappidly blinking..
          {
          }
        }  
      }
      
      posted in Development
      rvendrame
      rvendrame
    • RE: Difficulties compiling Nodemcu 1.0 (ESP-12 module) as a 8266 Gateway.

      @ramwal Thanks for the hint, it made the trick here too!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Inventory webpage

      @Nca78 Agree. But I liked the idea of a simple text search, where you enter for example 'MOSFET' and it lights up all bins with mosfets ... It is now in my list 'projects to investigate after finishing all ongoing' 😉

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Inventory webpage

      and you can link it with an Arduino + some addressable leds + (why not? ) my sensors, and do something like this...

      https://www.instructables.com/id/FindyBot3000-a-Voice-Controlled-Organizer/

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Library Compatabilty under Vera UI7

      @mntlvr but your original question was regarding the version of serial gateway right? Compatibility of GW 2.3.x is not 100% guaranteed with 1.4.x sensors but as I mentioned all my old 1.4.x sensors kept worked after updating GW sketch to 2.3.x.

      I never had problems with the plugin in vera controller. Maybe you should try to upload the files again... A setup in vera is also required as mentioned Here

      posted in Vera
      rvendrame
      rvendrame
    • RE: Library Compatabilty under Vera UI7

      @mntlvr , I had GW 1.4.x for a long time and in middle of last year I updated the GW to 2.3.x. All my old 1.4.x nodes keep working perfectly so far. I have DC dimmers, temp/hum/light, and some switches on this old version.

      I also updated my vera yesterday to 7.31. Surprisingly the updated process worked smooth for first time ever in 6 years!

      posted in Vera
      rvendrame
      rvendrame
    • RE: Pir AS 312 with 2 rechargeable AAA battery. Boost needed?

      When you sleep the node with a PIR connected, a small 'nap' before the main sleep helps to settle the Vbat, and it usually avoid false triggering. Maybe this will help:

      sleep(500);
      sleep(INTERRUPT,RISING, SLEEP_TIME);
      
      posted in Hardware
      rvendrame
      rvendrame
    • RE: Question: FL5150 LED Dimmer - replace a analog potentiometer with a digital one

      Hi, maybe a DAC like this will help:
      https://www.ti.com/lit/ds/symlink/dac7571.pdf

      Here it is implemented with another MCU:
      https://easyeda.com/kacper.jaszcz/Hidden_remote_lightswitch-af02b2a64ef44d919d2e2d42ccc5b1c4

      posted in Hardware
      rvendrame
      rvendrame
    • RE: 💬 MySensors Low-power Multi-function node on CR2032

      @fanfan , not sure if that may help you, but in my case I discovered that even in sleep mode the BME280 still drawing current (up to 1mA). The only solution I found was to bring down the SCL and SDA pins before entering in the sleep mode.

      Something like this:

      digitalWrite( A4 , LOW ); 
      digitalWrite( A5 , LOW ); 
      sleep( 60000 );
      
      wait(200); 
      weather_sensor.begin();
      wait(200); 
      
      

      Not sure if this is best way but it worked for me...

      posted in OpenHardware.io
      rvendrame
      rvendrame
    • RE: Electrodragon NRF Pro Mini Sensor Board

      @nikola-collins , yes, I just got the same conclusion. After installing the latest SPIFlash lib from lowpowerlab.com, and changed the constructor to "SPIFlash flash(8)" (like your code), seems that now I have ~12uA in sleep mode.

      Thanks anyway!

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Electrodragon NRF Pro Mini Sensor Board

      Just a comment for this board, the minimum current consumption in mySensors Sleep() that I could achieve is ~700uA, with 2XAA batteries.

      According to seller, this the benchmark for this board.

      I should have enquired it first, before buying 10 boards... one more lesson learned!

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Another nRF5 based wall switch

      @abarkow , did you print the cover? Is it a flat cover or they are cuts between each key?

      posted in My Project
      rvendrame
      rvendrame
    • RE: Ceiling fan/light node

      According to this, avoid trailing edge dimmers to control inductive loads (fan motor in this case).

      posted in My Project
      rvendrame
      rvendrame
    • RE: Controlling a 1st gen. LivingColors lamp

      @BartE

      I purchased this module:
      https://www.aliexpress.com/item/Wireless-Module-CC2500-2-4G-Low-power-Consistency-Stability-Small-Size/32702148262.html?spm=a2g0s.9042311.0.0.L1Dfwj

      This is the pinout...
      alt text

      ... and I'm in doubt how to wire GDO2, GDO0, RFSC above.

      RFCL - SCK (pin 13)?
      GDO2 - leave open?
      GDO0 - CE (pin 9)?
      RFCS - CS(pin 10)?

      Would you mind to clarify? Thanks!

      posted in My Project
      rvendrame
      rvendrame
    • RE: best approach to add MySensors Node to an existing smoke detector?

      @user2684 , I have same smoke sensor as you (as per picture you posted). How did you end with this? I'm experience many false smoke alarms, no matter what resistors/diodes I use.

      Sorry for reopen such old thread!

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Transformer-less power supply

      You can find "Hi-link like" PSUs at Aliexpress for less than $2 USD. Not sure how less you can reach by producing them by yourself.

      posted in My Project
      rvendrame
      rvendrame
    • RE: Transformer-less power supply

      Despite the security (which of course is the most important aspect here), such kind of circuit usually consumes from 2 to 10w (depending on AC voltage and C1 value), no matter in standby or not. I did some testing in the past and at end I dropped in favor of hi-link and similar small PSUs.

      posted in My Project
      rvendrame
      rvendrame
    • RE: Wall touch sensor

      @Yago-Casasnovas , the one mentioned by Boots runs a coincell. There is no wire to connect it, just glue anywhere and it will send commands to your controller. The standard one uses 433Mhz (like a garage door remote control), while the hacked version from Nca78 transforms it in 'mySensors enabled'.

      It doesn't control any light though, like the one you found from Broadlink. If you want a module to replace the original switch, wired to the lamp, search for 'Livolo' in the forum and you will find some hacks too.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Help with sleeping door sensor

      @ustredna , try changing this line:

      send(msg.set(value==HIGH));

      by

      send(msg.set(value));

      The same for msg2 line:

      send(msg2.set(value==HIGH));

      to

      send(msg2.set(value));

      And if you only need to update the GW on every 7 seconds (and not immediately), change the sleep:

      sleep( 7000 ) ;

      Hope it helps!

      posted in Development
      rvendrame
      rvendrame
    • RE: 💬 Micro (nano) ampere meter (double)

      @Nca78 , updating: I figured out how to connect the load, so I'm done with it (including calibration).

      I changed the original code a bit, as I also wanted it a bit more responsive. I didn't lift pin 15 as you did.

      BTW, what bootloader + clock are you using? Perhaps that could influence? I'm using MYSBootloaderV13pre.hex, 8Mhz internal clock...

      Changes:

      • Less average reading per cycle (from 32 to 4 ) --> Didn't notice significant changes in measurements.
      • More accumulated avg reads ( from 16 to 32 ) --> Just to keep a less volatile avg numbers in display.
      • Change the logic of short/long press. short press (~1s) = change mode, long press (~3s) = Offset.

      In case you want to give it a try...

      // uA meter with HX711
      /*
       PROJECT: MySensors - uA meter with HX711
       PROGRAMMER: AWI
       DATE: 20170414/ last update: 
       FILE: AWI_uA_meter.ino
       LICENSE: Public domain
      
       Performance improvements: rvendrame 
       
      Hardware: tbd Nano ATmega328p board w/ NRF24l01
      	
      Special:
      	program with Arduino Nano
      	
      SUMMARY:
      	Measures mV accross a shunt resistor ~ uA - channel A
      	Measures mV on channel B
      	Modes:
      		- default: measure uV in full resolution (Stable reading only for 0.1uV)
      		- other:
      			A: channel A: default, amplification 128 - div 500: 0.1uV stable,  range +/- 20mV, (1ohm +/- 20mA, res 100 nA)
      			B: channel B: amplification 32 - div 125: 100nA stable, range +/- 80mV,  (10 ohm +/- 8 mA, res 10 nA)
      			AB: both channels:  
      		- uA - calibration: depending on the actual shunt:
      			0.47 ohm -> 1 uV ~ 2uA, range -40 mA - 40 mA
      			1 ohm -> 1 uV = 1uA, range -20 mA - 20 mA
      			10 ohm -> 1 uv = 0.1uA
      		- mV - calibration, depend on amplification
      	Button switch:
      		- Short press, reset current channel to offset 0 (keep terminals shorted, no need with uA ;-)
      		- Long press, change channel A (uA) / B(uA)/ A & B (uA)
      		
      	Hx711 24bit weight scale sensor
      		- Noise and temperature sensitive (x bit effective)
      	OLED 128x64 display
      	
      Remarks:
      	Size is large as result of font library for display
      update:
      	
      */
      
      #include <U8g2lib.h>									// U8glib for OLED display
      #include <Wire.h> 										// I2C
      #include <Button.h>										// https://github.com/JChristensen/Button
      #include "HX711.h"										// local ADC lib
      
      const double calibrationFactorA = 599.18f ;				// calibration for channel A: set to 1.0 for known current and divide
      const double calibrationFactorB = 149.76f ;				// calibration for channel B: set to 1.0 for known current and divide
      long offsetChannelA = 0 ;								// channel offsets for A and B (drifts) are calibrated at startup and on command. 
      long offsetChannelB = 0 ;
      
      const uint8_t HX711_dout = A1 ;							// HX711 data out pin
      const uint8_t HX711_sck = A0 ;							// HX711 serial clock
      const uint8_t buttonPin = A2 ;							// connects the button to select function and reset offset
      //const unsigned long longPress = 1500UL ;				//	- long press set reference temperature - in ms												// 	- when alarm, short press resets alarm	
      Button myBtn(buttonPin, true,  true, 40);				// Declare the button( pin, pullup, invert, debounce ms)
      
      enum convertMode_t {channelA, channelB, channelAB} ;	// measurement modes, 32 port B / 128 port A / A & B
      
      HX711 scale;											// instantiate ADC
      
      // U8G instantiate, Change this constructor to match the display!!!
      U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);   // All Boards without Reset of the Display
      
      const int nettReadingsSize = 32 ; 						// the number of readings to determine the average and calculate variance/ accuracy
      double lastReading, lastReadingB ; 
      double nettReadings[nettReadingsSize] ; 				// store the rolling average of readings
      int nettReadingPointer = 0 ; 
      
      convertMode_t convertMode = channelA ;					// default channelA
      
      enum state_t {idleState, waitForRelease} ;      // define possible states
      static state_t state = idleState ;  
      
      
      void setup() {
      	Serial.begin(115200);
      
        Serial.println("AWI uA meter");
      
      	// u8g setup
      	u8g.begin() ;
      	u8g.setFont(u8g2_font_helvR14_tf);					// 'r' = reduced (or 'n' = numeric) font only for size
      	//u8g.setFont(u8g2_font_profont15_tf);					// 'r' = reduced (or 'n' = numeric) font only for size
      
      	// HX711.DOUT	- pin #A1
      	// HX711.PD_SCK	- pin #A0
      	// if parameter "gain" is ommited; the default value 128 is used by the library
      	//   64 & 128 is port A ; 32 is port B
      	scale.begin(HX711_dout, HX711_sck, 128); 			// set port based on state of selection
      
      	LCD_banner("Initializing") ;
      	Serial.print("read average: \t\t");
      	Serial.println(scale.read_average(20));  			// print the average of 20 raw readings from the ADC
      	
      	getOffset();										// get the offsets (drift values)
      	scale.set_offset(offsetChannelA) ;					// set it for measured channel
      	scale.set_scale(calibrationFactorA);				// this value is obtained by calibrating with known value; see the README for details
      	
      	Serial.print("read: \t\t");
      	Serial.println(scale.read());						// print a raw reading from the ADC
      	Serial.print("read average: \t\t");
      	Serial.println(scale.read_average(10));				// print the average of 20 readings from the ADC
      	Serial.print("get value: \t\t");
      	Serial.println(scale.get_value(5));					// print the average of 5 readings from the ADC minus the tare weight, set with tare()
      	Serial.print("get units: \t\t");
      	Serial.println(scale.get_units(5), 3);				// print the average of 5 readings from the ADC minus tare weight, divided by scale
      	Serial.println("Readings:");
      }
      
      void loop() {
      
      	//Serial.print("one reading:\t");
      	//Serial.print(scale.get_units(), 1);
      	//Serial.print("\t| average:\t");
      	//Serial.println(scale.get_units(30), 3);
      
        checkButton(); 
        
      	// get ADC readings dependent on setting: read A, B or A & B
      	// only A reads has average buffer when A&B mode is selected
      	if (convertMode == channelA){
      		scale.set_gain(128) ;
      		scale.set_offset(offsetChannelA) ;
      		scale.set_scale(calibrationFactorA );			// set division to A value and set mode to A
      		lastReading = scale.get_units(4) ; 			// get value (average 4 readings)corrected with scaling
      		nettReadings[nettReadingPointer] = lastReading ;	// store readings in averagebuffer
      		nettReadingPointer = (++nettReadingPointer) % nettReadingsSize ; // increment and wrap
          checkButton(); 
          LCD_local_display();
      	} else if (convertMode == channelB){
      		scale.set_gain(32) ;
      		scale.set_offset(offsetChannelB) ;
      		scale.set_scale(calibrationFactorB);			// set division to B value and set mode to B
      		lastReading = scale.get_units(4) ; 		  	// get value (average 4 readings)corrected with scaling
      		nettReadings[nettReadingPointer] = lastReading ;	// store readings in averagebuffer
      		nettReadingPointer = (++nettReadingPointer) % nettReadingsSize ; // increment and wrap
          checkButton(); 
          LCD_local_display();
      	} else if (convertMode == channelAB){				// if both channels average 128 readings iso 32 (no buffer)
      		scale.set_gain(128) ;
      		scale.set_offset(offsetChannelA) ;
      		scale.set_scale(calibrationFactorA);			// set division to A value and set mode to A
      		lastReading = scale.get_units(2) ; 		  	// get value (average 4 readings)corrected with scaling
      		checkButton(); 
      		scale.set_gain(32) ;
      		scale.set_offset(offsetChannelB) ;
      		scale.set_scale(calibrationFactorB);			// set division to A value and set mode to A
      		lastReadingB = scale.get_units(2) ; 			// get value (average 4 readings) corrected with scaling
          checkButton(); 
      		LCD_local_displayAB();
      	}
      	//scale.power_down();			       				// put the ADC in sleep mode
      	//delay(500);
      	//scale.power_up();
      	//delay(100);
      }
      
      void checkButton() { 
        
        myBtn.read();                   // read button state
        
        switch (state){
           case idleState:                  // Idle
            if (myBtn.wasPressed()) {       // Pressed 
              // change channel and wait release
              state = waitForRelease ;
            }
            break ;
          case waitForRelease:  
            if (myBtn.pressedFor(3000UL)) {  // Long Press 
               LCD_banner("Offset");
               getOffset();              
               state = idleState; 
            } else if (myBtn.wasReleased()) { // Short Press  
              state = idleState;
              switchMode() ;
            }
            break ;
          
        }
        
      }
      void LCD_banner(const char *s){
      /* prints all avaiable variables on LCD display with units
      	input: all "last" variables
      */
      	u8g.firstPage();
      	do {
      		int strWidth = u8g.getStrWidth(s) ;				// get the length of the string to determine print position
      		u8g.drawStr((128- strWidth)/2, 40, s ) ;			// print right aligned 
      	} while (u8g.nextPage()) ;
      }
      
      
      void LCD_local_display(void){
      /* prints all avaiable variables on LCD display with units
      	input: all "last" variables
      */
      	char buf[21];  										// buffer for max 20 char display
      	char lastNettBuf[14];
      	dtostrf(lastReading, 10, 2, lastNettBuf);			// Convert real to char
      	char averageNettBuf[14];
      	dtostrf(nettReadingsAverage(), 10, 2, averageNettBuf);	// Convert real to char
      	char spreadNettBuf[14];
      	dtostrf(nettReadingsSpread(), 10, 2, spreadNettBuf);	// Convert real to char
      	Serial.print("Average: \t") ; Serial.print(nettReadingsAverage());
      	Serial.print("\tSpread: \t") ; Serial.println(nettReadingsSpread());
      
      	u8g.firstPage();
      	do {
          checkButton(); 
      		snprintf(buf, sizeof buf, "Current %s", (convertMode==channelB)?"B":"A"); // Header
      		int strWidth = u8g.getStrWidth(buf) ;			//   length of the string to determine print position
      		u8g.drawStr((128- strWidth)/2, 14, buf ) ;		//   print middle aligned 
      		u8g.drawStr(0,31,"I") ;							// Current
      		snprintf(buf, sizeof buf, "%10s\xB5\A", lastNettBuf);
      		strWidth = u8g.getStrWidth(buf) ;				//   length of the string to determine print position
      		u8g.drawStr((128- strWidth), 31, buf ) ;		//   print right aligned 
      		u8g.drawStr(0,47,"avg") ;						// Average current
      		snprintf(buf, sizeof buf, "%10s\xB5\A", averageNettBuf);
      		strWidth = u8g.getStrWidth(buf) ;				// get the length of the string to determine print position
      		u8g.drawStr((128- strWidth), 47, buf ) ;		// print right aligned 
      		u8g.drawStr(0,63,"d\xB1") ;						// delta +/-
      		snprintf(buf, sizeof buf, "%10s\xB5\A", spreadNettBuf);
      		strWidth = u8g.getStrWidth(buf) ;				// get the length of the string to determine print position
      		u8g.drawStr((128- strWidth), 63, buf ) ;		// print right aligned 
      	} while (u8g.nextPage()) ;
      }
      void LCD_local_displayAB(void){
      /* prints A & B channel on LCD display with units
      	input: all "last" variables
      */
      	char buf[21];  										// buffer for max 20 char display
      	char lastNettBuf[14];
      	dtostrf(lastReading, 10, 2, lastNettBuf);			// Convert real to char
      	char lastNettBufB[14];
      	dtostrf(lastReadingB, 10, 2, lastNettBufB);			// Convert real to char
      	char lastNettBufAB[14];
      	dtostrf(lastReading +lastReadingB, 10, 2, lastNettBufAB);	// Convert real to char for added values
      	u8g.firstPage();
      	do {
          checkButton(); 
      		snprintf(buf, sizeof buf, "Current A+B"); 		// Header
      		int strWidth = u8g.getStrWidth(buf) ;			//   length of the string to determine print position
      		u8g.drawStr((128- strWidth)/2, 14, buf ) ;		//   print middle aligned 
      		u8g.drawStr(0,31,"IA");							// Current A
      		snprintf(buf, sizeof buf, "%10s\xB5\A", lastNettBuf);
      		strWidth = u8g.getStrWidth(buf) ;				//   length of the string to determine print position
      		u8g.drawStr((128- strWidth), 31, buf ) ;		//   print right aligned 
      		u8g.drawStr(0,47,"IB");							// Current B
      		snprintf(buf, sizeof buf, "%10s\xB5\A", lastNettBufB);
      		strWidth = u8g.getStrWidth(buf) ;				//   length of the string to determine print position
      		u8g.drawStr((128- strWidth), 47, buf ) ;		//   print right aligned 
      		u8g.drawStr(0,63,"A+B");						// Current A + B
      		snprintf(buf, sizeof buf, "%10s\xB5\A", lastNettBufAB);
      		strWidth = u8g.getStrWidth(buf) ;				//   length of the string to determine print position
      		u8g.drawStr((128- strWidth), 63, buf ) ;		//   print right aligned 
      	} while (u8g.nextPage()) ;
      }
      
      // calculate average of nett readings
      double nettReadingsAverage() {
      	double sum = 0;
      	for (byte i = 0; i < nettReadingsSize; i++) {
      		sum += nettReadings[ i ];
      	}
      	return sum / nettReadingsSize;
      }
      
      // calculate spread of nett readings (+/-)
      double nettReadingsSpread() {
      	double minReading = nettReadings[0];
      	double maxReading = minReading ;
      	for (byte i = 1; i < nettReadingsSize; i++) {
          checkButton(); 
      		if (minReading > nettReadings[ i ]){
      			minReading = nettReadings[i] ;
      		}
      		if (maxReading < nettReadings[ i ]){
      			maxReading = nettReadings[i] ; 
      		}
      	}
      	return (maxReading - minReading)/2 ;
      }
      
      // switch the mode
      void switchMode(){
      	if (convertMode == channelA){
      		convertMode = channelB ;
      	} else if (convertMode == channelB){
      		convertMode = channelAB ;
      	} else {
      		convertMode = channelA ;
      	}
      }
      
      // assuming both channels are shorted, calculate the offset values for channel A and B
      double getOffset(){
      	scale.set_gain(128) ;							// get channel A
      	offsetChannelA = scale.read_average(32) ;		// average 512 readings for offset
      	Serial.print("Offset A: \t") ; 
      	Serial.println(offsetChannelA);
      	scale.set_gain(32) ;							// get channel B
      	offsetChannelB = scale.read_average(32) ;		// average 512 readings for offset
      	Serial.print("Offset B: \t") ; 
      	Serial.println(offsetChannelB);
      }```
      posted in OpenHardware.io
      rvendrame
      rvendrame
    • RE: 💬 Micro (nano) ampere meter (double)

      @Nca78 , perfect, thank you! I was right with the two 1K resistors, but I connected the 1R 1W resistors both to E+, instead A+ and B+ separately...

      One more question, how did you connect the load to be measured? Sorry for dumb question, but this is the first time I build such type of device...

      posted in OpenHardware.io
      rvendrame
      rvendrame
    • RE: 💬 Micro (nano) ampere meter (double)

      @Nca78 , my HX711 board looks like yours. I'm a bit confused on how to connect the J1 pins to the load / power. Can you share how did you connected it? Thx!

      posted in OpenHardware.io
      rvendrame
      rvendrame
    • RE: 💬 OH 433Mhz Mysensors Bridge

      @LastSamurai , thanks for the great work. I just built one of these and it is working great.

      If your controller accepts long scene numbers (like my Vera does), we have the option to present it as a scene controller, instead individual buttons. The scene number will be the number of the button pressed. That makes life easy to add new panels around the house.

      Bellow is the sketch I created, based on your example. I also added a short/long-press logic, so for example for a 3-button panel, 6 different scenes can be triggered.

      /*
        This is a gateway node between mysensors and 433Mhz devices. A 433Mhz receiver is connected to pin 3 (int 1).
        This works with any 433Mhz device (as long as rc-switch understands the protocol).
      
        This is based on the MySensors network: https://www.mysensors.org
        This uses the rc-switch library to detect button presses: https://github.com/sui77/rc-switch
      
        Written by Oliver Hilsky 07.03.2017
        Adjusted to Scene controller by Ricardo Vendrame  03.06.2017 
      */
      
      #define LONG_PRESS_OFFSET 10000000UL  // Offset for long-press
      #define LONG_PRESS_COUNT  5           // Number of messages for long-press
      
      #define MY_RADIO_NRF24
      //#define MY_NODE_ID 25
      #define MY_BAUD_RATE 115200
      #define MY_DEBUG    // Enables debug messages in the serial log
      #define VCC_PIN 5
      #define GND_PIN 2
      #define RECEIVER_PIN 3
      
      //#include <EEPROM.h>
      #include <SPI.h>
      #include <MyConfig.h>
      #include <MySensor.h>
      //#include <Vcc.h>
      #include <RCSwitch.h>
      
      MySensor gw; 
      MyMessage msgSceneOn( 0 , V_SCENE_ON ); 
      MyMessage msgSceneOff( 0, V_SCENE_OFF ); 
      
      RCSwitch wirelessSwitch = RCSwitch();
      
      // Short/long press control 
      unsigned long lastreceive, count; 
      
      // add the decimal codes for your switches here
      unsigned long received_val; 
      
      void presentation()
      {
         
      #ifdef MY_NODE_ID
        gw.begin(NULL, MY_NODE_ID, false);
      #else
        gw.begin(NULL,AUTO,false);
      #endif
      
        gw.sendSketchInfo("433 Wireless Gateway", "1.0");
        gw.present( 0 , S_SCENE_CONTROLLER );
      
      }
      
      void setup() {
        
        Serial.begin(MY_BAUD_RATE); 
      
        // Power to Radio... 
        pinMode( VCC_PIN , OUTPUT ); 
        pinMode( GND_PIN , OUTPUT ); 
        digitalWrite( GND_PIN , LOW ); 
        digitalWrite( VCC_PIN , HIGH ); 
      
        // mySensors startup
        presentation(); 
        
        // Enable 433 receiving 
        wirelessSwitch.enableReceive(RECEIVER_PIN-2);  // Receiver on interrupt 
        
        Serial.println("Started listening on pin 3 for incoming 433Mhz messages");
      
        lastreceive = millis(); 
        
      }
      
      void loop() {
      
        gw.process(); 
        
        if ( wirelessSwitch.available() ) {  
      
          if ( ( millis() - lastreceive ) <= 200 ) count ++;
            else count = 1; 
            
          received_val = wirelessSwitch.getReceivedValue();
          wirelessSwitch.resetAvailable();
      
          lastreceive = millis(); 
          //Serial.println( lastreceive ); 
          
        }
      
        if ( count >= LONG_PRESS_COUNT || 
         ( ( millis() - lastreceive ) > 200 && count > 0 ) ) {
          
          // Send scene ID to the gateway
          if ( count >= LONG_PRESS_COUNT ) 
             received_val += LONG_PRESS_OFFSET;
              
          gw.send( msgSceneOn.set( received_val )); 
          
          Serial.print("Scene ");
          Serial.print( received_val ); 
          Serial.println( count < LONG_PRESS_COUNT ? " ON" : " OFF"); 
      
          // software debounce
          gw.wait(750); 
          //delay(750);
          count = 0; 
          wirelessSwitch.resetAvailable();
      
      
        } 
      
      }
      
      

      The edge for short/long press is defined by count of messages received (each message takes about 100ms to be received), so the default "5" in the sketch defines >= ~500ms as long press.

      #define LONG_PRESS_COUNT  5           // Number of messages for long-press
      

      And to distinguish between short and long press, a offset is added to the button number, defined here:

      #define LONG_PRESS_OFFSET 10000000UL  // Offset for long-press
      
      posted in OpenHardware.io
      rvendrame
      rvendrame
    • RE: 3.3 or 5v tranformer for mysensors projects

      @Tmaster , we have discussed the LNK302 chip a while ago, it may be interesting to check: https://forum.mysensors.org/search?term=lnk302&in=titlesposts

      I did POC here, and it does work, but I was a bit afraid of non-isolation so I decided to use the Hi-Link, assuming it would be more safe (and less components to assembly). I'm running a couple of nodes with Hi-Link for ~2 years without a glitch.

      The classic transformer approach for sure brings more isolation and safety. Also it is a good choice if you want to detect zero-cross (for AC dimmers) and measure real power consumption (by reading the real AC voltage from the transformer's AC output). On the other hand I see the bigger footprint as well as more components to assembly.

      Just my two cents...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: 💬 Floating Swimming Pool Sensor (Water Quality)

      @alexsh1 , I do agree. Now dfrobot also have one with 'industrial quality' , which is a bit cheaper than the one I bought from Phidgets. It may worth a try.

      https://www.dfrobot.com/product-1110.html

      posted in OpenHardware.io
      rvendrame
      rvendrame
    • RE: Mosfet with Ceech board

      @Jodaille , it works for me, when wiring the led between Vcc and the non-named pin where you put that orange (or brown?) wire. There is where I found the MOSFET N-channel drain is connected.

      alt text

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Mosfet with Ceech board

      You need to connect the LED (+resistor) like this:

      • Positive: Vcc Pin
      • Negative: The pin with the orange/brown wire in your picture.
        the mosfet onboard is N-channel, so it will switch the negative (GND) line.
      posted in Hardware
      rvendrame
      rvendrame
    • RE: Encapsulated transformers instead of traditional switching power supplies like Hi-Link

      I'm definitely not an expert on this, but here's my two cents: In very few countries (such as here in Brazil), we have both 220V/110V, it depends on the city where you live. So the switching PSU are more convenient for small electronics.

      You also need a bit more time/efforts to assembly (as you need the rectifier bridge, capacitor, regulator etc). Also a bit more space maybe.

      But the 'fire-proof' and 'galvanic isolation' sound as very good arguments --- I look forward to see your results...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Am I crazy?

      @gregl
      Yes I realized that I purchased a 'wrong' PH sensor, after more investigations. The ORP I bought from phidgets should be okay (as it is graded 'industrial'). It is ready to be connected to a PVC T piece too, and also costed a lot BTW. The ds18b20 I have is the waterproof version already, so no worries on that too.

      Do you think it worth I start with this cheap PH sensor just for 'piloting'? Will it last some months of constant usage at least? Or will it give up in few days?

      And what about the power supply part? It appears you choose to install your sensors at pump house, right? Do you see too much trouble for battery+solar powered version floating on the thank?

      Thanks for the good feedback!

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Am I crazy?

      @gregl, what sensor did you use for PH? I bought these two some time ago, but didn't have time to build up the sensor yet.

      PH:
      https://www.dfrobot.com/index.php?route=product/product&search=analog+ph+meter&description=true&product_id=1025

      ORP:
      http://www.phidgets.com/products.php?product_id=3556

      Temp:
      https://www.sparkfun.com/products/11050

      My original idea was to measure PH, ORP and Temp in a float sensor (perhaps powered by a li-ion 18650 battery, recharged by a solar panel on top).

      I was concerning about how waterproof I could make the case, yes. But I struggled much earlier: These sensors consume a reasonable mA power when running, and switch them ON and OFF via digital pins didn't work well ( I think there is some trouble with the 5V step-up I was using, tried some variations but never got it working fine).

      So I parked it for now and I'm looking forward for time available (and support) to re-start it.

      Just to share my history, without happy end (yet).

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Wakeuplight, all in the node or in the controller? Also some bits about serial api 1.5

      If you decide to put the logic part in the node, I recommend to use Over-the-Air (OTA) updates, as it will make life easier by not having to physically connect the node to a computer in case you/your wife didn't like the colors you initially choose.

      Only recent nodes were flashed with OTA, so I still preferring keep all logic into the controller.

      My two cents ....

      posted in Development
      rvendrame
      rvendrame
    • RE: Which Lab Power Supply?

      @AWI , a did a similar thing, but never got the volt/amper meter work properly on the 'negative side'. Mine looks very similar (to not say identical) to yours... Would you mind to share how did you connected the V-A meters?

      posted in Hardware
      rvendrame
      rvendrame
    • RE: MYSBootloader never finishes

      @jbjalling , I had a similar behavior in one node placed far from gateway (and with a repeater in between). It worked for me once I brought the node near by the gateway (and bypassed the repeater).

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Motion Sensor triggering on its own

      @Maciej-Kulawik if so, your PIR looks to need at least 3.3V, so the ~3V from 2xAA is not enough and it is causing instabilities (probably the same as reported by others here).

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Motion Sensor triggering on its own

      @Maciej-Kulawik It can be that the on-board LDO needs more than 3.3v to activate. It maybe even dropping the voltage from batteries, and doing nothing but disturbing 🙂 Maybe it worth to remove it when running the circuit with 3V from batteries.

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Motion Sensor triggering on its own

      @Maciej-Kulawik , maybe if you try to power the PIR with +5V for a while and watch the results? Don't forget to keep all GNDs inter-connected...

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Motion Sensor triggering on its own

      @Maciej-Kulawik , how are you powering the node? I had once a PIR false-triggering due power instabilities...

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: AC light dimmer with 2x TRIAC

      @jacikaas said:

      When I turn it on, bulb also graceful goes to 100%, but when max power had been reached - power instantly goes to 0% and in Domoticz status leaves as ON.
      But if I use slipper to set 100% - dim level leaves and light bulb is shining as 100%.

      I saw you still using 'static int' instead 'volatile int' for currentLevel . Did you try 'volatile int' ?

      Apart from that, I don't see any other reason for that. Perhaps something into controller side (domoticz)? I use Vera Lite with similar arduino circuit as yours, and I never had this behavior in my setup.

      posted in My Project
      rvendrame
      rvendrame
    • RE: Connecting the relay

      @moskovskiy82 , it makes sense. Glad you ruled it out!

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Connecting the relay

      @moskovskiy82

      The 5V and VIN pins are not the same thing, per original arduino nano schematics.

      0_1456582784868_Captura de tela 2016-02-27 11.18.28.png

      Usually the relay "click" generates some noise on the power lines, which may disturb ( = freeze, hang) arduino and/or nRF radio.

      Maybe once you connect it through the 5V, the regulator is reducing that noise? You might try to add capacitors between relay's VIN and GND, 47uF could be a starting point.

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: AC light dimmer with 2x TRIAC

      @jacikaas

      The analogWrite will fire the triac based on PWM concept, and not synched to zero_cross detection, so in my opinion it would bring more problems than solutions.

      You might be suffering from electrical problems at your zero-cross circuit. It might be not detecting all zero-crosses (or false triggering).

      Maybe if you have a oscilloscope you could check the activity in "zero-cross signal out" pin, it should give you precisely 100 pulses in one second, if working good.

      Another try is to change the '75' constant at dimtime calculation, try increase and/or decrease it a bit, and watch the results...

      posted in My Project
      rvendrame
      rvendrame
    • RE: AC light dimmer with 2x TRIAC

      @jacikaas

      You must declare variables as 'volatile' to ensure they will be updated during interrupts. Try changing:

      static int currentLevel = 128;  // Current dim level...
      

      into

      volatile int currentLevel = 128;  // Current dim level...
      

      And to ensure no triac firing at zero level, try something like this at beginning of zero_cross_int() (before the "int dimtime"):

      if ( currentLevel == 0 )  return; 
      

      Good luck again!

      posted in My Project
      rvendrame
      rvendrame
    • RE: AC light dimmer with 2x TRIAC

      @jacikaas please post your actual sketch...

      posted in My Project
      rvendrame
      rvendrame
    • RE: AC light dimmer with 2x TRIAC

      @jacikaas

      Try changing this line (not tested):

       int dimtime = (75*currentLevel);    // For 60Hz =>65    
      
      

      to

       int dimtime = (75* ( 128-currentLevel) );    // For 60Hz =>65    
      
      

      Also remove this line to avoid the flicker:

      
        analogWrite( LED_PIN, (int)(currentLevel / 100. * 255) );
      

      ... and finally add this line right before the "fadeToLevel( requestedLevel );" , in order to convert 0-100 range into 0-128 range:

       requestedLevel = map( requestedLevel, 0 , 100 , 0 , 128 ); 
      

      Good luck!

      posted in My Project
      rvendrame
      rvendrame
    • RE: Battery button sensor

      @Ivan-Z , how much do you expect for battery life (assuming a regular 250mA CR2032, in the scenario of a single button, regular daily usage in house lighting.

      posted in OpenHardware.io
      rvendrame
      rvendrame
    • RE: Node error when power via vcc/gnd, OK when using FTDI connection

      @sjoerd14 How do you power the arduino when not via FTDI? The nRF radio is very sensitive to power noise (for example from cheap phone chargers).
      Do you have a cap between radio VCC/GND?

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Graphing via RPi to website

      @stubtoe

      I use the Vera's dataMine plugin for such. It works well for me. Data is stored in a USB sticked plugged directly into my Veralite's USB port.

      posted in My Project
      rvendrame
      rvendrame
    • RE: How to do resend when st=fail on a Repeater

      @doblanch , not sure if I understood. gw.process is used to listen to incoming radio messages, while gw.send is to transmit messages, and is present on every example sketch here. For example the 'Door/Window/Button' sensor:

      void loop() 
      {
        debouncer.update();
        // Get the update value
        int value = debouncer.read();
       
        if (value != oldValue) {
           // Send in the new value
           gw.send(msg.set(value==HIGH ? 1 : 0));
           oldValue = value;
        }
      } 
      
      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Test of Step-Up-Modules (sparkfun, Pololu & china-module) / any other?

      @ericvdb , do you have any data sheet for this step-up? Or do you know which is the core chip?

      posted in Hardware
      rvendrame
      rvendrame
    • RE: How to do resend when st=fail on a Repeater

      @doblanch ,

      I see two ways of implementing it (despite I never tried):

      1. gw.send( msg ) returns false in case transmission fails.

      OR

      1. gw.send( msg, true ) will request an ack from controller, which should arrive back in few seconds if everything went well.

      In both cases, you have to write your own logic to retry.

      http://www.mysensors.org/download/sensor_api_15#the-full-api

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Battery powered sensor - low voltage threshold

      @scalz said:

      Stepup don't need lot of power for enable pin.

      The step up I have doesn't have 'enable pin'. Only input +/- and a USB output. So I connected the BC549 between GND and "IN -" , with its base connected to arduino D4 via 10K resistor. IN+ is connected directly to battery.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Battery powered sensor - low voltage threshold

      @mfalkvidd said:

      So you'll get a maximum of 28 days battery life. You'll need a step-up that is more efficient at low power, or shut off the step-up when the PH sensor isn't used.

      Yes, I tried to put a transistor (the only I had was a BC549) to switch the step up, however it did not work. The step up doesn't turn ON, when I have the PH sensor connected. It does work with smaller load (a DHT11 for example). The PH sensor consumes about 25mA.

      Maybe the poor BC549 is not powerful/fast enough for the step up? I will buy some 2N2222 just in case . Any comments?

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Battery powered sensor - low voltage threshold

      @epkboan , @scalz I'm currently evaluating a 5V step up to power up a PH sensor, with 2x AA batteries.

      Not sure if my multimeter is fine but I'm reading ~3mA consumption with just the step up connected (just the batteries and step up, nothing else).

      Isn't too much? My step up is the one from mySensor store link...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: PH and Temp controller with arduino

      @stingone , I'm doing something similar (and not finished yet).

      One comment regarding the PH sensor, if you want to have it continuously immersed in the water, this one you mentioned may not last too long (6months or less).

      I learned (in the hard way) that for long-lasting you need "industrial grade" ( = expensive ).

      This is the one I bought, see the comments in the section "Difference between SEN0161 and SEN0169:"
      http://dfrobot.com/wiki/index.php/PH_meter(SKU:_SEN0161)

      Hope it helps somehow...

      posted in My Project
      rvendrame
      rvendrame
    • RE: st:fail sometimes and sometimes OK

      @flopp said:

      sorry for asking so much
      after each gw.send?

      Yes

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: st:fail sometimes and sometimes OK

      @flopp said:

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

      Sensor. And capacitors on both.

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: st:fail sometimes and sometimes OK

      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.

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: Change power output?

      Just to add my two cents, the cheap pro mini clones that I bought didn't went well with 12V on raw pin, as 12V is the absolute maximum on their regulators. Some of them simply burned after some minutes , some got installable.

      To be on safe side, I don't put more than 9V on raw. You can use a 7809 for example to get 9V out of original 12V

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Wired instead of wireless sensors; How To?

      @MaxG , maybe this may help a bit.

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: 110v-230v AC to Mysensors PCB board

      @m26872 , is it also true in case the PSU itself fail? And what happens if the circuit consumes more current than zener rating? I'm my (poor) knowledge, zeners are more relevant for stabilization, while varistor are effective 'protection' devices...

      posted in Hardware
      rvendrame
      rvendrame
    • RE: 110v-230v AC to Mysensors PCB board

      @bjornhallberg said:

      I ordered some 5.1V and 5.6V 1206 SMD diodes

      Just to remember, the typical zeners are 1W , which gives a max of 200mA of output capacity, pretty enough for Arduino+radio, but maybe not enough for many relays / Leds etc. And if they burn due overload, they will allow all voltage/current flowing from PSU into arduino.

      That explains why we suggested the varistor, in order to short the PSU output and trigger its internal protection. Strange that your varistors didn't survive... Bad lot? Maybe they are not 5.5V as stated?

      posted in Hardware
      rvendrame
      rvendrame
    • RE: OTA FW on Repeater Nodes???

      @tekka , @Oitzu , I finally managed to have some time for this.

      This is the serial monitor output from the node, as soon as I request the FW update via MYSController (it is a endless loop):

      read: 0-0-9 s=0,c=3,t=13,pt=0,l=1,sg=0:0
      Device Init...
      ��Sensor start...
      send: 9-9-0-0 s=255,c=0,t=18,pt=0,l=3,sg=0,st=ok:1.5
      Device Init...
      ��Sensor start...
      send: 9-9-0-0 s=255,c=0,t=18,pt=0,l=3,sg=0,st=ok:1.5
      Device Init...
      

      And I tried to upload the new FW via FTDI adapter (in order to test with the repeater function off), however I got an error from avrdude (maybe my pro mini is broken somehow?)

      avrdude: Version 6.0.1, compiled on Apr 14 2015 at 16:30:25
               Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
               Copyright (c) 2007-2009 Joerg Wunsch
      
               System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
               User configuration file is "/Users/i007897/.avrduderc"
               User configuration file does not exist or is not a regular file, skipping
      
               Using Port                    : /dev/cu.usbserial-A50285BI
               Using Programmer              : arduino
               Overriding Baud Rate          : 57600
      avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xbe
      avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xbe
      avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xf2
      avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe6
      avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x52
      avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x9f
      avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe5
      avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xd2
      avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x43
      avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xd7
      
      avrdude done.  Thank you.
      

      Thanks!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: LE33ACZ problems

      @Aloha said:

      @rvendrame, have you tried both with capacitor and without? Did it make any difference to you?

      I usually add the 4.7uF cap between radios's VCC and GND, but I'm still getting some eventual st=fail on some distant radios... It worth a try I'd say.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: LE33ACZ problems

      @Aloha , I use these regularly in my projects without any issue. Just once when I swapped vin and vout 😉

      LE33.jpeg

      posted in Hardware
      rvendrame
      rvendrame
    • RE: Find parent - hardware or software issue?

      The controller is responsible to handle NodeIDs. If you don't have a controller, you must hardcode sensorIDs at the gw.begin, like you did. Gateway is node 0 and nodes should have different IDs ranging from 1 to 254.

      Once you do like that, you should see your gateway receiving data from nodes.

      posted in Development
      rvendrame
      rvendrame
    • RE: Find parent - hardware or software issue?

      @Marco-van-Noord said:

      i should at least see some output on the serial port of the gateway when another device starts up?

      Yes

      @Marco-van-Noord said:

      but whenever i restart a sensor, i do not get any new messages, is this correct?

      No

      What the node shows on serial monitor during startup?

      posted in Development
      rvendrame
      rvendrame
    • RE: Controlling LEDs with the IRLZ44N

      I had a similar problem in the past, and realized that I was using IRFZ instead IRLZ, which has a higher gate threshold voltage. I replaced my 3.3V arduino pro mini by a 5V version, and that did the trick in my case.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: AC diming

      @FotoFieber , I use some 230V dimmable leds that I bought from IKEA in Germany about 1 year ago and and they work good. Some are Philips and some are IKEA-branded.
      Most important is the 'dimmable' word on them. Most of current led drivers are not designed for AC dimming, as this increase the unit costs (usually the driver is more expensive than the leds itself)...

      posted in My Project
      rvendrame
      rvendrame
    • RE: Need idea for turn off speakers when tv is off

      I monitor my Samsung smartTV using the Vera's ping sensor plugin and it works very well.

      posted in General Discussion
      rvendrame
      rvendrame
    • RE: Stupid question about powering leds

      @Cliff-Karlsson , welcome to the Ohm law. 😉

      220ohm resistor on 3.3V = 15mA current, enough to power up most of common leds.

      Supposing your LEDs consume lets say 20mA each, and you want power 4 together, you need to provide 80mA instead, so U = R/I ==> 3.3 = R / 0.080 ==> R = 41.25 Ohms.

      -- BUT --- Each arduino output pin can provide a maximum of 40mA, so if you connect the 4 leds into one single pin, the leds will not receive enough power to light up, or worst, the arduino's pin internal driver will burn (most probable).

      In this case you have to either use more output pins (in order to distribute the load), or use a transistor to drive the output, like demonstrated by @hek in the LED Dimmer.

      Hope it helps

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: How To - Doorbell Automation Hack

      @timropp , If you are following the circuits posted above, the relays should provide complete isolation between 5VDC and 16VAC, so everything fine .

      posted in My Project
      rvendrame
      rvendrame
    • RE: OTA FW on Repeater Nodes???

      @tekka , I'm currently traveling so only in two weeks from now. I posted the 'Info' from the node at first post, maybe it helps some how? Bootloader is 'N/A' there, could be something in there?

      Captura de tela 2015-10-27 14.07.14.png

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: power NRF24L01+PA+LNA from FTDI USB to TTL Serial Adapter

      The PA+LNA version can drawn up to 150ma when transmitting. The 3.3v on nano is usually provided by the FTDI chip, which in general can't go more of 50mA.

      posted in Hardware
      rvendrame
      rvendrame
    • RE: OTA FW on Repeater Nodes???

      @tekka , the begin of log is like that:

      10/27/2015 14:31:18 INFO FW "myMultiSensor" assigned to node 9
      10/27/2015 14:31:21 TX 9;0;3;0;13;0
      10/27/2015 14:31:21 RX 0;0;3;0;9;send: 0-0-9-9 s=0,c=3,t=13,pt=0,l=1,sg=0,st=ok:0
      10/27/2015 14:31:21 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:21 CHILD New child discovered, node id=9, child id=internal
      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY
      10/27/2015 14:31:22 RX 9;255;0;0;18;1.5
      10/27/2015 14:31:22 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5

      ... and from here on, thousands of repetitions of same messages. It only stops by turning off the power of the node.

      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY
      10/27/2015 14:31:22 RX 9;255;0;0;18;1.5
      10/27/2015 14:31:22 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY
      10/27/2015 14:31:18 INFO FW "myMultiSensor" assigned to node 9
      10/27/2015 14:31:21 TX 9;0;3;0;13;0
      10/27/2015 14:31:21 RX 0;0;3;0;9;send: 0-0-9-9 s=0,c=3,t=13,pt=0,l=1,sg=0,st=ok:0
      10/27/2015 14:31:21 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:21 CHILD New child discovered, node id=9, child id=internal
      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY
      10/27/2015 14:31:22 RX 9;255;0;0;18;1.5
      10/27/2015 14:31:22 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY
      10/27/2015 14:31:22 RX 9;255;0;0;18;1.5
      10/27/2015 14:31:22 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: OTA FW on Repeater Nodes???

      @tekka , regular Arduino (pro-mini clone) with MYSBootloader.

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: OTA FW on Repeater Nodes???

      @Oitzu , sure I will try it, but only in two weeks. Thanks for the hint!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: OTA FW on Repeater Nodes???

      @Oitzu said:

      I really can not see why the node keeps rebooting over and over.
      Maybe enable Serial debug directly on the node?

      That will be my last try, after I return from a trip (in two weeks). Thanks anyway!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: OTA FW on Repeater Nodes???

      @Oitzu , sure,

      It started like that:

      10/27/2015 14:31:18 INFO FW "myMultiSensor" assigned to node 9
      10/27/2015 14:31:21 TX 9;0;3;0;13;0
      10/27/2015 14:31:21 RX 0;0;3;0;9;send: 0-0-9-9 s=0,c=3,t=13,pt=0,l=1,sg=0,st=ok:0
      10/27/2015 14:31:21 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:21 CHILD New child discovered, node id=9, child id=internal

      ... and then gets into the endless loop:

      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY
      10/27/2015 14:31:22 RX 9;255;0;0;18;1.5
      10/27/2015 14:31:22 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY
      10/27/2015 14:31:22 RX 9;255;0;0;18;1.5
      10/27/2015 14:31:22 RX 0;0;3;0;9;read: 9-9-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
      10/27/2015 14:31:22 DEBUG Update child id=255, type=ARDUINO_RELAY

      And here's my sketch (the one current in node is a bit different, but not significant):

      #include <MySensor.h>
      #include <SPI.h>
      #include <DHT.h>
      #include <IRLib.h>
       
      //  IO PINS
      #define MOTION 4  // The digital input you attached your motion sensor. 
      #define IR_LED 3  // Infrared LED output 
      #define DHT11  2  // Temp/Hum sensor 
      #define LDR    A0 // LDR (Light sensor) - Pull-down of 10K to GND
      
      //  Interval between reads (Temp/Hum/Light) 
      #define INTERVAL  720000  // 720s = 12min 
      
      MySensor gw;
      DHT dht ;
      IRsend ir;
      
      // Initialize messages
      MyMessage msg_motion( 1, V_TRIPPED );
      MyMessage msg_Hum( 2, V_HUM );
      MyMessage msg_Temp( 3, V_TEMP) ;
      MyMessage msg_light( 5, V_LIGHT_LEVEL ); 
       
      boolean metric = true;
      boolean lastMotion = false;
      float   temp , hum ; 
      int     lightLevel ; 
      
      unsigned long lastRun ; 
      
      void setup()
      {
        Serial.begin(115200);
        Serial.println("Device Init..."); 
        
        // Init sensors  
        pinMode( MOTION , INPUT );
        dht.setup( DHT11 ); 
      
        // Init mySensors
        Serial.println("mySensor start..."); 
        gw.begin( incomingMessage );  //  , AUTO , true );  // Repeater mode  
        
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("myMultiSensor", "1.2");
      
        // Register all sensors to gw (they will be created as child devices)
        gw.present( 1 , S_MOTION ); 
        gw.present( 2 , S_HUM );
        gw.present( 3 , S_TEMP );
        gw.present( 4 , S_SCENE_CONTROLLER ); 
        gw.present( 5 , S_LIGHT_LEVEL ); 
      
        metric = gw.getConfig().isMetric;
        lastRun = 0;
        
      }
      
      void loop()
      {
      
        // mySensors Radio handling
        gw.process(); 
        
        // Temp/Hum
        if ( lastRun == 0 || ( millis() - lastRun ) > INTERVAL )  { 
      
          ////// Check Temperature
          delay(dht.getMinimumSamplingPeriod());
      
          temp = dht.getTemperature();
          
          if (!metric) temp = dht.toFahrenheit(temp);
          
          gw.send(msg_Temp.set( temp , 0 ) , true );
          Serial.print("T: ");
          Serial.println( temp , 0 );
          
          ////// Check Humidty 
          delay(dht.getMinimumSamplingPeriod());
      
          hum  = dht.getHumidity();
          
          gw.send(msg_Hum.set( hum , 0 ) , true );
          Serial.print("H: ");
          Serial.println( hum , 1 );
        
          if (isnan( temp ) || isnan( hum ) ) 
          {
             Serial.println("Failed to read from DHT");
          } 
      
          ////// Check Light Level 
          lightLevel = map( analogRead( LDR ) , 0 , 1023 , 0, 100 ) ; 
          gw.send( msg_light.set( lightLevel ) , true ); 
          Serial.print("L: "); 
          Serial.println( lightLevel ); 
          
          lastRun = millis();
      
        }
      
        /////     Motion
        if ( digitalRead( MOTION ) != lastMotion ) { 
          gw.send(msg_motion.set( lastMotion? "0" : "1" ) , true ); // Send tripped value to gw
          Serial.print("M: "); 
          Serial.println( lastMotion? "0" : "1" );  
          lastMotion = !lastMotion; 
        } 
      
      
      }
      
      ///////////// Scene controller (IR) 
      void incomingMessage( const MyMessage &message) {
        
        // SCENE ON   (Note: SCENE OFF is not supported by compactwall) 
        if ( message.type == V_SCENE_ON ) {
          
          //  Retrieve the scene number
          int scene = atoi( message.data );  
       
          Serial.print( "Scene " );
          Serial.print( scene ); 
          Serial.println( " ON" ) ; 
          
          // Send comand to scenario compactwall module via Infrared LED
          long ir_command = 0x1380 + scene; 
          ir.send( RC5 , ir_command , 32 );
       
          }
          
          
      }
      
      

      Thanks a lot!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • OTA FW on Repeater Nodes???

      Hello everyone,

      I recently enabled repeater function in one of my nodes, and now when I try to update its firmware OTA with MYSController, instead the regular FW update messages, I get thousands of this:

      Captura de tela 2015-10-27 14.02.02.png

      Captura de tela 2015-10-27 14.05.58.png

      The GW is on latest 1.5 master branch version.

      The repeater node is also on 1.5, but a bit lower (I installed it ~4 month ago I think)
      Captura de tela 2015-10-27 14.07.14.png

      I'm using latest 0.1.2.282 MYSController.

      Any ideia about what can be wrong? I rebooted the node after 20k+ messages, it started normally and is responding fine, tough it still not up-to-date.

      I'm sure I was able to OTA-update it before switching repeater ON...

      Help!

      posted in Troubleshooting
      rvendrame
      rvendrame
    • RE: MySensor collides with LowPower's SLEEP_ enum

      Adding my two cents, if you keep radio always on and only sleep arduino, at the end of day you didn't save too much, as the radio is usually the most power consuming in the equation...

      If you plan to run on batteries definitely sleep radio if you want to extend runtime. You might wake up both arduino+radio from time to time and use gw.request() to retrieve the latest status of anything you might need.

      posted in Bug Reports
      rvendrame
      rvendrame
    • RE: Will the Arduino mini 3.3v give enough stable power for nRF ?

      @ahmedadelhosni , for a definitive answer you must check what kind of regulator your board has, as well as how much each component of your circuit will consume.

      The official pro-mini uses an MIC5205 voltage regulator that can deliver maximum of 150mA.

      Most clones uses a cheaper regulator (such as the 100mA LP2981 that I found in my pro-minis).

      The official nRF24l01 radio consumes about 15mA while transmitting/receiving. You have to add on top of it the arduino itself, as well as any other components that you are powering up.

      And to be on safe side I would not use more than 60-70% of nominal regulator's output.

      Hope it helps...

      posted in General Discussion
      rvendrame
      rvendrame