Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. My Slim 2AA Battery Node

My Slim 2AA Battery Node

Scheduled Pinned Locked Moved My Project
498 Posts 71 Posters 342.6k Views 69 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arnoldg
    wrote on last edited by
    #306

    Below is my first sketch with this awsome 2aa battery powerd board.
    i didn't measure the current. but i tryed to be as efficient with the power as possible.

    my avr is running on 8Mhz, this is becaus the DTH22 doesn't run on 1Mhz.

    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>  
    #include <Vcc.h>
    
    
    #define CHILD_ID_TEMP 1               // Child id for temperatur
    #define CHILD_ID_HUM 2                // Child id for humidity
    #define CHILD_ID_VOLT 3               // Child id for battery reading
    
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3 // Where is my DHT22 data pin connected to
    
    int node_id=6;                        // What is my node id
    
    unsigned long SLEEP_TIME =30000UL;    // Sleep time between reads (in milliseconds)
    int sleepcycle=1;                     // Counter to count the amout of time not sending data
    int humoffset=2;                      // only data is send if humidity is changed for this amout
    int tempoffset=0.5;                   // only data is if temperature is changed for this amout 
    int gwsendtimout=20;                  // each 20*sleep_time (10 minutes) data will be send
    
    const float VccMin   = 1.5;           // Minimum expected Vcc level, in Volts.
    const float VccMax   = 3.0;           // Maximum expected Vcc level, in Volts.
    const float VccCorrection = 1.0/1.0;  // Measured Vcc by multimeter divided by reported Vcc
    
    Vcc vcc(VccCorrection);
    
    MySensor gw;
    DHT dht;
    //Store last values
    float lastTemp = 0 ;                  
    float lastHum = 0 ;
    float batteryV=0;
    int oldBatteryPcnt = 0;             
    
    boolean lastTripped = false ;
    boolean metric = true; 
    
    boolean gwsend = true;              // to determin if data has to be send
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgVolt(CHILD_ID_VOLT, V_VOLTAGE);
    
    void setup()  
    { 
      gw.begin(NULL,node_id,false);
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Humidity", "1.1",true);
    
    
     
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM,"Humidity douche");
      gw.present(CHILD_ID_TEMP, S_TEMP,"Temperatuur douche");
      gw.present(CHILD_ID_VOLT, S_MULTIMETER,"Battery voltage");
       
      metric = gw.getConfig().isMetric;
    }
    
    void loop()      
    
    {  
      // get the battery Voltage
       batteryV  = vcc.Read_Volts();
       int batteryPcnt = vcc.Read_Perc(VccMin, VccMax);
    
       if (oldBatteryPcnt != batteryPcnt) {
         // Power up radio after sleep
         gwsend=true;
         oldBatteryPcnt = batteryPcnt;
       }
        
      delay(dht.getMinimumSamplingPeriod());
    
      float temp1 = dht.getTemperature();
      float humidity = dht.getHumidity();
    
      if (isnan(temp1)) {
    //      Serial.println("Failed reading temperature from DHT");
      } else if ((temp1 <= lastTemp-tempoffset)||(temp1 >= lastTemp+tempoffset)) {
        lastTemp = temp1;
        if (!metric) {
          temp1 = dht.toFahrenheit(temp1);
        }
        gwsend=true;
      }
    
      if (isnan(humidity)) {
        //      Serial.println("Failed reading humidity from DHT");
      } else if ((humidity <= lastHum-humoffset)||(humidity >= lastHum+humoffset)) {
          lastHum = humidity;
          gwsend=true;
        }
    
      if (sleepcycle>gwsendtimout){
        gwsend=true;
       }
    
    if (gwsend){     
        gw.sendBatteryLevel(oldBatteryPcnt);
        gw.send(msgVolt.set(batteryV, 1));
        gw.send(msgTemp.set(lastTemp, 1));  
        gw.send(msgHum.set(lastHum, 1));
        gwsend=false;
        sleepcycle=1;
      }
      sleepcycle++;  
      gw.sleep(SLEEP_TIME);
    }
    
    1 Reply Last reply
    0
    • W Offline
      W Offline
      wergeld
      wrote on last edited by
      #307

      Finally had time to solder it. Not my best job, I admit. One of the caps I tried to mount was not flush enough so I had to clip it off. Hopefully not a critical component! I made the radio removable using some header strips. Now to figure out what temp sensor to use. I have currently used just a thermister. Can DHT22 work down at ~1.9V?

      Anyway this was fun - highly recommend a needle point solder tip!
      0_1460248776746_IMG_20160409_194629.jpg

      AWIA 1 Reply Last reply
      0
      • W wergeld

        Finally had time to solder it. Not my best job, I admit. One of the caps I tried to mount was not flush enough so I had to clip it off. Hopefully not a critical component! I made the radio removable using some header strips. Now to figure out what temp sensor to use. I have currently used just a thermister. Can DHT22 work down at ~1.9V?

        Anyway this was fun - highly recommend a needle point solder tip!
        0_1460248776746_IMG_20160409_194629.jpg

        AWIA Offline
        AWIA Offline
        AWI
        Hero Member
        wrote on last edited by
        #308

        @wergeld congratulations :thumbsup:
        For the temp sensor I suggest a si7021 board. Almost the same price as as dht22 but more accurate, reliable and versatile. It uses the I2C bus (pin A4, A5)

        W 1 Reply Last reply
        0
        • AWIA AWI

          @wergeld congratulations :thumbsup:
          For the temp sensor I suggest a si7021 board. Almost the same price as as dht22 but more accurate, reliable and versatile. It uses the I2C bus (pin A4, A5)

          W Offline
          W Offline
          wergeld
          wrote on last edited by
          #309

          @AWI said:

          @wergeld congratulations :thumbsup:
          For the temp sensor I suggest a si7021 board. Almost the same price as as dht22 but more accurate, reliable and versatile. It uses the I2C bus (pin A4, A5)

          @AWI I saw the si7021 on another forum. Ordered a couple of the low voltage ones as I want to make my nodes with as few components as possible. I could still use my thermistor while I wait. This is a fun build!

          1 Reply Last reply
          0
          • SoloamS Offline
            SoloamS Offline
            Soloam
            Hardware Contributor
            wrote on last edited by
            #310

            Hello, I made a small modification to this project, hope that is ok! Now I need some help validating it! I opened a new topic to avoid going side topic in this one:

            http://forum.mysensors.org/topic/3642/m26872-slim-node-mod

            Thank you all

            m26872M 1 Reply Last reply
            1
            • SoloamS Soloam

              Hello, I made a small modification to this project, hope that is ok! Now I need some help validating it! I opened a new topic to avoid going side topic in this one:

              http://forum.mysensors.org/topic/3642/m26872-slim-node-mod

              Thank you all

              m26872M Offline
              m26872M Offline
              m26872
              Hardware Contributor
              wrote on last edited by
              #311

              @Soloam I'm happy that you've picked up the design. That's what this openhardware is all about. Also very good that you made a new topic! So, let's continue there. I'll follow.

              1 Reply Last reply
              1
              • rollercontainerR Offline
                rollercontainerR Offline
                rollercontainer
                wrote on last edited by
                #312

                I ordered a proto pack on 15th of April and received it on 30th of April. Pretty fast, I think. :-)

                1 Reply Last reply
                1
                • rollercontainerR Offline
                  rollercontainerR Offline
                  rollercontainer
                  wrote on last edited by
                  #313

                  Hm, I built some nodes and messured the current with a Fluke 179: 15mA even with a minimal sketch with sleeping enabled. AVRs are not from china, but the NRF24 are. So, is the radio the problem?

                  Greetings

                  1 Reply Last reply
                  0
                  • rollercontainerR Offline
                    rollercontainerR Offline
                    rollercontainer
                    wrote on last edited by
                    #314

                    (i am using MySensors 2.0.0beta)

                    1 Reply Last reply
                    0
                    • m26872M Offline
                      m26872M Offline
                      m26872
                      Hardware Contributor
                      wrote on last edited by
                      #315

                      Could be radio, but who knows? What troubleshooting steps have you taken? Hw-, sw-variations etc. Please post your sketch. Perhaps are there any SlimNode users with working MyS 2.0.0 beta that can share some info.

                      GertSandersG 1 Reply Last reply
                      0
                      • m26872M m26872

                        Could be radio, but who knows? What troubleshooting steps have you taken? Hw-, sw-variations etc. Please post your sketch. Perhaps are there any SlimNode users with working MyS 2.0.0 beta that can share some info.

                        GertSandersG Offline
                        GertSandersG Offline
                        GertSanders
                        Hardware Contributor
                        wrote on last edited by
                        #316

                        @m26872
                        I have had a bad radio which would not go to sleep and consumed around that amount all the time (also when I used SLEEP in the 2.0 library).

                        Switching the radio to another one fixed it. All my radio's are from China, so they are normally OK. But you can get bad ones once in a while. Given the low cost I do not care and swap them when needed.

                        1 Reply Last reply
                        1
                        • rollercontainerR Offline
                          rollercontainerR Offline
                          rollercontainer
                          wrote on last edited by
                          #317

                          Ok, where to buy NRF24's which are genuine for sure and not too expensive in europe?

                          GertSandersG 1 Reply Last reply
                          0
                          • rollercontainerR rollercontainer

                            Ok, where to buy NRF24's which are genuine for sure and not too expensive in europe?

                            GertSandersG Offline
                            GertSandersG Offline
                            GertSanders
                            Hardware Contributor
                            wrote on last edited by
                            #318

                            @rollercontainer
                            No idea, I'm quite happy with the radio's from China (1 bad one on 25 pcs so far).

                            1 Reply Last reply
                            0
                            • rollercontainerR Offline
                              rollercontainerR Offline
                              rollercontainer
                              wrote on last edited by
                              #319

                              Thx, Gert. Are you using 1.5 or 2.0.0beta?

                              GertSandersG 1 Reply Last reply
                              0
                              • rollercontainerR rollercontainer

                                Thx, Gert. Are you using 1.5 or 2.0.0beta?

                                GertSandersG Offline
                                GertSandersG Offline
                                GertSanders
                                Hardware Contributor
                                wrote on last edited by
                                #320

                                @rollercontainer
                                I use the 2.0 beta

                                1 Reply Last reply
                                0
                                • rollercontainerR Offline
                                  rollercontainerR Offline
                                  rollercontainer
                                  wrote on last edited by
                                  #321

                                  Bought another 2 radios from different dealers. The one with the blob on the die is going down to 2mA, but isnt working at all (node does not come up). The next one is working, but again 15mA. This is frustrating. Anyone here with a good source for radio modules?

                                  Even with a stripped down sketch without any sensors with only delay and sleep in the loop, the current stays the same.

                                  GertSandersG 1 Reply Last reply
                                  0
                                  • rollercontainerR rollercontainer

                                    Bought another 2 radios from different dealers. The one with the blob on the die is going down to 2mA, but isnt working at all (node does not come up). The next one is working, but again 15mA. This is frustrating. Anyone here with a good source for radio modules?

                                    Even with a stripped down sketch without any sensors with only delay and sleep in the loop, the current stays the same.

                                    GertSandersG Offline
                                    GertSandersG Offline
                                    GertSanders
                                    Hardware Contributor
                                    wrote on last edited by
                                    #322

                                    @rollercontainer
                                    I get my radio's from an Aliexpress store called AAA+ (or something with a lot of A's in the name).

                                    1 Reply Last reply
                                    0
                                    • BobcatB Offline
                                      BobcatB Offline
                                      Bobcat
                                      wrote on last edited by
                                      #323

                                      @26872, It's my first post here and I had to register so that I could give you my regards for your work and for sharing it with us! Just ordered a batch of your v2 boards.

                                      I have similar design sensors running on proto-pcbs, but your ready-made pcb makes everything much more convenient.

                                      Just had a question on stability of running regular Arduino 8mhz internal clock bootloader for prolonged time. Anyone tried this and had success running the 328 down to 2v (or so) @ 8mhz? If this is a doomed idea, I will have to attach the boost circuit to this design, but it would be nice to avoid all that parasite current consumption.

                                      GertSandersG 1 Reply Last reply
                                      0
                                      • BobcatB Bobcat

                                        @26872, It's my first post here and I had to register so that I could give you my regards for your work and for sharing it with us! Just ordered a batch of your v2 boards.

                                        I have similar design sensors running on proto-pcbs, but your ready-made pcb makes everything much more convenient.

                                        Just had a question on stability of running regular Arduino 8mhz internal clock bootloader for prolonged time. Anyone tried this and had success running the 328 down to 2v (or so) @ 8mhz? If this is a doomed idea, I will have to attach the boost circuit to this design, but it would be nice to avoid all that parasite current consumption.

                                        GertSandersG Offline
                                        GertSandersG Offline
                                        GertSanders
                                        Hardware Contributor
                                        wrote on last edited by
                                        #324

                                        @Bobcat
                                        I have had an atmega328 run down to 1V6 at 8Mhz before failing completely, so working down to 2V should be OK. The nrf24 will likely stop around that point as well (lower limit is 1V9 for that chip).

                                        BobcatB 1 Reply Last reply
                                        0
                                        • GertSandersG GertSanders

                                          @Bobcat
                                          I have had an atmega328 run down to 1V6 at 8Mhz before failing completely, so working down to 2V should be OK. The nrf24 will likely stop around that point as well (lower limit is 1V9 for that chip).

                                          BobcatB Offline
                                          BobcatB Offline
                                          Bobcat
                                          wrote on last edited by
                                          #325

                                          @GertSanders
                                          Thank you for the reply! Was the atmega doing some clock critical tasks when it went below 2v? I am thinking to attach BME280 (Pressure/Temp/Hum) which also operates in the same voltage range, but not sure if the I2C will be working properly when atmega goes overclocked.

                                          GertSandersG 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          14

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular