Navigation

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

    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