Navigation

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

    HarryDutch

    @HarryDutch

    11
    Reputation
    40
    Posts
    919
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    HarryDutch Follow

    Best posts made by HarryDutch

    • RE: How low can arduino can go?

      @funky81

      If you have a problem with your project (in this case you can't get the power consumption down to microamps) it's maybe a good idea to start with a bare minimum setup. In this case an Arduino Pro Mini, a regulated power supply and a sketch that's puts the Arduino to sleep. So for now you better focus on sleeping the Pro Mini and bring current consumption down to a couple of microamps before trying anything else.

      First you need to understand what these power savings are all about. This site (Nick Gammon) is all you need to know about power saving techniques for microprocessors (a must read):
      http://www.gammon.com.au/forum/?id=11497

      Read it all, do some of the examples yourself and above all try to understand what's happening.

      After that start with your basic setup to put the Arduino to sleep. This is how I do it:

      Arduino Pro Mini: use the 3.3v version. Remove the power led because it's useless and it's still using a couple of milliamps. I lift it off the board by using a small watchmaker screwdriver. Try to get it between the bottom side of the led and the pcb and use some force to lift it from the board. You could also cut one of the connections from the led to the board. For now don't remove the voltage regulator (more about this later).

      For the power supply I use a 3.3 volt LDO voltage regulator. In this case the HT7333-A (TO-92 package). I know there are a lot more LDO voltage regulators to choose from, but I have good results with this LDO. Search Ebay for it. Price is about $4 for 20 pieces. They have an ultra low quiescent current of only 4 microamps. According to the datasheet you need a 10 uF cap across Vin and GND and Vout and GND so use them. Find and read the datasheet to find out how to connect it.

      I’m using 3 AAA batteries (alkaline) to power the voltage regulator. Later on you can try other options (step-up, step-down, other regulators and so on) but for now stick with the setup as described above.

      Finally use the sketch below to put the Mini to sleep and check with your multimeter the current consumption. In this case I measured 38 uA with the voltage regulator in place (Voltcraft VC170 digital multimeter). After removing the voltage regulator I measured a current of only 3uA. Be aware that measuring very low currents are influenced by burden voltage (this is a nice video about burden voltage https://www.youtube.com/watch?v=fRP98k3Rh1E).

      #include <avr/sleep.h>
      
      void setup () 
      {
        // disable ADC
        ADCSRA = 0;  
        
        set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
        sleep_enable();
       
        // turn off brown-out enable in software
        MCUCR = bit (BODS) | bit (BODSE);
        MCUCR = bit (BODS); 
        sleep_cpu ();              // sleep within 3 clock cycles of above
      
      }  // end of setup
      
      void loop () { }
      
      

      Question is if it's really necessary to remove the voltage regulator to save an extra 35 uA. There is a nice battery life calculator here: http://oregonembedded.com/batterycalc.htm that will show you the difference in battery life when using 3uA or 38uA. I think a minimum period of 1 year before you have to replace/recharge your batteries is acceptable. Suppose you're using 3 AAA alkaline batteries. Capacity rating is then 1200 mAh (capacity is automatically derated by 15% to account for some self discharge.) Current consumption (without the regulator) is 0.003 mA. Current consumption during wake is 25 mA and the number of wakeups per hour is 12 (for example you take a temperature measurement every 5 minutes). Durations of wake time is 50 ms. If you use these figures with the calculator, battery life is 16 years. If you change 0.003 mA into 0.038 mA battery life will be 2.7 years. So you have to ask yourself if removing the voltage regulator (with the risk of destroying your mini which happened to me more than once) is really necessary. In this case I think it's not.

      If you really want to remove the regulator there are several ways to do this. Best way (at least for me) is first cutting the legs of the regulator with a very sharp scalpel. Be careful to cut only the legs and not the board beneath it. Then try to lift it from the board by using a needle nose pliers. Use minimal force! If you have to use too much force then try to cut the legs a little further.

      So there you have it. First try to prove to yourself that it's possible to get current consumption for an Arduino Pro Mini down to a few microamps and only then continue your adventures in MySensors land! Hope this helps.

      posted in Troubleshooting
      HarryDutch
      HarryDutch
    • RE: Sensor pins

      @Lee-Groom

      Have a look at MyConfig.h. If you have "#define WITH_LEDS_BLINKING" then D4, D5 and D6 are used for blinking the status led's. Could maybe explain your problem.

      posted in Hardware
      HarryDutch
      HarryDutch
    • RE: Node to Node Communication

      Second that! I'm looking also for an example.

      posted in Development
      HarryDutch
      HarryDutch
    • RE: Codebender on ipad hiding code

      @mfalkvidd
      When you open YouTube itself then look at the uppper right corner where you should see 3 dots. Tapping these dots will give you the all available options.

      posted in General Discussion
      HarryDutch
      HarryDutch
    • RE: Running ATmega328P on internal 8MHz clock

      Have a look here:
      http://www.gammon.com.au/breadboard

      This is the easyiest way to bootload you Atmega328p with 8Mhz. Works like a charm.

      posted in Hardware
      HarryDutch
      HarryDutch
    • RE: Domoticz and heater

      @sundberg84 , @jlehtinen

      I've solved this problem with a LUA script in Domoticz. The script copies the values of temperature and humidity to a TEXT sensor (as a string). In the Arduino sketch (you need the MySensors development branch) the string is split in 2 separate values (Strings). Works like a charm.

      LUA script:

      
         tempString = ""
         stringReturn = ""
         sensor = '103OutsideTempHum'
         tempString = otherdevices_svalues[sensor]
      
         sep = ";"
         i=1
      
         for str in string.gmatch(tempString, "([^"..sep.."]+)") do
            stringReturn = stringReturn .. str .. "#"
            i = i + 1
         end
      
      commandArray = {}
      
         time = os.date("*t")
         if ((time.min % 5)==0) then--run script every 5 minutes
         commandArray[1] = {['UpdateDevice'] = 77 .. '|0|' .. tostring(stringReturn)} -- 77 = idx of TEXT sensor in Domoticz
         end
      
      return commandArray
      
      

      Arduino sketch:

      
      #include <SPI.h>
      #include <TFT_ILI9341.h>
      #include <MySensor.h> 
      
      #define MY_RADIO_NRF24
      #define CHILD_ID_TEXT 1
      #define CHILD_ID_BUTTON 2
      
      #define MIN_V 2600
      #define MAX_V 3200
      
      #define sclk 13  // Don't change
      #define mosi 11  // Don't change
      #define cs   17
      #define dc   16
      #define rst  15  // you can also connect this to the Arduino reset
      
      TFT_ILI9341 tft = TFT_ILI9341();
      
      void Button() {}
      
      int interrupt;
      String tempSensor;
      byte batteryPcnt;
      
      MyMessage msgTemp(CHILD_ID_TEXT, V_TEXT);
      MyMessage msgButton(CHILD_ID_BUTTON, V_STATUS);
      
      void presentation() 
      {
        sendSketchInfo("103 TEST", "1.0");
        present(CHILD_ID_TEXT, S_INFO);
        present(CHILD_ID_BUTTON, S_BINARY);
      } 
      
      void setup()
      { 
        Serial.begin(9600);
        pinMode(4, OUTPUT);
        digitalWrite(4, HIGH);
        
        pinMode(3, INPUT_PULLUP); // int 1 used by button
       
        attachInterrupt(digitalPinToInterrupt(3), Button,FALLING);
      }
      
      
      void loop() 
      {
        if(interrupt == 1)
        {  
          send(msgButton.set(1));  
          request(CHILD_ID_TEXT, V_TEXT);
          batteryPcnt = min(map(readVcc(), MIN_V, MAX_V, 0, 100), 100);
          sendBatteryLevel(batteryPcnt);
          wait(500);
          Screen();
          
          send(msgButton.set(0));
        }
        
        digitalWrite(rst, LOW);
        digitalWrite(4, HIGH);   
        wait(10);
      
        interrupt = sleep(1,FALLING);
      }
      
      void receive(const MyMessage &message) 
      {
        if (message.sensor == 1) 
        {
          tempSensor = message.getString();
        } 
        wait(200);
      }
      
      //====== Show screen after hitting button ==============================
      void Screen() 
      {
        digitalWrite(4, LOW);
        wait(10);
        tft.init();
        tft.setRotation(2);    
        
        char c_tmp[6];
        char c_hum[6];
      
        int sepIndex1 = tempSensor.indexOf('#');
        int sepIndex2 = tempSensor.indexOf('#',sepIndex1+1);
        String tmp = tempSensor.substring(0,sepIndex1);
        String hum = tempSensor.substring(sepIndex1+1,sepIndex2);
        
        tft.fillScreen(ILI9341_BLACK);
        wait(5);//don't touch this!!
        tft.setTextSize(1);
      
        tft.fillRoundRect(5, 5, 230, 180, 10, ILI9341_WHITE);
        tft.setTextColor(ILI9341_BLUE);
        tmp.toCharArray(c_tmp, 6); 
        tft.drawCentreString(c_tmp,120,50,8);
      
        tft.fillRoundRect(5, 190, 230, 90, 10, ILI9341_WHITE);
        tft.setTextColor(ILI9341_BLACK);
        tft.setCursor(10,200,4);
        tft.print("Humidity "); 
        tft.setTextColor(ILI9341_BLUE);
        tft.setCursor(120,200,4);
        hum.toCharArray(c_hum, 6); 
        tft.print(c_hum); tft.print(" %");
        tft.setCursor(200,245,4);
        tft.print(batteryPcnt); 
        wait(15000L); 
      }
      
      long readVcc() {
        // Read 1.1V reference against AVcc
        // set the reference to Vcc and the measurement to the internal 1.1V reference
        #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
          ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
          ADMUX = _BV(MUX5) | _BV(MUX0);
        #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
          ADMUX = _BV(MUX3) | _BV(MUX2);
        #else
          ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
        #endif                 
       
        delay(2); // Wait for Vref to settle
        ADCSRA |= _BV(ADSC); // Start conversion
        while (bit_is_set(ADCSRA,ADSC)); // measuring
       
        uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
        uint8_t high = ADCH; // unlocks both
       
        long result = (high<<8) | low;
       
        result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
        return result; // Vcc in millivolts
      }
      
      
      posted in Domoticz
      HarryDutch
      HarryDutch
    • RE: WITH_LEDS_BLINKING - for gateways only?

      MySensors 1.5.1
      Controller: Domoticz

      I'm using a simpel test sensor with the "blinking led's" to find "dead zones" in my house. The "blinking led's" are a big help for this and works flawlessly all the time.

      /**
       * 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.
       *
       *******************************
       */
      #include <SPI.h>
      #include <MySensor.h>
      
      #define CHILD_ID_BUTTON 0        //pushbutton attached to interrupt 0 (= pin 2).
      #define CHILD_ID_LED 1           //LED that is switch on/off by the controller (Domoticz).
      
      MySensor gw;
      
      MyMessage msg(CHILD_ID_LED, V_LIGHT);
      MyMessage msg2(CHILD_ID_BUTTON, V_STATUS);
      
      byte firstTime = 1;     //make sure that the mcu is going to sleep for the first time (no loop)
      
      void setup() {
        
      gw.begin(incomingMessage);
      gw.sendSketchInfo("Test sensor","1.0");
      gw.present(CHILD_ID_LED, S_LIGHT); 
      gw.present(CHILD_ID_BUTTON, S_BINARY);  
      
      pinMode(2, INPUT_PULLUP);        //interrupt = 0;
      
      pinMode(7, OUTPUT);              //LED is attached to pin 7
      digitalWrite(7, LOW);            //make sure that the LED is off
      
      }
      
      void loop() { 
        if(firstTime == 0) {
          gw.process();
          
          gw.send(msg2.set(1)); // send to controller a message that the button has been pushed. The controller then swithes the LED on (incomingMessage)
          gw.wait(2000);
          if(digitalRead(7) == HIGH) digitalWrite(7, LOW); // switch the LED off after 2 seconds 
          gw.send(msg.set(0)); // let the controller know that the mcu has switched off the LED
          gw.wait(2000);   
        } 
        
        firstTime = 0;
        gw.sleep(0,FALLING); // go to sleep and wait for the next button push 
      }
      
      void incomingMessage(const MyMessage &message) {
        if (message.type == V_LIGHT) {
          if (message.getInt() == 1) digitalWrite(7, HIGH);  
        }
      }
      
      posted in Development
      HarryDutch
      HarryDutch
    • RE: Hall effect sensor

      You need a linear hall efect sensor (output proportional to field strength). Search Ebay for A1301 Hall sensor.

      More information here:
      http://playground.arduino.cc/Code/HallEffect

      posted in Hardware
      HarryDutch
      HarryDutch

    Latest posts made by HarryDutch

    • RE: Automatic stairs lighting +MySensors

      @aivaredze Great project. Absolutely great video! Love it. One question: how did you manage to hide the cables between your shield and the led strips? Maybe some pictures?

      posted in My Project
      HarryDutch
      HarryDutch
    • RE: šŸ’¬ Automatic stairs led lighting arduino shield

      Great video!!!!

      posted in OpenHardware.io
      HarryDutch
      HarryDutch
    • RE: [SOLVED] Sleep dont run

      @mar.conte A shot in the dark but have you tried to pull down pin 3 in order to prevent this pin is floating? Connect pin 3 to ground with a 10K resistor.

      posted in Troubleshooting
      HarryDutch
      HarryDutch
    • RE: [SOLVED] Sleep dont run

      @mar-conte
      What happens if you change your sleep function like this:

      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), HIGH,0);

      posted in Troubleshooting
      HarryDutch
      HarryDutch
    • RE: New MS node creates lots of random sensors, as well as actual sensors [Domoticz]

      Domoticz > Settings > uncheck "Accept new Hardware Devices". Don't forget to click Apply Settings.

      posted in Troubleshooting
      HarryDutch
      HarryDutch
    • RE: Looking for simple/clean Code example for sleep() external interrupt.

      I think the sketch you need is here .

      posted in General Discussion
      HarryDutch
      HarryDutch
    • RE: [Solved] Strange behavior Sleep() function and interrupts in MyS library 2.1.1

      @tekka Yes! This works. Thanks for your help. I'm still confused why my test script worked with 2.0.0. and not with 2.1.1. Thanks again.

      posted in Bug Reports
      HarryDutch
      HarryDutch
    • RE: [Solved] Strange behavior Sleep() function and interrupts in MyS library 2.1.1

      @Yveaux I'm using my own pcb's. Nothing special. It has the ATMEGA328p (8 Mhz) and the nrf radio. The hardware worked with MyS library 2.0.0. Using Arduino 1.8.1. Board UNO 8 Mhz 3.3v.

      posted in Bug Reports
      HarryDutch
      HarryDutch
    • [Solved] Strange behavior Sleep() function and interrupts in MyS library 2.1.1

      After upgrading the MySensors library from 2.0.0 to 2.1.1 I noticed that the sleep function with interrupts was working different than before. Have a look at the simple test sketch below . In 2.0.0 the loop is called only once after an interrupt. In 2.1.1 the loop is called twice before the sleep function becomes active. Below you have the serial log for 2.0.0 and 2.1.1. for 2 interrupts. Is this a bug or do I need to change some settings or use a different code?

      //Test sleep function and interrupt in library 2.1.1 and 2.0.0
      
      #define MY_DEBUG 
      
      #include <SPI.h>
      #define MY_RADIO_NRF24
      #include <MySensors.h>
      byte countInterrupt;
      void isr() {}
                                                                                        
      void setup(void) {
        pinMode(3, INPUT_PULLUP); // intterupt 1
        attachInterrupt(digitalPinToInterrupt(3), isr,FALLING); 
      }
      
      void loop() {
        sleep(1,FALLING,0);
        Serial.print("interrupt ");
        Serial.println(countInterrupt++);
        wait(1000);
      }
      

      Serial log 2.0.0 (this one works ok).

      Starting sensor (RNNNA-, 2.0.0)
      TSM:INIT
      TSM:RADIO:OK
      TSP:ASSIGNID:OK (ID=2)
      TSM:FPAR
      TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
      TSP:MSG:READ 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0
      TSP:MSG:FPAR RES (ID=0, dist=0)
      TSP:MSG:PAR OK (ID=0, dist=1)
      TSM:FPAR:OK
      TSM:ID
      TSM:CHKID:OK (ID=2)
      TSM:UPL
      TSP:PING:SEND (dest=0)
      TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
      TSP:MSG:READ 0-0-2 s=255,c=3,t=25,pt=1,l=1,sg=0:1
      TSP:MSG:PONG RECV (hops=1)
      TSP:CHKUPL:OK
      TSM:UPL:OK
      TSM:READY
      TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
      TSP:MSG:SEND 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=ok:2.0.0
      TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=ok:0
      TSP:MSG:READ 0-0-2 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      TSP:MSG:READ 0-0-2 s=255,c=3,t=6,pt=0,l=1,sg=0:M
      Request registration...
      TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
      TSP:MSG:READ 0-0-2 s=255,c=3,t=27,pt=1,l=1,sg=0:1
      Node registration=1
      Init complete, id=2, parent=0, distance=1, registration=1
      ****************** Start first interrupt *************************************
      interrupt 0
      ***************** Start second interrupt *************************************
      interrupt 1
      

      Serial log 2.1.1

      0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
      4 TSM:INIT
      4 TSF:WUR:MS=0
      12 TSM:INIT:TSP OK
      14 TSF:SID:OK,ID=2
      16 TSM:FPAR
      51 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2060 !TSM:FPAR:NO REPLY
      2062 TSM:FPAR
      2099 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2277 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      2283 TSF:MSG:FPAR OK,ID=0,D=1
      4106 TSM:FPAR:OK
      4106 TSM:ID
      4108 TSM:ID:OK
      4110 TSM:UPL
      4116 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      4122 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      4128 TSF:MSG:PONG RECV,HP=1
      4132 TSM:UPL:OK
      4134 TSM:READY:ID=2,PAR=0,DIS=1
      4143 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      4151 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      4159 TSF:MSG:SEND,2-2-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
      4171 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      4184 TSF:MSG:READ,0-0-2,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      4190 MCO:REG:REQ
      4194 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      4202 TSF:MSG:READ,0-0-2,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      4208 MCO:PIM:NODE REG=1
      4210 MCO:BGN:STP
      4212 MCO:BGN:INIT OK,TSP=1
      4214 MCO:SLP:MS=0,SMS=0,I1=1,M1=2,I2=255,M2=255
      4220 MCO:SLP:TPD
      4222 MCO:SLP:WUP=1
      ********************* Start first interrupt ********************************
      interrupt 0
      5226 MCO:SLP:MS=0,SMS=0,I1=1,M1=2,I2=255,M2=255
      5230 MCO:SLP:TPD
      5232 MCO:SLP:WUP=1
      interrupt 1
      6234 MCO:SLP:MS=0,SMS=0,I1=1,M1=2,I2=255,M2=255
      6238 MCO:SLP:TPD
      6240 MCO:SLP:WUP=1
      ********************* Start second interrupt *******************************
      interrupt 2
      7243 MCO:SLP:MS=0,SMS=0,I1=1,M1=2,I2=255,M2=255
      7247 MCO:SLP:TPD
      7249 MCO:SLP:WUP=1
      interrupt 3
      8251 MCO:SLP:MS=0,SMS=0,I1=1,M1=2,I2=255,M2=255
      8255 MCO:SLP:TPD
      
      posted in Bug Reports
      HarryDutch
      HarryDutch
    • RE: i2c Lightning Sensor +

      @gohan Maybe this one?
      http://www.ebay.com/itm/EMP-sensor-detector-module-for-lightning-detection-/302051777514?hash=item4653b05bea:g:L8UAAOSwLnBX2sVY

      posted in My Project
      HarryDutch
      HarryDutch