💬 Battery Powered Sensors



  • I am not getting it...

    I have a 3.3V Pro Mini, it is connected to my table power supply and want it to be powered by a coin cell later. To test the VCC lib, I set

    const float VccExpected   = 3.21;
    

    What do I need to put here?

    const float VccCorrection = 3.21/3.21;
    

    It always returns BatteryPercentage of 2 or 3% seems the function is not calculating right. Anyhow I saw there is another function to call Read_Volts()

    float volts = (float)vcc.Read_Volts();
    int myPerc = volts *100 / VccExpected; 
    

    So "myPerc" returns a value of 98% which seems feasible, also when reducing Voltage it drops.
    But still, not getting the values with the build in function read_Perc()



  • I'm building my home automation with a few Whisper Nodes (https://talk2.wisen.com.au/product-talk2-whisper-node-avr/) and I just got them working with the MySensor code. I'm running most of my projects with two AA but I just setup one with a CR2032 transmitting my attic temperature every 5 minutes to see how it goes. One thing I discovered is that the board comes two "built-in" resistor divider to monitor the battery and power supply voltage, which is pretty handy... also they have added a Mosfet on the battery voltage divider, I guess to eliminate the constant current leak consumed by the voltage divider, am I right?! (https://bitbucket.org/talk2/whisper-node-avr/overview#markdown-header-voltage-monitor)


  • Hardware Contributor

    @bjacobt

    It seems you are missing the capacitors connecting each side of the crystal to ground. Those should be between 15 and 25pf (depends on the crystal), normally ceramic type.



  • @GertSanders

    How are you sending the voltage?

    Sensor = S_MULTIMETER and value = V_VOLTAGE in a normal message?

    Thx!


  • Hardware Contributor

    @chaeron
    Correct 🙂



  • @GertSanders

    Thanks! I'll use that approach for all my house sensors, since right now all I send is battery percentage..

    ...at least until/if they add support for a I_Battery_Voltage internal value. 😈



  • Realy n00b in electronics here but do you need to use those exact values of the resistors when hooking this up?


  • Mod

    @meanmrgreen are you reffering to the 470K+1M resistors? (This is a long thread)
    If so, they can be any size but the code will need to be adjusted if the ratio between the resistors is changed.

    Also, less resistance will drain the battery faster.



  • Yes i do.
    This is like going back to school... but fun!



  • can someone explains why using analogReference(INTERNAL) ?

    for the moment i only have 5V nano suplyed by a 7.4V lipo (i know, this is not a good choice, but i just have this right now) so with that hardware, 1.1V seems too low.
    I mean that resistance ratio to reach 1.1V max smells a very inacurate result; isn't it?


  • Hardware Contributor

    @giovaFr Hello, try to replace 470k(R2) by a 180k 😉

    for obtain this value i did : R2 = R1 / ( Vbatmax - Vref); R2 = 1.1^6 / (7.5 - 1.1) = 172k, i taked a normalized value = 180k.



  • I think i've finnaly understood :
    1.1V is not a reference like an offset it is a reference as a max readable voltage
    Analog Input will always return values between 0 and 1023
    5V / 1023 bits = 0.0048 V per bit
    1.1V /1023 bits = 0.001075 V per bit
    so with 1.1V we are allmost 5 times more accurate. Moreover it seems that 1.1V will stay stable even if battery voltage becomes low. (so understand now why using it)
    And that's what mfalkvidd explained : if we type in code : analogReference(INTERNAL); then voltage must never exceed 1.1V on A0 (it is different on an arduino Mega)

    Now to choose R1 and R2 here what i've made :
    A0maxV = VbattMax * (R2 / (R1+R2)
    for me it means
    1.1V = 8.4V * (R2 / (10^6 Ohms + R2)
    so i use R2 around 150k Ohms

    A0voltage = A0value * 0.001075
    A0Voltage = VBatt * (R2 /(R1+R2))
    A0Voltage = VBatt * rRatio
    VBatt = A0Voltage / rRatio = (A0Value *0.001075 ) /rRatio

    So here the magic formula:
    VBatt = (A0Value *0.001075 ) /rRatio

    Let me know if i'm wrong somewhere.


  • Hardware Contributor

    @giovaFr said in 💬 Battery Powered Sensors:

    A0maxV = VbattMax * (R1 / (R1+R2)

    Are you sure about that ? I think is A0maxV = VbattMax * (R2 / (R1+R2)

    R2 = 150k Ohms for 8.4V with R1 always at 1M Ohms



  • oops you are right i mixed both 🙂

    i fixed my error, thanks



  • If I power my 3.3V miniPro through VCC, do I still need to remove/cut the voltage regulator?
    I thought the current moved from vvc-in/raw through the regulator and then to the MCU and VCC 😕 .
    My battery powered nodes are dying and I suspect I need to change BOD and eventually something more (LED gone )..


  • Hardware Contributor

    @Efflon

    VCC pin is directly connected to the MCU.

    The RAW or IN pin is connected to the regulator input. Th eregulator output is connected to VCC pin and thus to the MCU power input pin.

    On a 3V3 promini you can give between 3V3 and 12V (on most promini's, some can handle up to 16V) on the RAW or IN pin. The regulator on the promini will bring that down to 3V3 (which you will be able to measure on the VCC pin).

    By giving 3V3 on the VCC pin, some power is lost via the output pin of the regulator (through the regulator) towards the GND pin of the regulator. This should be minimal, but on bad regulators it can be enough to drain a battery in weeks. So yes, I would cut the regulator output line when giving power via VCC.

    Cutting the line of the powerLED (on either side of it, doesn't matter) will make sure that the LED does not drain the battery either. This LED can pull between 5 -15mA depending on the protection resistor that sits in series with it.

    So VCC pin and RAW pin are NOT the same.



  • @GertSanders Thanks for you explanation. I thought vvc on the short end next to rx was going through the voltage regulator just as RAW. Anyhow I have already de-soldered the LED's and are powering through vcc next to A3. Apparently my voltage regulators are bad so I'll cut the lines and give it a try and hope power consumption stays low.



  • I've used the Vcc library to read the battery level without voltage divider or any other external components. Is this not a reliable way to measure?



  • I'll answer myself - no, the Vcc lib is not realiable 🙂 I had a sensor that died yesterday and it reported 100% battery until the end...


  • Hero Member

    @maghac The Vcc library is reliable. It uses the internal 1.1 v reference of the MCU to measure the voltage on the Vcc pin. If your sensor keeps reporting 100% I guess you either power the arduino through a regulator (or the raw pin) or missed something in the Vcc initialisation/ calibration.



  • @AWI It's possible that I missed something in the code. I am powering the arduino directly on VCC though and I'm not using a regulator.

    Will have another look tonight.



  • Do you think that the use of a piezo electric switch is possible ?
    I found one that deliver 24v and 0,2A... The goal would be to create wireless switch...


  • Hero Member

    @aclertant Interesting idea... Energy harvesting with piezo-electric components is certainly possible. From MySensors point of view the energy (very very little) has to be stored and boosted to power the radio and mcu for message processing. There are a few examples of "harvesting" remotes (i.e. Philips HUE) but I am not sure if these use a piezo element.



  • I removed the both the LED and the Voltage Regulator of an Arduino pro min 3.3v . The simple sketch on it's own works fine. However when I connect an NRF24L01 it does not communicate back to the gateway.. 😞


  • Mod

    @aclertant
    If you look at enocean products there are already commercial energy harversting switches in case you don't find a way to make it.



  • @gohan yes it's exactly what I'd like to do 😉

    I should forget to use an arduino in fact... just send one command using... a pic ? or something else...

    The enocean switch is really cool, but quiet expensive 😞


  • Mod

    Like all commercial products they cost because they have been developed, tested and produced. So it's up to you if you want to spend time tinkering or go with an already working solution 🙂



  • @gohan @AWI
    we need something like this but for NRF24L01 module.
    https://github.com/SmingHub/Sming
    Do you think that possibly exist or there is a huge problem ? Like no eeprom or something like that ?


  • Mod

    You see, enocean protocol has been developed from the start to be used with devices that use energy harvesting, so you can't think to use general purpose HW (like esp8266, FRF24, Arduino boards) that is not optimized very low power consumption (look at all the mods required to make a mini pro last months on battery with a reed switch and a nrf24 module); with piezo-electric components the amount of energy is really really tiny so you need super optimized HW to work with that.
    The link you posted is about something that works on a ESP8266 but that works over wifi, that is for sure not the best energy efficient system.


  • Hardware Contributor

    There is a much more efficient way (and cost-less) to measure VBATT :
    https://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
    It doesn't need any external resistor, so there will be no current flowing even when the Atmega is asleep.


  • Hero Member

    @napo7 This has been mentioned in this topic. @Yveaux Vcc library is the easiest way to handle this.


  • Hardware Contributor

    @AWI Ahh Sorry ! Didn't seen the comment !
    I thought it was never mentioned since the how-to still refers to resistor divider method (which is, IMO a bad method since it will draw current...)
    I'll have a look at Yveaux's lib.



  • I have used resistor ( 470K+1M ) to measure the voltage on a 5 minute interval. The Soil sensor is out in the garden where the container housing the arduino pro min gets exposed to sun. The voltage reading is high during 1 PM to 4 PM, when its under the sun. I am not sure if this is because of the heat.

    0_1488370532353_Voltage Graph.JPG

    The code is given below. Please note I multiply my actual voltage with calibration variable. however during the high voltage time the calibration variable does not seem to work.

    • Battery powers the soil sensor.
    • The voltage regulator has been removed.
    • MCU powered using vcc pin.
    //#define MY_DEBUG
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_BAUD_RATE 38400
    #define MY_RADIO_NRF24
    #define VIEW_READING
    
    #include <MySensors.h>
    #include <SPI.h>
    #include <math.h>
    
    
    #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
    #define N_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
    #define NUM_READS 10
    #define CHILD_ID_MOISTURE 0
    #define CHILD_ID_BATTERY 1
    #define SLEEP_TIME 300000//10000 // Sleep time between reads (in milliseconds), was 10000
    #define STABILIZATION_TIME 500 // Let the sensor stabilize before reading default BOD settings
    #define VOLTAGE_PIN A0
    
    
    int index;
    long buffer[NUM_READS];
    const long Known_Resistor = 4700;
    
    /// @brief Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs)
    typedef struct {
      int moisture; //!< Moisture
      long resistance; //!< Resistance
    } values;
    
    
    MyMessage soil_msg(CHILD_ID_MOISTURE, V_LEVEL);
    MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);
    
    
    void presentation() {
      sendSketchInfo("Soil Moisture", "2.0");
      present(CHILD_ID_MOISTURE, S_MOISTURE);
      present(CHILD_ID_BATTERY, S_MULTIMETER);
    }
    
    
    void setup() {
      pinMode(6, OUTPUT);
      pinMode(7, OUTPUT);
      digitalWrite(6, LOW);
      digitalWrite(7, LOW);
    }
    
    
    
    
    void loop() {
      //float dryLevel = readNoMoisture();
      long moistureLevel = readAggSoilMoisture();
    
      //float coeff = 100.00 / float(dryLevel);
      float voltage = readVoltage() * 1.57368; 
    
      float batteryPcnt = voltage / 3.3 * 100;
    
    #ifdef VIEW_READING
      Serial.print("--Voltage:"); Serial.println(voltage);
      Serial.print("--Battery %:"); Serial.println(batteryPcnt);
      Serial.print("--Soil Sensor value:"); Serial.println(moistureLevel );
    #endif
    
      send(soil_msg.set(moistureLevel, 1));
      sendBatteryLevel(batteryPcnt);
      send(voltage_msg.set(voltage, 3), 1);
    
    
    
      sleep(SLEEP_TIME);
    }
    
    float readVoltage() {
      analogReference(INTERNAL);
      fakeRead(VOLTAGE_PIN);
      int sensorValue = analogRead(VOLTAGE_PIN);
      float voltage = sensorValue * 0.003363075;
      analogReference(DEFAULT);
      fakeRead(VOLTAGE_PIN);
      return voltage;
    
    }
    
    void fakeRead(int pin) {
      for (int counter = 0; counter < 5; counter++) {
        analogRead(pin);
        delay(STABILIZATION_TIME);
      }
    }
    
    
    // Averaging algorithm
    void addReading(long resistance)
    {
      buffer[index] = resistance;
      index++;
      if (index >= NUM_READS) {
        index = 0;
      }
    }
    
    long average()
    {
      long sum = 0;
      for (int i = 0; i < NUM_READS; i++) {
        sum += buffer[i];
      }
      return (long)(sum / NUM_READS);
    }
    
    int readAggSoilMoisture()
    {
    
      measureRawSoilMoisture(6, 7, A1);
      long read1 = average();
    
      measureRawSoilMoisture(7, 6, A2);
      long read2 = average();
      long sensor1 = (read1 + read2) / 2;
      return int( ((sensor1 / (float)Known_Resistor) * 100.00));
    }
    
    
    
    void measureRawSoilMoisture (int phase_b, int phase_a, int analog_input)
    {
      // read sensor, filter, and calculate resistance value
      // Noise filter: median filter
    
      for (int i = 0; i < NUM_READS; i++) {
    
        // Read 1 pair of voltage values
        digitalWrite(phase_a, HIGH);                 // set the voltage supply on
        delayMicroseconds(25);
        int supplyVoltage = analogRead(analog_input);   // read the supply voltage
        delayMicroseconds(25);
        digitalWrite(phase_a, LOW);                  // set the voltage supply off
        delay(1);
    
        digitalWrite(phase_b, HIGH);                 // set the voltage supply on
        delayMicroseconds(25);
        int sensorVoltage = analogRead(analog_input);   // read the sensor voltage
        delayMicroseconds(25);
        digitalWrite(phase_b, LOW);                  // set the voltage supply off
    
        // Calculate resistance
        // the 0.5 add-term is used to round to the nearest integer
        // Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
        long resistance = abs(Known_Resistor * (supplyVoltage - sensorVoltage ) / sensorVoltage) ;
    
      
        delay(1);
        delay(STABILIZATION_TIME);
        addReading(resistance);
     
      }
    
    }
    
    
    
    


  • Using voltage divider still might be necessary if you don't have battery directly connected to the MCU VCC, for example using step-up/down regulator to power the MCU. In this case you still can use a voltage divider and have a P+N Mosfet to control the current going through the voltage divider, so no leak to ground.

    In practical terms you basically use another GPIO to enable or disable it the Mosfet when needed. I saw that on the Whisper Node board I'm using and seems to be effective (reference: https://bitbucket.org/talk2/whisper-node-avr#markdown-header-voltage-monitor)... In any case using high value resistors (over 100K) will reduce any current draw. Finally a small capacitor can be used to stabilize the voltage.



  • I have a DHT11 + NRF24L01 + Pro Mini 3.3v 8Mhz
    All is working fine when on usb cable.. but it fails when connected to 2x 1.5 AA batteries..
    what could be wrong ?


  • Mod

    Dht 11 operating voltage is 3.3 to 5v, so 2 AA batteries are not enough. Better look at other more reliable sensors that can operate at lower voltages



  • I did a test with a variable power supply , and I can confirm that the pro mini does weird stuff at smaller then 3v, but it works at 3.3v.. I have now also ordered those 3.3v up-boosters (because I already bought the battery mounts) mentioned here.



  • What would be the best approach if I wanted a battery powered node using a 5V sensor? I want to build a secret knock sensor but I want it to be battery powered.

    I was thinking about using 3xAA batteries (3x1.6 would be 4.8V max) and a 5V step-up converter and then power the sensor and the arduino (on the raw pin, since it's a 3.3V arduino). The radio would be powered from the VCC on the arduino.


  • Mod

    I think that isn't going to be a very efficient way. Are you sure there isn't any 3.3V sensor you could use?



  • @maghac

    Consider this option:
    Use 2 AA batteries.
    Change the BOD on the arduino to something lower than the 2.8V default.
    Power everything from the batteries except the sensor.
    Use the 5V step-up converter only for the sensor.



  • @ileneken3 Good idea, i think I'll design it that way. I also had a closer look on eBay and found another sensor that runs on 3.3v.



  • "Disconnect or desolder the 3.3 VDC regulator because it is not needed." => Why it isn't needed? I assume it is needed when connecting a sensor that requires 3.3V (e.g. HTU21d or even the RFM69)? I assume the assumption made here is that you're using 2 AA 1.5V batteries? I'm using 3 LR44 (3x1.55V) so I suppose I still need the regulator.


  • Mod

    @mpp the line below the one you are quoting says "Power the device with two AA batteries connected in series". So yes, your assumption that 2 AA batteries is used is correct.



  • Hi, i've got a barebones arduino circuit set up with a dht22 sensor. It's powered off 2 aa batteries. All works well with the two batteries even when they are running at about 3.0 volts combined (it would probably run at lower voltages but batteries haven't gone down that far yet). If i power directly from usb with my ftdi interface all works. However, when i add the 3.3v step up, the radio doesn't get a response from the nrf gateway anymore. I have a 4.7u capacitor on the nrf. The gateway is receiving some data but not all as i can see "mygateway1-out/0/255/0/0/18 2.1.1" in my mqtt broker every couple of seconds but the mysensors client never seems to get fully initialised. I've tried two or three of the step ups and checked the voltage with a multimeter and i'm getting circa 3.3v. One thing i did notice is that when i swapped in one of my 3 dht22's it worked initially but then stopped, the other two wouldn't (all work without the step up). I think this is a bit of a red herring but putting in here for information. Any thoughts?



  • share your schematic. from what you are describing it seems like the step up converter is not able to provide enough current.


  • Mod

    could be also noise generated from the booster, in fact you could run the NRF24 directly from battery since it can still work down to 1.9V



  • but the dht22 would not work, it requires at least 3.3v (however i succesuffly used it with 3V). I think that NRF has some decoupling capacitors onboard, so unless the boost converter design is not totaly wrong it shouldn't be a problem. schematic would be helpful.



  • @rozpruwacz 0_1498042165035_Mini Arduino Sensor W FTDI Double Sided Ordered_bb.jpg

    Here is my breadboard design, i'm afraid the schematic in fritzing isn't really in a state to post here. It's unreadable. The resistors shown in the diagram wouldn't have the correct values i used. The values i used are from the arduino site for creating an arduino. The ones shown are used for the sake of creating a pcb. The DHT22 goes on the 4 pin header, the NRF goes on the 8 pin header.



  • @FatBeard I should point out that the step up was an afterthought and it was the ground and vout of the stepup were connected directly to the power rail along the bottom. It powers the whole circuit.



  • @FatBeard said in 💬 Battery Powered Sensors:

    goes on

    ok, but what about boost converter ? as i understand the problem is when You use the boost converter ? is it some kind of module ? or your design ?



  • @rozpruwacz Ya, it's a module and it's the 3.3v step up module recommended on this page. Thanks for your help by the way



  • @FatBeard said in 💬 Battery Powered Sensors:

    recommended

    which one ? could you paste a link ?





  • unless the dht22 pull up resistor is not to low, which would cause large current when the data pin is held low, i don;t see any mistakes ... are you able to measure the current drawn from the boost converter ?



  • @rozpruwacz Both resistors are 10k. I can measure the amps, i'll do this tonight and get back to you. thanks again



  • one other thought, what type of nrf module You use in your gateway ? from my expirience i know that the PA+LNA modules are very sensitive to noise. Do you have other sensors in your network that are affected ? maybe it is the problem with the gateway nrf module and not the sensors nfr module ? You can try to shield the modules somehow.


  • Hardware Contributor

    Try adding a 0,1uF cheramic capacitor on the booster from Out to Gnd. Also external capacitor on the radio is crusial!



  • The NRF is a NRF24L01+ without the antenna on the gateeway and all of the sensors. I'm going to try the capacitor idea now. I'll try measuring current shortly too.



  • I made progress. So the capacitor idea doesn't seem to work. However rozpruwacz suggested measuring the current which I did. I disconnected the negative wire and put my multimeter in between the negative from the battery and the ground pin on the step up module. I measured 72ma when the device powers up, then it runs at .16ma when in sleep mode. But here is the thing, in this configuration, mysensors worked as a thermometer. I got humidity and temperature readings from the sensor to my mqtt server through the gateway over the nrfs. When I removed the multimeter again from the equation it stopped working. Surely this would hint at what the problem is for someone more familiar with electronics than myself?



  • Any thoughts on what I could do to fix the issue permanently without the multimeter?


  • Mod

    why don't you connect the radio directly to battery?



  • this is very wierd ... maybe try another nrf module ? also try what gohan suggested. But it should work as it is. I have similar configuration, but the boost converter has pass trough mode, so i can switch it on and off from the atmega and have no problems with that setup, no matter if the boost converter is os or off, the communication is ok. Can you upload a picture of your setup ? maybe we see something you didn't realize is important to say.


  • Hardware Contributor

    @FatBeard - Could it be that the step up booster are making alot of noice. When you connect your multimeter it works in some way like a filter and reduces the noice?

    I have made alot of these sensors and i strongly suggest you connect i like @gohan suggest - radio directly to the bat.

    This is how i have created my EasyPCB and with alot of trial and error - radio + booster isnt a good idea.

    https://www.openhardware.io/view/4/EasyNewbie-PCB-for-MySensors



  • @sundberg84 Ok, thanks guys. I'll try your suggestions out tonight. I would have preferred to do it through the step up to get the most out of the batteries but maybe this is not practical.


  • Mod

    maybe you could use the booster, but you would need to analyze the kind of noise and build a specific filter for that.



  • @FatBeard boost converter has limited efficiency, this means that it eat the battery power. Nrf can work down to 1.9 V so it is not so obvious that the booster actually will make your sensor live longer.


  • Mod

    It can help drainig the battery to even lower voltages, but the tradeoff is lower efficiency and noise


  • Hardware Contributor

    Search the forum. Booster VS not booster - its always a tradeoff.
    Some people go further and skip booster and lower BOD on the arduino instead.
    I would say 1.9V is pretty good... I have had my longest temp sensor now since the beginning (Almost 3 years) and changed 2xAA once. If you are using sleep and measure once you will get away with a long lasting sensor.


  • Mod

    At 0.95V per cell, an alkaline battery has delivered about 99% of its total capacity. Look at a discharge curve like this:
    0_1498143146830_IMG_1741.PNG

    So if the booster has more than 1% overhead, using a booster to power nrf24 and atmega328 will give worse battery performance than running directly off 2 alkaline batteries.



  • Thats for the response guys. So tried connecting directly to the battery. I cut the trace on the pcb, then soldered a wire directly from the vIn to the positive leg of the 4.7u cap that leads to the radio. No joy though. Still same problem.

    To the point about disabling bod, i have done that already, my issue with that setup though is that my dht22 seems to give inconsistent measurements when operating. It would give readings a degree apart every 5 minutes when the temperature would have remained a lot more stable. I assumed this to be due to the 2x batteries running at just a tad below 3v, while the dht22 is rated at 3.3v. Hence i thought the stepup would fix this problem.


  • Mod

    Get a more serious sensor like sht31 or si7021 😉


  • Hardware Contributor

    @FatBeard - I use this setup, run the radio from the battery and arduino and dht22 from booster without problems. It should work. About the readings... as gohan said... the dht22 is known for... not that good quality



  • I've actually ordered some bme280s which I'm waiting on, I think they will work down to low voltages too. So hopefully that will sort this issue by not needing the step up.

    I would like to still to be able to figure out this problem though. I tried removing the dht22 completely to see if it was contributing to the problem, no luck. I've tried various capacitors over the ground and vout to no avail.

    How would I go about analysing noise on the circuit?



  • @sundberg84 I'll also take a look at your pcb. I was trying to achieve a pcb like that. A generic one to use with various sensors. I Was hoping to do it myself for the sake of learning. But I may have change tact.


  • Hardware Contributor

    @FatBeard - I would start by changing the Nrf24l01+ - there are some really bad ones out there.
    Second I would rewire everyhing from/to the radio. After that I would rewire everything else and maybe change the arduino. As you said, removing all sensors and try debug in "bare minimun" (Power, Arudino and Radio) is a good idea. You can create a fake motion sensor sketch for example sending 1/0 with a 10 sec delay in between just to test the setup (without sensor attached).


  • Hardware Contributor

    I'm using an approach read some thread bottom. Direct 2XAA to the Atmega barebone @8Mhz with BOD disabled and step up (not very efficient) to port the voltage of the batteries to a 3.3v for the DHT22. I'm reading the voltage with "secret voltmeter" example posted (https://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/ )

    The Atmega sleep for 10 minutes, take reading and if different sends to the gateway (as your sketches). I want shutdown the booster, as it is not very efficient. I did have a debate on arduino forum: https://forum.arduino.cc/index.php?topic=488315.0

    Basically, a part that I don't absolutely "cut the ground" with a NPN, otherwise I could have issues with different potential grounds etc etc, I don't know anymore if my design is secure and can works.

    For all friday, saturday and sunday my node was power on without issues, but I don't want my house burning for a short circuit from batteries...

    This is base fritzing draw:

    alt text

    And this is the real pictures of node:

    alt text

    And final this is the not-so-efficient booster: https://www.amazon.it/gp/product/B06XHJCHX6/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1 and regulated exit to 3.3v.

    (Voltage goes down from friday to today from 2.74 to 2.63).

    Am I wrong with my connections? Thank you to all....



  • @sineverba I gave up trying to cross connect power controls directly and went for bistable telecoms relays, 100mW fire 30ms max latched stay open until you reverse signals from + & - pins. Works a treat, powered only for duration of latch....pity the sensor it controlled was shit, but hey ho....small steps


  • Hardware Contributor

    @zboblamont

    A bistable could cost more than entire node 😄

    But it could be an idea... instead of NPN. But remain my doubt.... for the moment, with node powered in this mode..... Am I in danger of burn battery / node / house? 😞


  • Mod

    If I were you I'd go for an I2C sensor that could also work at low voltage, this way you could also power the sensor via a digital pin and turn it off before entering the sleep function to save extra power.


  • Hardware Contributor

    @gohan

    What sensor do you use? Seems interesting the Bosch BM280 that has also the pressure but seems it wants the 3.3v...


  • Mod

    I am testing SHT31 and BME280 but it is on the power hungry side and temperature is reading +0.5/+0.7 °C more, while the SHT31 is +-0.2°C



  • @sineverba I think the small latching Axicom 3v signal relay I used was around 2 euro, but they were sold in packs of 10, so expensive if no use for the other 9 🙂 The objective was low current low voltage short power duration, I found that the enable pin for the booster used more power when system was sleeping... switching the 5v booster by relay ensured no current leakage, 2 pins from the Arduino to control it, 30mA for 30ms to open, same to close it, as and when required to power the 5v ultrasonic... Arduino had it's own battery pack and booster but spends most of it's time in deep sleep so power consumption is peanuts.


  • Hardware Contributor

    @zboblamont
    Do you want post your schema // picture of your node? Thank you in advance 🙂



  • @sineverba None are finished, as waiting on the replacement ultrasonic to arrive. I posted photos of the original booster and JSN board at https://forum.mysensors.org/topic/4810/distance-sensor/43
    when seeking opinions on potential noise issues. The tiny relay is also shown there.
    The external nodes will all be Whisper Nodes (essentially a customised pro-mini), 2 have RTCs on board to take ultrasonic readings on two tanks, the rest respond to events.


  • Hardware Contributor

    Atmega on breadboard, 8MHZ, no Xtal, BOD disabled.

    I have a question and an issue.

    This is exactly the breadboard (missing only the NRF, connected direct to the battery and not to the stepup and NRF has the 4.7mF capacitor and works very well on every other node).

    alt text

    This is my sketch > https://pastebin.com/raw/6Kxm238q

    1. Can I remove one of the two 104 capacitors? Or I need both? Atmega feeded directly from battery, I remember.

    2. With this setup, the node *doesn't trasmit and if I connect the serial (via FTDI232) Atmega floods it with strange characters and doesn't stop (I did try all the bauds, but default is 115200). The leds on FTDI232 blinks continuosly, 1 blink 1 strange chars printed on monitor serial.

    2a) If I remove totally the ground between rails or remove totally the booster (so, for breviti, I don't give anymore power to the DHT22) the node trasmits very well (of course only the voltage) and serial works

    2b) If I feed the node with 3.3v (e.g. from the FTDI232) the node transmits and serial is all ok.

    At the end, seems that DHT 22 (rated for max 6V) doesn't want the 4.92V OR Atmega crash with this voltage.

    PS I have the stepup to 5V 'case I did wrong the order..... 🙂

    Thank you to all!


  • Mod

    @sineverba your wiring looks quite odd. Especially compared to https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/overview
    Where did you find the wiring guide?


  • Hardware Contributor

    @mfalkvidd do u mean the DHT? I can assire you that resistor is between data and VCC 😉 maybe semms strange for need of arrangement on frtzing....... in effect at 3,3 it works and it works in another noce (at 3,3) i would understand because at 5v it doesnt works and serial is flooded ...... I could also post a picture of real breadboard 🙂

    Thank you!


  • Mod

    @sineverba yes, you're right. It looks a bit different but the connections are equivalent. Sorry for the confusion.


  • Hardware Contributor

    @mfalkvidd no problem ! I can understand the difficult to understand schemas of other people 😉 do you nave btw somw idea for my issues and queation (if I can remove a caos, for example).... Thank you


  • Mod

    @sineverba sorry, I don't. I have no experience with the bare atmega.



  • How about using rechargeable batteries instead of alkaline? They would be 1.2V instead of 1.5. vmax would be 2.8V ?


  • Hardware Contributor

    @Oliviakrk
    I use recheargeable. At full charge both are 2.74...
    DHT22 at 2.74 doesn't read. It is rated for 3.3v - 6v



  • @sineverba
    Yes, so a stepup before DHT 22 is required. And it works...But..I have issues with measuring battery level.

    int batteryPcnt = sensorValue / 10;
    

    Always gives something around 74-77%. Even if I use batteries straight of the charger (Panasonic/Sanyo Enelops, which are 1,3 -1,4V when taken of the charger)



  • There is minor correction in the battery level measurement calculation. It should be 1.1 * (1 * 10^6 + 470 * 10^3) / (470 * 10^3) = 3.44V


  • Mod

    @Oliviakrk Look in comments in the code

    // 3.44/1023 = Volts per bit = 0.003363075
    

    if your batteries put out a total of 2.8V the voltage divider is set to use a Vmax of 3.44V (that suits the alkaline batteries), that is probably why. If you want you could change the voltage divider for a lower Vmax



  • @sundberg84 To give you an update. I've changed from a dht22 sensor to a bme280 i2c sensor. The sensor is running off a4 and 5 and power is gotten directory from 2aa batteries. My original problem is gone in that it's working fine as a mysensors node. My issue though is when in sleep mode, i'm running at 1ma, when i would expect to be down in the low ua area. Any thoughts? The code i'm using is based off of this thread: https://forum.mysensors.org/topic/3816/bme280-temp-humidity-pressure-sensor/5


  • Hardware Contributor

    @FatBeard I looked at the datasheet and you should expect only a couple of uA... not mA. I would first disconnect the sensor and make sure it's not the other setup that draws power. Did you remove led and volt. reg.?

    If the sensor still draws power I would either try another one or power it from a digital pin and turn power off before sleep with LOW.



  • @sundberg84 Thanks Sunberg, pretty much sorted now. It was the sensor, i changed libraries and it solved my problem. In theory i was using the forced read with both, but only the sparkfun bme280 library worked in reducing the power. To the best of my knowledge, i'm now running at 6ua most of the time with a 60ms (i timed from beginning to end of the loop method) jump to 1amp every three minutes to get a reading. It's difficult for me to capture the amps properly as when i put my uni-t digital multimeter into the circuit, the nrf stops working. Any thoughts on why that might be?


  • Mod

    1 Amp is definitely a lot. I think it can't be a correct reading


  • Hardware Contributor

    @FatBeard - as @gohan said - 1A can not be correct. Something is wrong.
    If the radio does not work, and the sensors if fishy... I would disconnect it and run the radio/atmega only and fake a sensor value to send and see what happens.


Log in to reply
 

Suggested Topics

19
Online

11.2k
Users

11.1k
Topics

112.5k
Posts