Navigation

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

    Best posts made by carlierd

    • Office plan monitor (advice required)

      Hello,

      Thanks to @mfalkvidd I implement my first plant monitor. As it's working perfectly I decided to create a specific design base on the following post.

      The schematic :
      0_1461932293283_2016-04-29 11.10.08.png

      The board (route by eagles):
      0_1461932385715_2016-04-29 10.18.30.png

      I tried to make the smaller board possible.

      Any comment / advice is really recommended ๐Ÿ™‚

      David

      posted in My Project
      carlierd
      carlierd
    • RE: Office plant monitoring

      Hello,

      After several weeks I finally succeed to create a dedicated PCB ! It was started yesterday evening and works fine.

      Some pictures:
      0_1469782265724_Photo 1.jpg
      0_1469782279459_Photo 2.jpg
      0_1469782286758_Photo 3.jpg

      Measure is reported each two hours. So I expect more than two years on a CR2032 (using @GertSanders firmware).

      I can off course provide any information as PCB.

      Thanks @mfalkvidd for the idea and the code. The project is now WAF ๐Ÿ˜‰

      David.

      posted in My Project
      carlierd
      carlierd
    • RE: Slim Node scene controller/ keypad

      Hello,

      Some pictures of my scene controller inspired by this post ! I modified the original sketch to have two functions: keyboard for my alarm (from key 1 to 9) and scene controller (from key 10 to 16). Thanks @awi for the idea and the original sketch !

      0_1471010520501_Scene controller 1.png

      0_1471010530511_Scene controller 2.png

      0_1471010539448_Scene controller 3.png

      0_1471010545316_Scene controller 4.png

      David.

      posted in My Project
      carlierd
      carlierd
    • RE: MySensors 1.5.3 Released

      Compilation OK !!

      Thanks !

      posted in Announcements
      carlierd
      carlierd
    • RE: [Solved] Soft signing issue

      So simple as soon as you give me the answer ๐Ÿ˜‰

      Thanks a lot !

      posted in Troubleshooting
      carlierd
      carlierd
    • RE: Please add a guide for how to connect use the RFM69(H)W

      Thanks Hek !! Do you also add procedure for modification of librairie to use RFM69 ? I understood that something needs to be done ?

      posted in Feature Requests
      carlierd
      carlierd
    • RE: [Solved] How to check RFM69 is a HW model ?

      Autoreply !

      So I check the web and found interesting conversation from Lowpowerlab.

      It seems there is no software way to check the model (there is a version registry but as I don't have RFM69H to check if there is a difference it's difficult to conclude).
      But according to the Lowpowerlab thread both models looks really different!

      RFM69H:
      RFM69W-500x500.jpg

      RFM69HW:
      RFM69HW-500x500.jpg

      There is no doubt ๐Ÿ˜‰

      posted in Hardware
      carlierd
      carlierd
    • RE: Slim Node Si7021 sensor example

      @ar91 Please find the code I used in 3 different nodes. The good thing with the playground lib is that there is error message if dialog with DHT22 failed.

      /**
       * 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.
       *
       */
      
      /**************************************************************************************/
      /* Temperature, humidity and luminosity measurements.                                 */
      /*                                                                                    */
      /* Version     : 1.1.6                                                                */
      /* Date        : 10/01/2016                                                           */
      /* Modified by : David Carlier                                                        */
      /**************************************************************************************/
      /*                                ---------------                                     */
      /*                            RST |             |  A5                                 */
      /*                            RX  |             |  A4                                 */
      /*                            TX  |   ARDUINO   |  A3                                 */
      /*     RFM69 (DIO0) --------- D2  |     UNO     |  A2                                 */
      /*            DHT22 --------- D3  |             |  A1                                 */
      /*            Power --------- D4  | ATMEGA 328p |  A0 --------- Light dep. resistor   */
      /*              +3v --------- VCC |             | GND --------- GND                   */
      /*              GND --------- GND |  8MHz int.  | REF                                 */
      /*                            OSC |             | VCC --------- +3v                   */
      /*                            OSC |             | D13 --------- RFM69 (SCK)           */
      /*                            D5  |             | D12 --------- RFM69 (MISO)          */
      /*                            D6  |             | D11 --------- RFM69 (MOSI)          */
      /*                            D7  |             | D10 --------- RFM69 (NSS)           */
      /*                            D8  |             |  D9                                 */
      /*                                ---------------                                     */
      /*                                                                                    */
      /* Power = Vcc for LDR.                                                               */
      /* +3v = 2*AA                                                                         */
      /*                                                                                    */
      /**************************************************************************************/
      
      #include <SPI.h>
      #include <MySensor.h>
      #include <dht.h>
      #include <MyTransportRFM69.h>
      #include <MySigningAtsha204Soft.h>
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_LIGHT 2
      #define CHILD_ID_VOLTAGE 3
      #define LIGHT_SENSOR_ANALOG_PIN 0
      #define HUMIDITY_SENSOR_DIGITAL_PIN 3
      #define POWER_PIN 4
      //unsigned long SLEEP_TIME = 850000; // Sleep time between reads (in milliseconds) (close to 15')
      unsigned long SLEEP_TIME = 275000; // Sleep time between reads (in milliseconds) (close to 5')
      
      //Construct MySensors library
      MySigningAtsha204Soft signer;
      MyHwATMega328 hw;
      MyTransportRFM69 transport;
      MySensor gw(transport, hw, signer);
      dht DHT;
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgLum(CHILD_ID_LIGHT, V_LEVEL);
      MyMessage msgVolt(CHILD_ID_VOLTAGE, V_VOLTAGE);
      
      /**************************************************************************************/
      /* Initialization                                                                     */
      /**************************************************************************************/
      void setup()
        {
        //Get time (for setup duration)
        #ifdef DEBUG
          unsigned long startTime = millis();
        #endif
      
        //Start MySensors
        gw.begin();
      
        //Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("GHAS sensor", "1.1.5");
      
        //Register all sensors to gw (they will be created as child devices)
        gw.present(CHILD_ID_HUM, S_HUM);
        gw.present(CHILD_ID_TEMP, S_TEMP);
        gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
        gw.present(CHILD_ID_VOLTAGE, S_MULTIMETER);
      
        //Delay for DHT22
        delay(1500);
      
        //Print setup debug
        #ifdef DEBUG
          int duration = millis() - startTime;
          Serial.print("[Setup duration: "); Serial.print(duration, DEC); Serial.println(" ms]");
        #endif
        }
      
      /**************************************************************************************/
      /* Main loop                                                                          */
      /**************************************************************************************/
      void loop()
        {
        //Get time (for a complete loop)
        #ifdef DEBUG
          unsigned long startTime = millis();
        #endif
      
        //Power on
        powerOnPeripherals();
      
        //Get DHT22 data
        int dht22Result = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN);
        switch (dht22Result)
          {
          case DHTLIB_OK:  
                      //Serial.println("OK,\t");
                      break;
          case DHTLIB_ERROR_CHECKSUM:
                      #ifdef DEBUG
                        Serial.println("Checksum error,\t");
                      #endif
                      break;
          case DHTLIB_ERROR_TIMEOUT:
                      #ifdef DEBUG
                        Serial.println("Time out error,\t");
                      #endif
                      break;
          case DHTLIB_ERROR_CONNECT:
                      #ifdef DEBUG
                        Serial.println("Connect error,\t");
                      #endif
                      break;
          case DHTLIB_ERROR_ACK_L:
                      #ifdef DEBUG
                        Serial.println("Ack Low error,\t");
                      #endif
                      break;
          case DHTLIB_ERROR_ACK_H:
                      #ifdef DEBUG
                        Serial.println("Ack High error,\t");
                      #endif
                      break;
          default:
                      #ifdef DEBUG
                        Serial.println("Unknown error,\t");
                      #endif
                      break;
          }
      
        //Get temperature and humidity
        float temperature = 0;
        float humidity = 0;
        if (dht22Result == DHTLIB_OK)
          {
          temperature = DHT.temperature;
          humidity = DHT.humidity;
          }
      
        //Get power before luminosity to use real voltage
        float realVoltage = getVoltage() / 100.0;
        int batteryPcnt = realVoltage * 100 / 3.0;
        if (batteryPcnt > 100) {batteryPcnt = 100;}
        int lux = computeIlluminance(realVoltage);
      
        //Power off
        powerOffPeripherals();
      
        //Send data to gateway
        gw.send(msgHum.set(humidity, 1));
        gw.send(msgTemp.set(temperature, 1));
        gw.send(msgLum.set(lux));
        gw.send(msgVolt.set(realVoltage, 2));
        gw.sendBatteryLevel(batteryPcnt);
      
        //Print debug
        #ifdef DEBUG
          Serial.print(temperature, 1);
          Serial.print(" degC");
          Serial.print("   ");
          Serial.print(humidity, 1);
          Serial.print(" %");
          Serial.print("   ");
          Serial.print(lux);
          Serial.print(" lx");
          Serial.print("   ");
          Serial.print(realVoltage);
          Serial.print(" v");
          int duration = millis() - startTime;
          Serial.print("   ");
          Serial.print("["); Serial.print(duration, DEC); Serial.println(" ms]");
          Serial.flush();
        #endif
      
        //Sleep
        gw.sleep(SLEEP_TIME);
        }
      
      /**************************************************************************************/
      /* Allows to compute illuminance (in LUX) from LIGHT_SENSOR_ANALOG_PIN.               */
      /**************************************************************************************/
      int computeIlluminance(float realVoltage)
        {
        //Get luminosity
        int luminosity = analogRead(LIGHT_SENSOR_ANALOG_PIN);
        //Calculating the voltage in the input of the ADC
        double voltage = realVoltage * ((double)luminosity / 1024.0);
        //Calculating the resistance of the photoresistor in the voltage divider
        double resistance = (10.0 * realVoltage) / voltage - 10.0;
        //Calculating the intensity of light in lux and return it
        int illuminance = 255.84 * pow(resistance, -10/9);
        return illuminance;
        }
      
      /**************************************************************************************/
      /* Allows to get the real Vcc (return value * 100).                                   */
      /**************************************************************************************/
      int getVoltage()
        {
        const long InternalReferenceVoltage = 1056L;
        ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
        delay(50);  // Let mux settle a little to get a more stable A/D conversion
        //Start a conversion  
        ADCSRA |= _BV( ADSC );
        //Wait for it to complete
        while (((ADCSRA & (1<<ADSC)) != 0));
        //Scale the value
        int result = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L;
        return result;
        }
      
      /**************************************************************************************/
      /* Allows to power ON peripherals.                                                    */
      /**************************************************************************************/
      void powerOnPeripherals()
        {
        //Power-up
        pinMode (POWER_PIN, OUTPUT);
        digitalWrite (POWER_PIN, HIGH);
        delay(1);
        }
      
      /**************************************************************************************/
      /* Allows to power OFF peripherals.                                                   */
      /**************************************************************************************/
      void powerOffPeripherals()
        {
        //Power off
        digitalWrite (HUMIDITY_SENSOR_DIGITAL_PIN, LOW);
        digitalWrite (POWER_PIN, LOW);
        pinMode (HUMIDITY_SENSOR_DIGITAL_PIN, INPUT);
        pinMode (POWER_PIN, INPUT);
        }
      

      Hope it helps !

      David.

      posted in My Project
      carlierd
      carlierd
    • RE: Newbie: RFM69 serial gateway

      Arf ! Remove the cable between RFM and SMA connector. Use only RF cables. You can do the job with a cable of 17,3 cm directly connected to the antenna pin of the RFM. It's very good for testing and you can reach more than 100 meters with it.

      David.

      posted in Troubleshooting
      carlierd
      carlierd
    • RE: Ethernet gateway example in DEV branch

      Hello,

      I tried the SOFT SPI from Gieemek (see this post) and it's really better ! I done it with a UNO board on pin 7, 6, 5 and 4 (it seems that pin 13, 12, 11 and 10 are not a good choice with the Ethernet shield).

      So now I can ping the Gateway ๐Ÿ™‚

      But (yes, there is a but), MYSController is not able to connect and there is no specific message on the serial link of the UNO board:

      0;0;3;0;9;Starting...
      IP: 192.1.1.66
      0;0;3;0;9;gateway started, id=0, parent=0, distance=0
      

      The IP address is the good one.
      What can I do ?

      Thanks !

      posted in Development
      carlierd
      carlierd
    • RE: Slim Node scene controller/ keypad

      Hello !

      I was inspired by your post and adapt your code to my needs:

      • Scene controller on key 10, 11, 12, 13, 14, 15 and 16 (7 scenes possible)
      • 4 digit code send as VAR_1 if 4 keys between 1 and 9 have been pushed one after one within 2 seconds

      For fun I added a buzzer and a final song is played in case the code is sent.
      No control of the code in the sensor, it will be done in the controller (Jeedom).

      The code if someone is interested:

      /**
       * 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.
       *
       *
       * Code modified from AWI
       * (http://forum.mysensors.org/topic/3128/slim-node-scene-controller-keypad)
       *
       * Buzzer code from Sparkfun
       * (SparkFun Inventor's Kit / Example sketch 11)
       *
       */
      
      /**************************************************************************************/
      /* Keyboard sensor.                                                                   */
      /*                                                                                    */
      /* Version     : 1.5.10                                                                */
      /* Date        : 17/04/2016                                                           */
      /* Modified by : David Carlier                                                        */
      /**************************************************************************************/
      /*                                ---------------                                     */
      /*                            RST |             |  A5                                 */
      /*                            RX  |             |  A4                                 */
      /*                            TX  |   ARDUINO   |  A3                                 */
      /*     RFM69 (DIO0) --------- D2  |     UNO     |  A2                                 */
      /*     Keyboard SDA --------- D3  |             |  A1                                 */
      /*     Keyboard SCL --------- D4  | ATMEGA 328p |  A0                                 */
      /*              +3v --------- VCC |             | GND --------- GND                   */
      /*              GND --------- GND |  8MHz int.  | REF                                 */
      /*                            OSC |             | VCC --------- +3v                   */
      /*                            OSC |             | D13 --------- RFM69 (SCK)           */
      /*                            D5  |             | D12 --------- RFM69 (MISO)          */
      /*                            D6  |             | D11 --------- RFM69 (MOSI)          */
      /*                            D7  |             | D10 --------- RFM69 (NSS)           */
      /*              LED --------- D8  |             |  D9 --------- Buzzer                */
      /*                                ---------------                                     */
      /*                                                                                    */
      /* +3v = 2*AA                                                                         */
      /*                                                                                    */
      /**************************************************************************************/
      
      #include <SPI.h>
      #include <MySensor.h>
      #include <MyTransportRFM69.h>
      #include <MySigningAtsha204Soft.h>
      
      //Constants for MySensors
      #define SKETCH_NAME           "Keyboard Sensor"
      #define SKETCH_VERSION        "1.5.10"
      #define CHILD_ID_DIGICODE     0
      #define KEYPAD_ID_SCENE       1
      #define CHILD_ID_VOLTAGE      2
      #define SDA_PIN               3
      #define SCL_PIN               4
      #define LED_PIN               8
      #define BUZZER_PIN            9
      #define BUZZ_FREQ_KEY         350
      #define BUZZ_TIME_KEY         100
      #define BUZZ_FREQ_ERROR       75
      #define KEYBOARD_SIZE         16
      #define MAX_SCENE             7
      #define BATTERY_FULL          3143    // 2xAA usually gives 3.143V when full
      #define BATTERY_ZERO          2340    // 2.34V limit for 328p at 8MHz
      
      //Length must equal the total number of notes and spaces
      const byte songLength = 18;
      
      //Notes is an array of text characters corresponding to the notes
      //in your song. A space represents a rest (no tone)
      char notes[] = "cdfda ag cdfdg gf "; // a space represents a rest
      
      //Beats is an array of values for each note and rest.
      //A "1" represents a quarter-note, 2 a half-note, etc.
      //Don't forget that the rests (spaces) need a length as well.
      int beats[] = {1,1,1,1,1,1,4,4,2,1,1,1,1,1,1,4,4,2};
      
      //The tempo is how fast to play the song.
      //To make the song play faster, decrease this value.
      int tempo = 113;
      
      //Misc. variables
      unsigned long WAITING_TIME = 2000; //Waiting time for key pressing
      boolean keyState[KEYBOARD_SIZE];
      
      //Construct MySensors library
      MySigningAtsha204Soft signer;
      MyHwATMega328 hw;
      MyTransportRFM69 transport;
      MySensor node(transport, hw, signer);
      MyMessage msgCode(CHILD_ID_DIGICODE, V_VAR1);
      MyMessage msgSceneOn(KEYPAD_ID_SCENE, V_SCENE_ON);
      MyMessage msgSceneOff(KEYPAD_ID_SCENE, V_SCENE_OFF);
      MyMessage msgVolt(CHILD_ID_VOLTAGE, V_VOLTAGE);
      
      /**************************************************************************************/
      /* Initialization                                                                     */
      /**************************************************************************************/
      void setup()  
        {
        //Get time (for setup duration)
        #ifdef DEBUG
          unsigned long startTime = millis();
        #endif
      
        //Setup buzzer and LED pins
        pinMode(BUZZER_PIN, OUTPUT);
        pinMode(LED_PIN, OUTPUT);
        blinkLedFastly(3);
      
        //Set keyboard pin
        pinMode(SDA_PIN,INPUT);
        pinMode(SCL_PIN, OUTPUT);
        digitalWrite(SCL_PIN, HIGH);
      
        //Start MySensors and send the Sketch Version Information to the Gateway
        node.begin();
        node.sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
      
        //Register all sensors
        node.present(CHILD_ID_DIGICODE, S_CUSTOM);
        node.present(KEYPAD_ID_SCENE, S_SCENE_CONTROLLER);
        node.present(CHILD_ID_VOLTAGE, S_MULTIMETER);
      
        //Load last Scenestates from EEPROM (7 scenestates available)
        for (int i = 0 ; i < MAX_SCENE; i++)
          {              
          keyState[i] = node.loadState(i);
          #ifdef DEBUG
            Serial.print(" "); Serial.print(keyState[i]);
          #endif
          }
      
        //Setup done !
        blinkLedFastly(3);
      
        //Print setup debug
        #ifdef DEBUG
          int duration = millis() - startTime;
          Serial.println("");
          Serial.print("[Setup duration: "); Serial.print(duration, DEC); Serial.println(" ms]");
        #endif
        }
      
      /**************************************************************************************/
      /* Main loop                                                                          */
      /**************************************************************************************/
      void loop()
        {
        //Sleep, node wakes up on key interrupt
        byte interuptionType = node.sleep(SDA_PIN - 2, FALLING);
      
        //Verify if a key was pressed
        if (interuptionType == 0)
          {
          return;
          }
      
        //Get time (for a complete loop)
        #ifdef DEBUG
          unsigned long startTime = millis();
        #endif
      
        //Get first digit
        byte key = getKeyPressed();
        tone(BUZZER_PIN, BUZZ_FREQ_KEY, BUZZ_TIME_KEY);
      
        //Check validity
        if (key == 0)
          {
      
          Serial.print("bah si !");
          Serial.println(interuptionType);
          
          blinkLedFastlyAndBuzz(3);
          return;
          }
      
        //Inform user that key is valid
        blinkLedFastly(1);
        int digicode = key * 1000;
      
        //Check if key corresponds to a scene touch or a code
        if (key > 9)
          {
          //Update scene state
          node.saveState(key - 10, (boolean)node.loadState(key - 10)?false:true);
      
          //Report data to the gateway
          long voltage = getVoltage();
          node.send(node.loadState(key - 10)?msgSceneOn.set(key - 10):msgSceneOff.set(key - 10));
          node.send(msgVolt.set(voltage / 1000.0, 3));
          int batteryPcnt = round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO));
          if (batteryPcnt > 100) {batteryPcnt = 100;}
          node.sendBatteryLevel(batteryPcnt);
      
          //Print debug
          #ifdef DEBUG
            Serial.print("Scene ");
            Serial.print(key - 10);
            Serial.print(": ");
            Serial.print((boolean)node.loadState(key - 10)?" 1 ":" 0 ");
            Serial.print("   ");
            Serial.print(voltage / 1000.0);
            Serial.print(" v");
            int duration = millis() - startTime;
            Serial.print("   ");
            Serial.print("["); Serial.print(duration, DEC); Serial.println(" ms]");
            Serial.flush();
          #endif
          }
        else
          {
          //Wait for next key pressed or WAITING_TIME without action
          interuptionType = node.sleep(SDA_PIN - 2, FALLING, WAITING_TIME);
      
          //Verify if a key was pressed
          if (interuptionType == 0)
            {
            blinkLedFastlyAndBuzz(3);
            return;
            }
      
          //Get second digit
          key = getKeyPressed();
          tone(BUZZER_PIN, BUZZ_FREQ_KEY, BUZZ_TIME_KEY);
      
          //Check validity
          if (key == 0 || key > 9)
            {
            blinkLedFastlyAndBuzz(3);
            node.sleep(1000);
            return;
            }
      
          //Inform user that key is valid
          blinkLedFastly(1);
          digicode = digicode + key * 100;
      
          //Wait for next key pressed or WAITING_TIME without action
          interuptionType = node.sleep(SDA_PIN - 2, FALLING, WAITING_TIME);
      
          //Verify if a key was pressed
          if (interuptionType == 0)
            {
            blinkLedFastlyAndBuzz(3);
            return;
            }
      
          //Get third digit
          key = getKeyPressed();
          tone(BUZZER_PIN, BUZZ_FREQ_KEY, BUZZ_TIME_KEY);
      
          //Check validity
          if (key == 0 || key > 9)
            {
            blinkLedFastlyAndBuzz(3);
            node.sleep(1000);
            return;
            }
      
          //Inform user that key is valid
          blinkLedFastly(1);
          digicode = digicode + key * 10;
      
          //Wait for next key pressed or WAITING_TIME without action
          interuptionType = node.sleep(SDA_PIN - 2, FALLING, WAITING_TIME);
      
          //Verify if a key was pressed
          if (interuptionType == 0)
            {
            blinkLedFastlyAndBuzz(3);
            return;
            }
      
          //Get fourth digit
          key = getKeyPressed();
          tone(BUZZER_PIN, BUZZ_FREQ_KEY, BUZZ_TIME_KEY);
      
          //Check validity
          if (key == 0 || key > 9)
            {
            blinkLedFastlyAndBuzz(3);
            node.sleep(1000);
            return;
            }
      
          //Inform user that key is valid
          blinkLedFastly(1);
          digicode = digicode + key;
      
          //Report data to the gateway
          long voltage = getVoltage();
          node.send(msgCode.set(digicode));
          node.send(msgVolt.set(voltage / 1000.0, 3));
          int batteryPcnt = round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO));
          if (batteryPcnt > 100) {batteryPcnt = 100;}
          node.sendBatteryLevel(batteryPcnt);
      
          //Print debug
          #ifdef DEBUG
            Serial.print("Complete code: ");
            Serial.print(digicode);
            Serial.print("   ");
            Serial.print(voltage / 1000.0);
            Serial.print(" v");
            int duration = millis() - startTime;
            Serial.print("   ");
            Serial.print("["); Serial.print(duration, DEC); Serial.println(" ms]");
            Serial.flush();
          #endif
      
          //Play final song instead of sleeping
          playFinalSong();
          }
      
        //Wait to avoid false interruption
        node.sleep(1000);
        }
      
      /**************************************************************************************/
      /* Allows to play the final song.                                                     */
      /**************************************************************************************/
      void playFinalSong()
        {
        //Declare local variables
        int i, duration;
      
        // step through the song arrays
        for (i = 0; i < songLength; i++)
          {
          // length of note/rest in ms
          duration = beats[i] * tempo;
      
          // is this a rest? 
          if (notes[i] == ' ')
            {
            delay(duration);            // then pause for a moment
            }
          else                          // otherwise, play the note
            {
            tone(BUZZER_PIN, frequency(notes[i]), duration);
            delay(duration);            // wait for tone to finish
            }
          delay(tempo/10);              // brief pause between notes
          }
        }
      
      /**************************************************************************************/
      /* takes a note character (a-g), and returns the corresponding frequency in Hz        */
      /* for the tone() function.                                                           */
      /**************************************************************************************/
      int frequency(char note) 
        {
        //Declare local variables
        int i;
        const int numNotes = 8;  // number of notes we're storing
      
        // The following arrays hold the note characters and their
        // corresponding frequencies. The last "C" note is uppercase
        // to separate it from the first lowercase "c". If you want to
        // add more notes, you'll need to use unique characters.
      
        // For the "char" (character) type, we put single characters
        // in single quotes.
      
        char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
        int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523};
      
        // Now we'll search through the letters in the array, and if
        // we find it, we'll return the frequency for that note.
      
        for (i = 0; i < numNotes; i++)  // Step through the notes
          {
          if (names[i] == note)         // Is this the one?
            {
            return(frequencies[i]);     // Yes! Return the frequency
            }
          }
        return(0);  // We looked through everything and didn't find it,
                    // but we still need to return a value, so return 0.
        }
      
      /**************************************************************************************/
      /* Allows to get the pressed key.                                                     */
      /**************************************************************************************/
      byte getKeyPressed()
        {
        //Get first bit
        digitalWrite(SCL_PIN, LOW);
        delayMicroseconds(100);
        digitalWrite(SCL_PIN, HIGH);
      
        //Read all keys
        for(int i = 0; i < KEYBOARD_SIZE; i++)
          {
          keyState[i] = (digitalRead(SDA_PIN) == LOW);
          digitalWrite(SCL_PIN, LOW);
          delayMicroseconds(100);
          digitalWrite(SCL_PIN, HIGH);
          delayMicroseconds(100);
          }
      
        //Read keyboard table to find the pressed key
        byte keyPressed = -1;
        for(int i = 0 ; i < KEYBOARD_SIZE; i++)
          {
          if (keyState[i])
            {
            keyPressed = i;
            }
          }
      
        //Return the result
        return (keyPressed + 1);
        }
      
      /**************************************************************************************/
      /* Allows to fastly blink the LED.                                                    */
      /**************************************************************************************/
      void blinkLedFastly(byte loop)
        {
        byte delayOn = 150;
        byte delayOff = 150;
        for (int i = 0; i < loop; i++)
          {
          blinkLed(LED_PIN, delayOn);
          delay(delayOff);
          }
        }
      
      /**************************************************************************************/
      /* Allows to fastly blink the LED and to play a sound on the buzzer.                  */
      /**************************************************************************************/
      void blinkLedFastlyAndBuzz(byte loop)
        {
        byte delayOn = 150;
        byte delayOff = 150;
        for (int i = 0; i < loop; i++)
          {
          blinkLed(LED_PIN, delayOn);
          tone(BUZZER_PIN, BUZZ_FREQ_ERROR, delayOff);
          delay(delayOff);
          }
        }
      
      /**************************************************************************************/
      /* Allows to blink a LED.                                                             */
      /**************************************************************************************/
      void blinkLed(byte pinToBlink, int delayInMs)
        {
        digitalWrite(pinToBlink,HIGH);
        delay(delayInMs);
        digitalWrite(pinToBlink,LOW);
        }
      
      /**************************************************************************************/
      /* Allows to get the real Vcc (return value in mV).                                   */
      /* http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/   */
      /**************************************************************************************/
      long getVoltage()
        {
        ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
        delay(50);  // Let mux settle a little to get a more stable A/D conversion
        //Start a conversion  
        ADCSRA |= _BV( ADSC );
        //Wait for it to complete
        while (bit_is_set(ADCSRA, ADSC));
      
        //Compute and return the value
        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
        }
      

      David.

      posted in My Project
      carlierd
      carlierd
    • RE: In wall LCD Switch/Scene controller for MySensors

      Arf !! One more thing to do after my weather station node !! ๐Ÿ˜‰

      Looks very good !

      posted in OpenHardware.io
      carlierd
      carlierd
    • RE: Clean looking sensor node

      Very interesting !! Thanks for the idea !

      David.

      posted in Enclosures / 3D Printing
      carlierd
      carlierd
    • RE: Office plan monitor (advice required)

      @hek : The plant-ground stick is not used. @mfalkvidd did the voltage divider using pull-up. I plan to directly solder the sensor to the pcb.

      @scalz : will upgrade it. I already modified a little by using more space and have a less dense board.

      posted in My Project
      carlierd
      carlierd
    • RE: ๐Ÿ’ฌ Very narrow and minimal switch node

      @GertSanders I will try to modify your design to replace the NRF with a RFM69. Thanks.

      posted in OpenHardware.io
      carlierd
      carlierd
    • RE: ๐Ÿ’ฌ Various bootloader files based on Optiboot 6.2

      @GertSanders Hello. I tried the full deep sleep and it's really amazing !

      I used your 8MHz with internal crystal and B0 led, BOD disabled. RFM69 for radio and just a switch via a 10MOhm resistor.
      With the switch open: 280nA
      With the switch close: 580nA

      Measures done with a uCurrent Gold.
      So I am sure now that I found the good bootloader for my application. It's simple to install and I can change easily the BOD !
      Thanks !

      posted in OpenHardware.io
      carlierd
      carlierd
    • RE: Buy designs on OpenHardware.io

      Very good idea ! Especially for the DIY kit !!

      posted in OpenHardware.io
      carlierd
      carlierd
    • RE: ๐Ÿ’ฌ MyMultisensors

      Unfortunately it's not me on the avatar but it's my preferred judo technic ๐Ÿ˜‰

      posted in OpenHardware.io
      carlierd
      carlierd
    • RE: ๐Ÿ’ฌ MyMultisensors

      Merci pour le lien ! Trรจs instructif !

      @scalz said:

      http://www.dorkbotpdx.org/blog/paul/better_spi_bus_design_in_3_steps

      posted in OpenHardware.io
      carlierd
      carlierd