Navigation

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

    Posts made by carleki

    • RE: coin-cell (CR2032) powered temperature sensor

      @fleinze
      Hi, do you think it's possible to connect de Dallas sensor to pin 7, 8 and 9 of the arduino ?

      Like this :

      #define ONE_WIRE_BUS 8 // Pin where dallase sensor is connected
      #define ONE_WIRE_GND 9
      #define ONE_WIRE_VCC 7
      

      I have tried, and the temperature is always 85°C ...

      posted in My Project
      carleki
      carleki
    • RE: Measuring battery

      Hello @mrc-core

      You can use the Vcc.h library, and mesure the voltage without any wire 😉

      https://github.com/Yveaux/Arduino_Vcc

      posted in My Project
      carleki
      carleki
    • fail converting 1.5 sketch to 2.0

      Hi guys !

      I'm trying to convert a temperature sketch with CR2032 battery monitoring, and the OneWire without resistor lib (to avoid the 4.7k resistor attached to the Dallas)

      But, it seems I have not well followed the instructions to convert a sketch from 1.5.4 to 2.0, because it won't compile !

      Here is the original sketch (1.5) :

      // avec mesure de la batterie avec Vcc.h
      // ok avec pile CR2032 et docATmega328 8Mhz MYSBootloader et efuse 0x07
      // pour DS18B20 SANS resistance
      // nécessite la lib OneWire : OneWireNoResistor-master.zip
      //
      // boards.txt :
      //proMYSBL.name=docATmega328 8Mhz MYSBootloader
      
      //proMYSBL.upload.tool=avrdude
      //proMYSBL.upload.protocol=arduino
      //proMYSBL.upload.maximum_size=30720
      //proMYSBL.upload.maximum_data_size=2048
      //proMYSBL.upload.speed=115200
      
      //proMYSBL.bootloader.tool=avrdude
      //proMYSBL.bootloader.low_fuses=0xE2
      //proMYSBL.bootloader.high_fuses=0xDA
      //proMYSBL.bootloader.extended_fuses=0x07
      //proMYSBL.bootloader.unlock_bits=0x3F
      //proMYSBL.bootloader.lock_bits=0x0F
      //proMYSBL.bootloader.file=MySBootloader/MYSBootloader.hex
      
      //proMYSBL.build.mcu=atmega328p
      //proMYSBL.build.f_cpu=8000000L
      //proMYSBL.build.board=AVR_UNO
      //proMYSBL.build.core=arduino:arduino
      //proMYSBL.build.variant=arduino:standard
      #include <MySensor.h>
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      #include <Vcc.h>
      
      #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected
      #define ONE_WIRE_GND 5
      #define ONE_WIRE_VCC 3
      #define ID_BatPcnt 1
      #define ID_Bat 2
      
      #define MAX_ATTACHED_DS18B20 16
      
      // 60000 = 1 minute
      // 12000 = 2 minutes
      // 300000 = 5 minutes
      // 600000 = 10 minutes
      #define SLEEP_TIME 300000  // Sleep time between reads (in milliseconds)
      
      
      
      
      const float VccMin   = 2.3;             // Vcc mini attendu, en Volts.
      const float VccMax   = 3;           // Vcc Maximum attendu, en Volts (2 piles AA neuves)
      const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2
      Vcc vcc(VccCorrection);
      
      OneWire oneWire(ONE_WIRE_BUS);
      DallasTemperature sensors(&oneWire);
      MySensor gw;
      MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles
      MyMessage msgBAT(ID_Bat,V_VAR2);          // on utilise le type V_VAR2 pour la tension des piles
      float lastTemperature[MAX_ATTACHED_DS18B20];
      uint8_t numSensors = 0;
      boolean receivedConfig = false;
      boolean metric = true;
      // Initialize temperature message
      MyMessage msg(0, V_TEMP);
      int oldvalue = 0;
      int node_id = 30; // on donne un ID au node
      
      void setup()
      {
        // Startup OneWire
      #ifdef ONE_WIRE_VCC
        pinMode(ONE_WIRE_VCC, OUTPUT);
        digitalWrite(ONE_WIRE_VCC, HIGH);
      #endif
      #ifdef ONE_WIRE_GND
        pinMode(ONE_WIRE_GND, OUTPUT);
        digitalWrite(ONE_WIRE_GND, LOW);
      #endif
      
        analogReference(INTERNAL);
        pinMode(BATT_IN_PIN, INPUT);
        pinMode(BATT_VCC_PIN, OUTPUT);
        digitalWrite(BATT_VCC_PIN, LOW);
      
        sensors.begin();
      
        // Startup and initialize MySensors library. Set callback for incoming messages.
       // gw.begin();
        gw.begin(NULL, node_id, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Temperature Sensor", "1.0");
      
        // Fetch the number of attached temperature sensors
        numSensors = sensors.getDeviceCount();
      
        sensors.setWaitForConversion(false);//saves a few mAs per read :-) to debug
      
        // Present all sensors to controller
        gw.present(ID_BatPcnt, S_CUSTOM);  // type S_CUSTOM pour le capteur "% de charge"
        gw.present(ID_Bat, S_CUSTOM);      // type S_CUSTOM pour le capteur "tension"
        for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
          gw.present(i, S_TEMP);  
        }
      }
      
      
      void loop()
      {
        // Process incoming messages (like config from server)
        //gw.process();
      // mesure de Vcc
            float v = vcc.Read_Volts();
            // calcul du % de charge batterie
            float p = 100 * ((v - VccMin) / (VccMax - VccMin));
            // On envoie les données des capteurs et de l'état de la batterie au Gateway
            //gw.sendBatteryLevel(p);  // Inutile...
            gw.send(msgBAT_PCNT.set(p, 1)); // 1 décimale
            gw.send(msgBAT.set(v, 3));      // 2 décimales
        // Fetch temperatures from Dallas sensors
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures();
      
        gw.sleep(750);//wait for conversion in sleep mode
      
        // Read temperatures and send them to controller
        for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
      
          // Fetch and round temperature to one decimal
          float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.;
      
          // Only send data if temperature has changed and no error
          gw.send(msg.setSensor(i).set(temperature, 1));
            lastTemperature[i] = temperature;
          //if (lastTemperature[i] != temperature && temperature != -127.00) {
      
            // Send in the new temperature
            
          //}
        }
       
        gw.sleep(SLEEP_TIME);//wake on interrupt or after sleep-time
      }
      

      Here is my "converted" sketch :

      // avec mesure de la batterie avec Vcc.h
      // ok avec pile CR2032 et docATmega328 8Mhz MYSBootloader et efuse 0x07
      // pour DS18B20 SANS resistance
      // nécessite la lib OneWire : OneWireNoResistor-master.zip
      //
      // boards.txt :
      //proMYSBL.name=docATmega328 8Mhz MYSBootloader
      
      //proMYSBL.upload.tool=avrdude
      //proMYSBL.upload.protocol=arduino
      //proMYSBL.upload.maximum_size=30720
      //proMYSBL.upload.maximum_data_size=2048
      //proMYSBL.upload.speed=115200
      
      //proMYSBL.bootloader.tool=avrdude
      //proMYSBL.bootloader.low_fuses=0xE2
      //proMYSBL.bootloader.high_fuses=0xDA
      //proMYSBL.bootloader.extended_fuses=0x07
      //proMYSBL.bootloader.unlock_bits=0x3F
      //proMYSBL.bootloader.lock_bits=0x0F
      //proMYSBL.bootloader.file=MySBootloader/MYSBootloader.hex
      
      //proMYSBL.build.mcu=atmega328p
      //proMYSBL.build.f_cpu=8000000L
      //proMYSBL.build.board=AVR_UNO
      //proMYSBL.build.core=arduino:arduino
      //proMYSBL.build.variant=arduino:standard
      #include <MySensors.h>
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      #include <Vcc.h>
      
      #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected
      #define ONE_WIRE_GND 5
      #define ONE_WIRE_VCC 3
      
      
      #define ID_BatPcnt 1
      #define ID_Bat 2
      
      #define MAX_ATTACHED_DS18B20 16
      #define MY_NODE_ID 123
      #define MY_RADIO_NRF24
      
      // 60000 = 1 minute
      // 12000 = 2 minutes
      // 300000 = 5 minutes
      // 600000 = 10 minutes
      #define SLEEP_TIME 300000  // Sleep time between reads (in milliseconds)
      
      
      const float VccMin   = 2.3;             // Vcc mini attendu, en Volts.
      const float VccMax   = 3;           // Vcc Maximum attendu, en Volts (2 piles AA neuves)
      const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2
      Vcc vcc(VccCorrection);
      
      OneWire oneWire(ONE_WIRE_BUS);
      DallasTemperature sensors(&oneWire);
      //MySensor gw;
      MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles
      MyMessage msgBAT(ID_Bat,V_VAR2);          // on utilise le type V_VAR2 pour la tension des piles
      float lastTemperature[MAX_ATTACHED_DS18B20];
      uint8_t numSensors = 0;
      boolean receivedConfig = false;
      boolean metric = true;
      // Initialize temperature message
      MyMessage msg(0, V_TEMP);
      int oldvalue = 0;
      
      void before()
      {
        // Startup up the OneWire library
        sensors.begin();
      }
      
      void setup()
      {
        // Startup OneWire
      #ifdef ONE_WIRE_VCC
        pinMode(ONE_WIRE_VCC, OUTPUT);
        digitalWrite(ONE_WIRE_VCC, HIGH);
      #endif
      #ifdef ONE_WIRE_GND
        pinMode(ONE_WIRE_GND, OUTPUT);
        digitalWrite(ONE_WIRE_GND, LOW);
      #endif
      
        analogReference(INTERNAL);
        pinMode(BATT_IN_PIN, INPUT);
        pinMode(BATT_VCC_PIN, OUTPUT);
        digitalWrite(BATT_VCC_PIN, LOW);
      
          
      }
      
      void presentation()
      {
        // Startup and initialize MySensors library. Set callback for incoming messages.
       // gw.begin();
        //gw.begin(NULL, node_id, true);
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("TS sR batt", "2.0");
      
        // Fetch the number of attached temperature sensors
        numSensors = sensors.getDeviceCount();
      
        sensors.setWaitForConversion(false);//saves a few mAs per read :-) to debug
      
        // Present all sensors to controller
        present(ID_BatPcnt, S_CUSTOM);  // type S_CUSTOM pour le capteur "% de charge"
        present(ID_Bat, S_CUSTOM);      // type S_CUSTOM pour le capteur "tension"
        for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
          present(i, S_TEMP);  
        }
      }
      
      void loop()
      {
        // Process incoming messages (like config from server)
        //gw.process();
      // mesure de Vcc
            float v = vcc.Read_Volts();
            // calcul du % de charge batterie
            float p = 100 * ((v - VccMin) / (VccMax - VccMin));
            // On envoie les données des capteurs et de l'état de la batterie au Gateway
            //gw.sendBatteryLevel(p);  // Inutile...
            send(msgBAT_PCNT.set(p, 1)); // 1 décimale
            send(msgBAT.set(v, 3));      // 2 décimales
        // Fetch temperatures from Dallas sensors
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures();
      
        sleep(750);//wait for conversion in sleep mode
      
        // Read temperatures and send them to controller
        for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) {
      
          // Fetch and round temperature to one decimal
          float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.;
      
          // Only send data if temperature has changed and no error
          send(msg.setSensor(i).set(temperature, 1));
            lastTemperature[i] = temperature;
          //if (lastTemperature[i] != temperature && temperature != -127.00) {
      
            // Send in the new temperature
            
          //}
        }
       
        sleep(SLEEP_TIME);//wake on interrupt or after sleep-time
      }
      

      And the error given by the Arduino IDE :

      In file included from /home/carmelo/Arduino/tmp/tmp_tempbattv2/tmp_tempbattv2.ino:28:0:
      /home/carmelo/Arduino/libraries/MySensors/MySensors.h:332:2: error: #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
       #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
        ^
      exit status 1
      Erreur de compilation pour la carte Arduino Pro or Pro Mini
      
      posted in Troubleshooting
      carleki
      carleki
    • RE: 4 doors sensors and 4 move sensors on the same node

      @gloob

      ok ! I will check the wires and signal output from the movement sensors 😉

      posted in My Project
      carleki
      carleki
    • RE: 4 doors sensors and 4 move sensors on the same node

      @gloob said:

      What type of sensors are they? Do they act like simple "switches" or what kind of signal do they offer on the output?

      For the door, I assume they are like reed switch (with magnet fixed on the door itself)
      For the movement ... I don't know !

      posted in My Project
      carleki
      carleki
    • 4 doors sensors and 4 move sensors on the same node

      Hello,
      In my house, I have an old alarm system installed, with :

      • 4 doors sensors
      • 4 move sensors

      All the sensors are wired, and all the cables are going un a closet, where the old alarm system is installed.

      I don't want to use the old alarm because it is broken, but I want to reuse the sensors. I have electric power in the closet, so it will not be a batteries powered node, so is my idea realisable :

      • Arduino powered by USB, with at least 8 inputs (arduino uno ?)
      • I connect 1 cable of each sensor on each input
      • the other cables from the sensors connected to ground of the arduino

      is it correct ?

      posted in My Project
      carleki
      carleki
    • RE: Battery Operated Door Magnet Sensor

      Thanks a lot for your answer 🙂

      I must be an idiot but ... I can't compile your sketch ... Which version of MySensors lib are you using ? (I'm with 1.5.4)

      posted in My Project
      carleki
      carleki
    • 1.5.4 and 2.0 on the same computer

      Hello,
      Is it possible to have 1.5.4 and 2.0 MySensors on the same computer ?

      posted in Development
      carleki
      carleki
    • RE: Battery Operated Door Magnet Sensor

      @sghazagh said:

      @m26872 Thank you very much mate.
      I just added the battery reporting part and it works like a charm.

      Many many thanks...
      Did you add 1MOhm resistor between the Input pin and the reed switch ?

      posted in My Project
      carleki
      carleki
    • RE: debug battery powered node

      @gloob said:

      Correct.

      thanks 😉

      posted in Troubleshooting
      carleki
      carleki
    • RE: debug battery powered node

      I didn't know it was possible !

      So : Vcc and GND from the battery, and TX, RX and GND to my usb serial adapter ?

      posted in Troubleshooting
      carleki
      carleki
    • debug battery powered node

      Hello !

      I have sometimes tempertures nodes, powered by batteries, which are freezing ... If I reboot the node, all is working correctly ...

      How can I debug it ? If I connect the node to my computer, it will change the power input, so if it's a power related issue, I will not see it ...

      Do you have any idea ?

      Thanks !

      posted in Troubleshooting
      carleki
      carleki
    • RE: coin-cell (CR2032) powered temperature sensor

      @fleinze said:

      @carmelo42 sorry I somehow missed your post. I use the standard-bootloader as I did not get Optiboot to run on the 3.3V/8MHz pro minis. I set the extended fuse to 0x07 (BOD disabled) by editing boards.txt.
      thanks !

      is is a bit confusing for me :

      • we can burn the bootloader from the Arduino IDE : are the fuses written at this moment ?
      • we can upload a sketch with the arduino IDE : are the fuses written at this moment ?
      • with my researches, I found that for disabling BOD was possible with 0xFF value for efuse ?

      I have some lifetime issues with my CR2032 sensor .. and I suspect the fuses are not correctly set ...

      If you can light up my mind it will be perfect 🙂

      posted in My Project
      carleki
      carleki
    • RE: coin-cell (CR2032) powered temperature sensor

      @fleinze said:

      @carmelo42

      The no-resistor-library can be found here:
      https://wp.josh.com/2014/06/23/no-external-pull-up-needed-for-ds18b20-temp-sensor/

      The resistors (there are two but the other one is barely visible) are for voltage-measurement. In a later version I got rid of them using this resistor-less method of measurement:
      http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/

      great 🙂

      Did you change the bootloader ? Which one did you use ?

      posted in My Project
      carleki
      carleki
    • RE: coin-cell (CR2032) powered temperature sensor

      @fleinze said:

      @carmelo42 I just changed coin-cell on one of my sensors. It lasted since for 10 months, this is ok for me.

      10 months ? it's perfect 🙂

      Can you provide the modified version of the library to avoid using 4.7k resistor for the Dallas sensor ?

      What is for the resistor on the pic ? for the voltage mesurement ?

      posted in My Project
      carleki
      carleki
    • RE: coin-cell (CR2032) powered temperature sensor

      what about your nodes after several months ?

      posted in My Project
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      @siod said:

      @carmelo42 no, unfortunately I don´t have any logs, any idea how to create logs?

      maybe if you keep your node connected to your computer with USB to serial adapter ?

      posted in My Project
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      @siod my temperature nodes work good, but my relay one doesn't work 😢

      Do you have any logs when it freezes ?

      posted in My Project
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      @carmelo42 said:

      @jeti said:

      @carmelo42 yes

      I have this serial/usb adapter :
      https://img1.picload.org/image/ldrrddg/deekrobot-isp.png

      Can you tell me how I connect it to my node ? (noob question I guess ... but I don't want to burn my node 😞 )

      I have found the answer myself with the schematic 😉

      Have you ever tried to power the node with 1 x CR2032 battery ?

      I have tried, but the node doesn't send anything further than 5 meters ...

      posted in My Project
      carleki
      carleki
    • RE: need help with node not sending info

      I have added the C5 capacitor (on the "My Slim 2AA node"), and replaced the nrf24 from my GW with a NRF24L01+PA+LNA.

      It's way better 🙂

      So far, no problem .. I will keep you updated in the following days

      Anyway, thanks for your help 💃

      posted in Troubleshooting
      carleki
      carleki
    • RE: need help with node not sending info

      yes, I have tried 15 meters away : same problem

      posted in Troubleshooting
      carleki
      carleki
    • RE: need help with node not sending info

      I have cleaned the eeprom last night after your advice, and the node is currently at 50 centimeters from the GW. (I have also changed the power source for the node : I was using 1 x CR2032 battery, but last night I have used 2 brand new AA batteries)

      On my Slim AA Node, I have not the C5 cap, I will add it ...

      Can it be a bootoloader issue ? (I'm using my Atmega at 8 Mhz)

      posted in Troubleshooting
      carleki
      carleki
    • RE: need help with node not sending info

      @sundberg84 thanks 🙂

      All my nodes (and GW, pretty sure) have already decoupling capacitors ...

      I'm using "standard" temperature sketch :

        /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
       * http://www.mysensors.org/build/temp
       */
      
      #include <MySensor.h>  
      #include <SPI.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      #include <Vcc.h>
      
      #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
      #define ID_BatPcnt 1
      #define ID_Bat 2
      int node_id = 93; // on donne un ID au node
      
      const float VccMin   = 1.6;             // Vcc mini attendu, en Volts.
      const float VccMax   = 3.06;           // Vcc Maximum attendu, en Volts (2 piles AA neuves)
      const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2
      Vcc vcc(VccCorrection);
      
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      unsigned long SLEEP_TIME = 15000; // Sleep time between reads (in milliseconds)900000 15 minutes - 600000 10 minutes
      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
      MySensor gw;
      MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles
      MyMessage msgBAT(ID_Bat,V_VAR2);          // on utilise le type V_VAR2 pour la tension des piles
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      boolean receivedConfig = false;
      boolean metric = true; 
      // Initialize temperature message
      MyMessage msg(0,V_TEMP);
      
      void setup()  
      { 
        // Startup up the OneWire library
        sensors.begin();
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      
        // Startup and initialize MySensors library. Set callback for incoming messages. 
        gw.begin(NULL, node_id, true);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Temp Sens Bat", "1.3");
      
        // Fetch the number of attached temperature sensors  
        numSensors = sensors.getDeviceCount();
      
        // Present all sensors to controller
        gw.present(ID_BatPcnt, S_CUSTOM);  // type S_CUSTOM pour le capteur "% de charge"
        gw.present(ID_Bat, S_CUSTOM);      // type S_CUSTOM pour le capteur "tension"
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
           gw.present(i, S_TEMP);
        }
      }
      
      
      void loop()     
      {     
        // Process incoming messages (like config from server)
        gw.process(); 
      // mesure de Vcc
            float v = vcc.Read_Volts();
            // calcul du % de charge batterie
            float p = 100 * ((v - VccMin) / (VccMax - VccMin));
            // On envoie les données des capteurs et de l'état de la batterie au Gateway
            //gw.sendBatteryLevel(p);  // Inutile...
            gw.send(msgBAT_PCNT.set(p, 1)); // 1 décimale
            gw.send(msgBAT.set(v, 3));      // 2 décimales
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures();
      
        // query conversion time and sleep until conversion completed
        int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
        // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
        gw.sleep(conversionTime);
      
        // Read temperatures and send them to controller 
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
       
          // Fetch and round temperature to one decimal
          float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
       
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
       
            // Send in the new temperature
            gw.send(msg.setSensor(i).set(temperature,1));
            // Save new temperatures for next compare
            lastTemperature[i]=temperature;
          }
        }
        gw.sleep(SLEEP_TIME);
      }
      
      
      posted in Troubleshooting
      carleki
      carleki
    • need help with node not sending info

      Hello,
      I have just make my "2AA slim node" and in the serial monitor here is what I obtain :

      send: 90-90-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=fail:0
      send: 90-90-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=fail:1.5.4
      send: 90-90-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
      repeater started, id=90, parent=0, distance=1
      send: 90-90-0-0 s=255,c=3,t=11,pt=0,l=13,sg=0,st=fail:Temp Sens Bat
      send: 90-90-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.3
      send: 90-90-0-0 s=1,c=0,t=23,pt=0,l=0,sg=0,st=fail:
      send: 90-90-0-0 s=2,c=0,t=23,pt=0,l=0,sg=0,st=fail:
      send: 90-90-0-0 s=0,c=0,t=6,pt=0,l=0,sg=0,st=ok:
      send: 90-90-0-0 s=1,c=1,t=24,pt=7,l=5,sg=0,st=fail:230.0
      send: 90-90-0-0 s=2,c=1,t=25,pt=7,l=5,sg=0,st=fail:4.958
      send: 90-90-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.1
      
      

      Can someone help me ?
      Thanks 🙂

      posted in Troubleshooting
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      @jeti said:

      @carmelo42 yes

      I have this serial/usb adapter :
      https://img1.picload.org/image/ldrrddg/deekrobot-isp.png

      Can you tell me how I connect it to my node ? (noob question I guess ... but I don't want to burn my node 😞 )

      posted in My Project
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      @m26872 is it possible to send the sketch in the atmega on board ? using an FTDI serial/usb ?

      posted in My Project
      carleki
      carleki
    • RE: mysensors relay stops working after few hours

      I'm using these relay : https://www.mysensors.org/build/relay

      I think there is already protection from the coil voltage spikes.

      posted in Troubleshooting
      carleki
      carleki
    • RE: 💬 My Slim 2AA Battery Node

      thanks @m26872 🙂

      I have ordered smd capacitors for c5 ... but I think it will be good 🙂

      Can you explain the role of the C5 cap ? I know that C4 is for decoupling for the radio, but C1, C2, C3 and C4 : I don't know !

      Another little question 🙂
      with my brand new atmega328p, I have burned the bootloader with an arduino uno with the "ArduinoISP" in it.

      After that, I have sent the sketch with another arduino (with it's own atmega removed) and my brand new atmega like that :
      https://www.arduino.cc/en/uploads/Tutorial/ArduinoUSBSerialSimple.png

      Is it possible to put the sketch in the atmega directly on the slim2aabatterynode board ? With an FTDI serial device ?

      posted in OpenHardware.io
      carleki
      carleki
    • RE: mysensors relay stops working after few hours

      @Nuubi said:

      These are most often related to noise of the power supply or other transient noise/spikes in the circuit (due to a relay for example).

      To be more specific, I'd first remove the relay from the circuit and just use a led instead. If the node works then without problems for longer time, the reason indicates it's a noise issue from the relay section.

      Similar examples can be found, e.g. http://forum.arduino.cc/index.php?topic=186879.15

      Generally these are solved by separating the power supplies, or 'de-coupling'. A good read illustrating the situation, please read it through: http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

      I have bunch of nodes that are troublesome. So fat it's been due to noisy somewhere in the circuit. Also, noticed that some nodes start to malfunction after few years due to low quality capacitors. And that is painful to cure...

      thanks 🙂

      I understand better 🙂

      So, if I understand the right way, I have to put a decoupling capacitor because of the noise produced by the power supply and another decoupling capacitor because of the noise produced by the relay.

      I have already a 47µF cap on the VCC and GND pins of my NRF24.
      Should I put another 47µF beetween the VCC and GND of my relay ?

      I think it's noob question ... may be it'll be nice to put these infos in the relay page of mysensors website ?

      posted in Troubleshooting
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      @jeti said:

      ups... C5 is also not there on my board,it shoud be parallel to C4!

      is your sensor working without C5 ?

      posted in My Project
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      I have received yesterday my little packet from DirtyPCB 🙂
      11 PCBs, so 33 sensors 🙂

      I'm just wondering where the C5 capactior will go on the board .. Can't figure out 😞

      posted in My Project
      carleki
      carleki
    • RE: 💬 My Slim 2AA Battery Node

      Hello 🙂
      In the BOM file there is C5 capacitor, but I can't figure out where it does stand on the board. Can you help please ?

      posted in OpenHardware.io
      carleki
      carleki
    • RE: Soldering tips for atmega328p-au?

      @Yveaux said:

      @carmelo42 Using foto-sensitive pcb material, UV light and printing your design on transparent slides it should also be possible.
      I no longer bother creating PCB's myself, as I can order them very cheap from China, with silkscreen, solder mask and far better quality...

      ok ! I have ordered PCBs from dirtypcb.com (the files for "my-slim-2aa-battery-node"), but I'm not advanced enough to design PCBs with siklscreen and solder mask (yet ^^)

      posted in Hardware
      carleki
      carleki
    • RE: Soldering tips for atmega328p-au?

      With a USB microscope and tiny solder iron, it's ok to solder atmega328p-au !

      Is it possible to do DIY PCB for SMD atmega ?
      I'm doing my PCBs with toner transfer + acetone at the moment. It works great for DIP atmega, but I can't do SMD version because the ways are to tiny ...

      Any idea ?

      posted in Hardware
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      @m26872 said:

      @carmelo42
      Thanks for your support by ordering. I actually recieved another 50+ share credit transfer from DirtyPCBs today. It'll be donated to MySensors right away.

      If you look at post 116 you'll see the I used a 10Mohm pull-up between Vcc and atmega input pin. Reed switch connects between Gnd and input pin.

      Thanks to you for providing us theses files 🙂

      Ok, my mistake (I juste received my 10 MOhm resistor 😉
      Perfect, I just have to wait now for the little yellow packet 😉

      posted in My Project
      carleki
      carleki
    • RE: mysensors relay stops working after few hours

      @Nuubi said:

      "Classic" way to rule out the power source + relay related issues is to replace the relay with a led.
      Noise in power lines may stop the NRF module, but also Arduino can get messed up due to spikes in power supply.

      I did'nt see your answer ...
      What can I do to avoid this ? Put the relay away from the NRF & atmega ?

      posted in Troubleshooting
      carleki
      carleki
    • RE: My Slim 2AA Battery Node

      I have ordered the 2.0 boards, they are on their way to my home 🙂

      I'm plannign to use them as :

      • temperature node
      • door sensor

      For the door sensor, can you tell me if I'm good :
      I have to use a 1MOhm resistor between the pin of atmega and one wire of the reed switch ? So I will have the longest battery life (my atmegas are burned at 1 Mhz or 8 Mhz)

      Am I right ?

      posted in My Project
      carleki
      carleki
    • RE: 💬 Connecting the Radio

      thanks @arraWX 🙂

      posted in Announcements
      carleki
      carleki
    • RE: 💬 Connecting the Radio

      "try adding a decoupling capacitor of 4.7µ - 47µF (the exact size usually doesn't matter)"

      I can use 4.7µ or 47µ only ? or a size between 4.7 and 47 ?

      posted in Announcements
      carleki
      carleki
    • RE: Coin cell based small sensor node / handsoldering smd parts

      very cool 🙂

      Will you provie PCB at dirtypcb.com ?
      As soon as you do it I order PCB 🙂

      posted in Hardware
      carleki
      carleki
    • RE: 💬 Building a Serial Gateway

      I have 2 gateways : one with 1.5.4 and one with 2.0 :
      I have tested with 2 temp nodes : one with 1.5.4 version and one with 2.0 : the 2 gateways can see the 2 nodes !

      posted in Announcements
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      I finally have found the problem : I had only Vcc.h in my VCC folder ... So the .cpp file was misisng !!

      --> noob alert 🙂

      posted in Development
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      ok ....

      it is not the 1st time I have problems with lib MYS lib install ... I have done this :

      on a fresh linux install, DL the Arduino IDE 1.6.5, in the IDE menu, DL the MYS libraries and DallasSensors Temp lib ...

      Is this the wrong way ?

      posted in Development
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      I have installed lib 2.0 on my linux virtual machine. When I try to compile temperature node with battery monitoring here is what I got :

      
      
      /tmp/ccQR5mwk.ltrans1.ltrans.o: In function `loop':
      ccQR5mwk.ltrans1.o:(.text+0x6d4): undefined reference to `Vcc::Read_Volts()'
      /tmp/ccQR5mwk.ltrans2.ltrans.o: In function `global constructors keyed to 65535_0_tempbatv2.ino.cpp.o.2373':
      ccQR5mwk.ltrans2.o:(.text.startup+0x98): undefined reference to `Vcc::Vcc(float)'
      collect2: error: ld returned 1 exit status
      exit status 1
      Error compiling for board Arduino Pro or Pro Mini.
      

      My sketch :

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
       * http://www.mysensors.org/build/temp
       */
      
      
      // Enable debug prints to serial monitor
      //#define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      #include <SPI.h>
      #include <MySensors.h>  
      #include <DallasTemperature.h>
      #include <OneWire.h>
      #include <Vcc.h>
      
      #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
      #define ID_BatPcnt 1
      #define ID_Bat 2
      
      //const float VccMin   = 1.6;             // Vcc mini attendu, en Volts.
      //const float VccMax   = 3.06;           // Vcc Maximum attendu, en Volts (2 piles AA neuves)
      //const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2
      //Vcc vcc(VccCorrection);
      
      static const float VccMin = 1.6;        // Minimum expected Vcc level, in Volts. (0.6V for 1 AA Alkaline)
      static const float VccMax = 3.3;        // Maximum expected Vcc level, in Volts. (1.5V for 1 AA Alkaline)
      static const float VccCorrection = 2.52 / 2.6;  // Measured Vcc by multimeter divided by reported Vcc
      Vcc vcc(VccCorrection);
      
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      unsigned long SLEEP_TIME = 900000; // Sleep time between reads (in milliseconds)
      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      bool receivedConfig = false;
      bool metric = true;
      MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles
      MyMessage msgBAT(ID_Bat,V_VAR2);          // on utilise le type V_VAR2 pour la tension des piles
      // Initialize temperature message
      MyMessage msg(0,V_TEMP);
      
      void before()
      {
        // Startup up the OneWire library
        sensors.begin();
      }
      
      void setup()  
      { 
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Temperature Sensor", "1.1");
      
        // Fetch the number of attached temperature sensors  
        numSensors = sensors.getDeviceCount();
      
        // Present all sensors to controller
        present(ID_BatPcnt, S_CUSTOM);  // type S_CUSTOM pour le capteur "% de charge"
        present(ID_Bat, S_CUSTOM);      // type S_CUSTOM pour le capteur "tension"
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
           present(i, S_TEMP);
        }
      }
      
      void loop()     
      {     
        // mesure de Vcc
            float v = vcc.Read_Volts();
            // calcul du % de charge batterie
            float p = 100 * ((v - VccMin) / (VccMax - VccMin));
            // On envoie les données des capteurs et de l'état de la batterie au Gateway
            //gw.sendBatteryLevel(p);  // Inutile...
            send(msgBAT_PCNT.set(p, 1)); // 1 décimale
            send(msgBAT.set(v, 3));      // 2 décimales
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures();
      
        // query conversion time and sleep until conversion completed
        int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
        
        // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
        sleep(conversionTime);
      
        // Read temperatures and send them to controller 
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
       
          // Fetch and round temperature to one decimal
          float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
       
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
       
            // Send in the new temperature
            send(msg.setSensor(i).set(temperature,1));
            // Save new temperatures for next compare
            lastTemperature[i]=temperature;
          }
        }
        sleep(SLEEP_TIME);
      }
      

      I understand there is a problem with Vcc and vcc float ... but ...

      posted in Development
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      @scalz do you know if it's possible to have 1.5.4 and 2.0 in my Arduino IDE ?

      posted in Development
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      Ok !

      I will update all my sensors + gw to 2.0 and test it with my sensors (as long as the outside temperatures won't go below 15°C all day I don't need to have my boiler functionnal so I can do some tests 🙂

      If it's ok I stay with 2.0, if not I can go back to 1.5.4 😉

      I'm using just temperature nodes, relay actuator nodes and distance nodes : so all the code is available on mysensors website with 2.0 😉

      posted in Development
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      I will try the v2.0 !
      Juste flash my gateway with the new sketch ?
      Can v1.5.4 nodes and v2.0 nodes work with 2.0 gateway ?

      May be it's quite simply to upgrade to v2.0 and my freeze problems will be solved ...

      posted in Development
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      @hek said:

      Then you have to calculate the number of sleepcycles * sleep time to get the passed time.

      In the links provided by @scalz, the max time for the watchdog is 8 seconds, and my node is asleep for 15 minutes !

      posted in Development
      carleki
      carleki
    • RE: How to auto reboot node every 24 hours ?

      @scalz said:

      Hello.

      you have to use a watchdog timer for this. You can use the internal wdt of you mini pro etc.. or use an external hardware wdt.
      https://forum.mysensors.org/topic/4760/watchdog-on-2-0/17
      https://tushev.org/articles/arduino/5/arduino-and-watchdog-timer

      merci scalz 😉

      but if my node (temperature or door) goes to sleep : the watchdog will not be reseted and it will restart ?

      posted in Development
      carleki
      carleki
    • How to auto reboot node every 24 hours ?

      hi !

      is it possible to program a node restart every 24 hours ?

      I have lots of nodes around my house, and sometimes one of them stops sending information ... After a restart it's ok, so I want to automatically restart my sensors to avoid manualy doing it.

      is it possible ?

      thanks !

      posted in Development
      carleki
      carleki
    • RE: distance + relay node

      @carmelo24 it's ok now 🙂

      here is my sketch :

      // Sketch pour commander un relai en mode impultionnel. 
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <NewPing.h>
      
      #define node_id 66
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      #define CHILD_ID 1
      #define TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
      #define ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.
      #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
      unsigned long SLEEP_TIME = 500; // Sleep time between reads (in milliseconds)
      MySensor gw;
      NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
      MyMessage msg(CHILD_ID, V_DISTANCE);
      boolean metric = true; 
      long temps;
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, node_id, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("RelayDistance", "1.1");
      
        // Fetch relay status
          // Register all sensors to gw (they will be created as child devices)
          gw.present(RELAY_1, S_LIGHT);
          gw.present(CHILD_ID, S_DISTANCE);
          boolean metric = gw.getConfig().isMetric;
          // Then set relay pins in output mode
          pinMode(RELAY_1, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(RELAY_1, RELAY_OFF);
          temps = millis();
      
      }
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      
       
      // mesure de la distance si ça fait plus de 10 secondes qu'on ne l'a pas fait
       if((millis() - temps) > 10000) {
             int dist = metric?sonar.ping_cm():sonar.ping_in();
             gw.send(msg.set(dist));
             Serial.print(dist);
             Serial.print("toto");
                
       
       temps = millis();
       
        }
      }
      
      
      void incomingMessage(const MyMessage &message) {
      // action du relais (avec impulsion, pour action comme un bouton poussoir)
        if (message.type==V_LIGHT) {
           // Change relay state
          digitalWrite(RELAY_1, RELAY_ON);
          delay(100);  
          digitalWrite(RELAY_1, RELAY_OFF);
           delay(100); 
          
          
         } 
      }
      
      
      posted in Development
      carleki
      carleki
    • RE: distance + relay node

      So this is my sketch right now. The relay works ok, but I have only 0cm or 1cm with for the distance (and I can hear a sound coming from the distance sensor ...) :

      // Sketch pour commander un relai en mode impultionnel. 
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <NewPing.h>
      
      #define node_id 66
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      #define CHILD_ID 1
      #define TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
      #define ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.
      #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
      unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
      MySensor gw;
      NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
      MyMessage msg(CHILD_ID, V_DISTANCE);
      //int lastDist;
      boolean metric = true; 
      
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, node_id, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("RelayDistance", "1.1");
      
        // Fetch relay status
          // Register all sensors to gw (they will be created as child devices)
          gw.present(RELAY_1, S_LIGHT);
          gw.present(CHILD_ID, S_DISTANCE);
          boolean metric = gw.getConfig().isMetric;
          // Then set relay pins in output mode
          pinMode(RELAY_1, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(RELAY_1, RELAY_OFF);
      
      }
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      
          int dist = metric?sonar.ping_cm():sonar.ping_in();
        Serial.print("Ping: ");
        Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
        Serial.println(metric?" cm":" in");
      
       // if (dist != lastDist) {
         //   gw.send(msg.set(dist));
          //  lastDist = dist;
      //  }
        
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
          digitalWrite(RELAY_1, RELAY_ON);
          delay(100);  
          digitalWrite(RELAY_1, RELAY_OFF);
           delay(100); 
          digitalWrite(RELAY_1, RELAY_ON);
          delay(100);  
          digitalWrite(RELAY_1, RELAY_OFF);
           delay(100); 
          digitalWrite(RELAY_1, RELAY_ON);
          delay(100);  
          digitalWrite(RELAY_1, RELAY_OFF);
           delay(100); 
          digitalWrite(RELAY_1, RELAY_ON);
          delay(100);  
          digitalWrite(RELAY_1, RELAY_OFF);
          
         } 
      }
      
      
      posted in Development
      carleki
      carleki
    • RE: distance + relay node

      @mfalkvidd said:

      Could you share any details on "it doesn't work"?

      The distance stays at 0 cm on my controller, and the relay actuator isn't triggered when I click it on my controller (I use my sensors with Jeedom)

      posted in Development
      carleki
      carleki
    • distance + relay node

      Hello, I'm trying to aggregate 2 sketches : distance and relay actuator node ...

      But I think I'm going the wrong way because it doesn't work ...

      Here is my code :

      // Sketch pour commander un relai en mode impultionnel. 
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <NewPing.h>
      // relais
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      int node_id = 9;
      
      // distance
      #define CHILD_ID 1
      #define TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
      #define ECHO_PIN     5  // Arduino pin tied to echo pin on the ultrasonic sensor.
      #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
      unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
      
      MySensor gw;
      NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
      MyMessage msg(CHILD_ID, V_DISTANCE);
      int lastDist;
      boolean metric = true; 
      
      void setup()  
      {   
        // Initialize library and add callback for incoming messages
        //gw.begin(incomingMessage, AUTO, true);
        gw.begin(NULL, node_id);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("RelaisPulDist", "1.1");
      
        // Fetch relay status
          // Register all sensors to gw (they will be created as child devices)
          gw.present(RELAY_1, S_LIGHT);
      
          gw.present(CHILD_ID, S_DISTANCE);
          boolean metric = gw.getConfig().isMetric;
          
          // Then set relay pins in output mode
          pinMode(RELAY_1, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(RELAY_1, RELAY_OFF);
      
      }
      
      void loop() 
      {
        // Alway process incoming messages whenever possible
        gw.process();
      
         int dist = metric?sonar.ping_cm():sonar.ping_in();
        Serial.print("Ping: ");
        Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
        Serial.println(metric?" cm":" in");
      
        if (dist != lastDist) {
            send(msg.set(dist));
            lastDist = dist;
        }
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
           // Change relay state
          digitalWrite(RELAY_1, RELAY_ON);
          delay(500);  
          digitalWrite(RELAY_1, RELAY_OFF);
         } 
      
        }
      
         
      }
      
      
      

      Can you see what's going wrong ?
      thanls !

      posted in Development
      carleki
      carleki
    • RE: 💬 Small MySensor

      Hi, great project !

      Can you detail how you burn the bootloader and the sketch into the atmega ? (I mean, how do you wire the pinout to upload bootloader and sketch)
      Thanks !!

      posted in OpenHardware.io
      carleki
      carleki
    • mysensors relay stops working after few hours

      Hello,

      I have a serial gateway, 2 mySensors temperature nodes, and 1 relay mySensors node.

      The 2 temperature nodes work good, but the relay one stops worling after a few hours .. I have to turn it off and on again and it works again for a few hours ...

      (I use mysensors with jeedom).

      I have think the problem could be material, I have built another relay board, with another arduino (duemilanove original) and a new NRF ... but same again ...

      Do you have some idea ?

      Thanks 🙂

      Carmelo

      posted in Troubleshooting
      carleki
      carleki