๐Ÿ’ฌ Battery Powered Sensors



  • @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.



  • @sundberg84 @gohan. Apologies , that's a typo on my part. It jumps to 1ma do 60ms from 6ua. Which I'm happy with I think. My question was more how I can measure it properly. The multimeter seems to be effecting the circuit.


  • Hardware Contributor

    This post is deleted!

  • Mod

    @FatBeard actually what you really need to measure is the sleep current as it is the state where the node will be spending all of its time. Where are you connecting the multimeter for measuring current?



  • @gohan between positive end of one of the two aa batteries and where it enters circuit. If I start off by having battery connected, the release it slowly with the multimeter attached and without breaking circuit I get my 6ua. However after the timer runs out and the radio comes back on I'm stuck at 1ma. The radio at that point doesn't want to work and it doesn't return to 6ua


  • Mod

    @FatBeard the burden voltage of your multimeter might be too large, which would reduce the voltage to the atmega below its working level.
    You're measuring current, so the meter must be in series with the power supply. It's not clear to me how you can remove the multimeter without breaking power to the atmega.


  • Mod

    You could try to add a booster to power the Arduino or change the multimeter ๐Ÿ˜€


  • Hardware Contributor

    Hi to all!
    I have a issue reading of voltage on pin A0 of an ATMEGA 328 barebone mounted on a breadboard.

    This is the image

    alt text

    The purple pin goes to A0.

    The rail on the bottom coming direct from batteries, with a multimeter I read that they have 2.73V. On monitor serial, % of battery is about 1-2% and voltage reading is about... 0.004 and floating about 0.004 - 0.010 ....

    Can I imagine an issue with pin A0 itself? I have about 10 Atmega spares ๐Ÿ™‚ and I will test another one... but thinking about this issue.

    I did try also removing the 0.1uF cap, without any change.

    The reading function is the same of this sketch.

    Thank you very much!



  • Hi guys, if your Arduino is equipped with an ATMega 328P then it could go down to 1.8V at lower frequencies like 1MHz (8MHz internal RC oscillator / 8 by default).
    Or you can use the internal low power 128KHz RC osc eventually ...
    It means you could power both the Arduino and the radio directly from the battery string and consume even less current.
    Just wondering if anyone tried these cases so far?


  • Mod

    There have been some users that went that way but personally I am preferring to use a single AA LiFePo4 battery with standard voltages and clocks



  • I am a newbie and have some thoughts about the battery level that I did not find in this forum.
    The 8MHz 3.3V Arduino Pro Mini can handle down to roughly 2.8V.
    If I have understood the calculations in the sketch correctly then the analog value of A0 is 1023 at 3.44V and 0 at 0V.
    This means that at 2.8V the value is about 830 = 83% and under this, the Arduino stops working. Is this right?
    If this is correct, I wonder if someone has changed the calculation in the sketch so that the battery percentage becomes 0 at 2.8V?
    This would mean that the battery percentage becomes a more real value on the battery level.


  • Mod

    It's a simple percentage calculation that you can do it in the code



  • @gohan Thanks for your reply, you can show me how the code should look.


  • Mod

    void batM() //The battery calculations
    {
      delay(500);
      // Battery monitoring reading
      int sensorValue = analogRead(BATTERY_SENSE_PIN);
      delay(500);
    
      // Calculate the battery in %
      float Vbat = sensorValue * VBAT_PER_BITS;
      send(msgVBat.set(Vbat, 3));
      int batteryPcnt = static_cast<int>(((Vbat - VMIN) / (VMAX - VMIN))*100.);
      Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");
    
      // Add it to array so we get an average of 3 (3x20min)
      batArray[batLoop] = batteryPcnt;
    
      if (batLoop > 2) {
        batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]);
        batteryPcnt = batteryPcnt / 3;
    
        if (batteryPcnt > 100) {
          batteryPcnt = 100;
        }
    
        Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
        sendBatteryLevel(batteryPcnt);
        batLoop = 0;
      }
      else
      {
        batLoop++;
      }
    }
    

    This is the function I use, I just define the VMAX and VMIN in the beginning of sketch. The function calculates an average of 3 measurements before sending the value


  • Hardware Contributor

    @gohan said in ๐Ÿ’ฌ Battery Powered Sensors:
    Hello, i didn't know why you add 4 measures (batarray) and you divide by 3 the sum .


  • Mod

    @tonnerre33 good catch! maybe it's an optimistic value ๐Ÿ™‚


  • Mod

    I actually didn't look much at battery percentage, but I prefer looking at the voltage that gives me a better idea of how the battery is doing since I can log the values on a graph



  • @magnusf It is important to know that the battery voltage is non linear in respect to how much juice left. Just search for "battery discharge curve" to see how much it depends on battery type, current and temperature. So calculating the percentage is actually meaningless unless You exactly know how much current your board sucks at what temperature and what type of battery You use.



  • Instead of using "DC-DC Step Up Boost Module 5V" for a HBS, wouldnยดt it make sense to just use 2 AA batteries for the nano and 2 additional batteries (i.e. four in a row) for the HBS?


  • Mod

    What's the hbs?



  • Same as on the motion example - HC-SR501, 4.5V- 12V.



  • Maybe only a third Battery, as the HBS only needs 4.5V..



  • To answer my own question: yes, it seems to work. Searched around and read a while, found this:
    https://forum.mysensors.org/topic/6511/hc-sr501-3-3v-randomly-sends-tripped-when-radio-is-on/22
    Best addition imho ,no need for step up / down. ๐Ÿ˜„



  • Hi,
    I'm trying to build a Soil Moisture sensor with NiMh battery and solar panel as in another post. I use a stepup converter to 3.3V connected on the VCC of a pro-mini 3.3V. The sensor seems working when connected to FTDI USB device, ut once I remove the power from FTDI, no more communication. I measured the voltage on the output of the stepup which indicates 3.26V. Is it norml or a defective step-up ? And should I remove the regulator of the pro-mini as suggested above or not ? (in article above, it states the regulator is not necessary, but it doesn't say if pro-mini would still work if regulator remains there).
    Thanks for your support


  • Mod

    @ricorico94 what does the debug output from the node and the gateway say?

    What regulator are you using? Most regulators produce power that is too noisy to be usable by the nrf24 radio (you didn't state which radio you're using so I'm just guessing here, based on the most common problems). What capacitor(s) are you using after the regulator?

    See https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help/ for the most common problems and how to diagnose them.

    Also see https://www.mysensors.org/build/battery for more information about battery powered sensors.



  • Hi,
    As regulator I use a stepup like that one:
    https://fr.aliexpress.com/item/DC-DC-0-8-3-3V-to-3-3V-Step-Up-Boost-Power-Module-For-Arduino/32819660926.html?spm=a2g0s.9042311.0.0.27426c37HEbdcz

    I use a NRF24L01 as radio module following the connection guidelines from Mysensors. I did not add any capacitor to 3.3 and ground of the NRF24L01.
    I connected the vO of the stepup to the VCC (the VCC between RX and GRD and not the RAW) of the arduino pro mini 3.3V as indicated in this post:https://forum.mysensors.org/topic/4045/solar-powered-soil-moisture-sensor
    I use indeed a similar lamp with its small NiMh battery (1.2v) and its solar panel.
    The NRF24L01 is connected on GRD (between RST and RAW) and on VCC (between A3 and RST). I hadn't put any capacitor.
    I tried following your advice to add a 0.1uF ceramic capcitor between VCC (the one between RX and GRD) of pro mini and its ground, but apparently, I face same issue.
    (I did not solder the capcitor yet, I only connected through the pins I usually use for the FTDI)

    16 MCO:BGN:INIT NODE,CP=RNNNA---,VER=2.2.0
    26 TSM:INIT
    28 TSF:WUR:MS=0
    34 TSM:INIT:TSP OK
    36 TSF:SID:OK,ID=4
    38 TSM:FPAR
    75 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2084 !TSM:FPAR:NO REPLY
    2086 TSM:FPAR
    2123 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4130 !TSM:FPAR:NO REPLY
    4132 TSM:FPAR
    4169 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6176 !TSM:FPAR:NO REPLY
    6178 TSM:FPAR
    6215 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8222 !TSM:FPAR:FAIL
    8224 TSM:FAIL:CNT=1
    8226 TSM:FAIL:DIS
    8228 TSF:TDI:TSL
    18229 TSM:FAIL:RE-INIT
    18231 TSM:INIT
    18237 TSM:INIT:TSP OK
    18241 TSF:SID:OK,ID=4
    18243 TSM:FPAR
    18280 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    20289 !TSM:FPAR:NO REPLY
    20291 TSM:FPAR
    20328 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    22337 !TSM:FPAR:NO REPLY
    22339 TSM:FPAR
    22376 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    24385 !TSM:FPAR:NO REPLY
    24387 TSM:FPAR
    24424 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    26433 !TSM:FPAR:FAIL
    26435 TSM:FAIL:CNT=2
    26437 TSM:FAIL:DIS
    26439 TSF:TDI:TSL
    36442 TSM:FAIL:RE-INIT
    36444 TSM:INIT
    36450 TSM:INIT:TSP OK
    36454 TSF:SID:OK,ID=4
    36456 TSM:FPAR
    36493 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    38502 !TSM:FPAR:NO REPLY
    38504 TSM:FPAR
    38541 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    40550 !TSM:FPAR:NO REPLY
    40552 TSM:FPAR
    40589 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    42598 !TSM:FPAR:NO REPLY
    42600 TSM:FPAR
    42637 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    44646 !TSM:FPAR:FAIL
    44648 TSM:FAIL:CNT=3
    44650 TSM:FAIL:DIS
    44652 TSF:TDI:TSL
    54657 TSM:FAIL:RE-INIT
    54659 TSM:INIT
    54665 TSM:INIT:TSP OK
    54669 TSF:SID:OK,ID=4
    54671 TSM:FPAR
    54708 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    56717 !TSM:FPAR:NO REPLY
    56719 TSM:FPAR
    56756 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    57493 TSF:MSG:READ,0-0-4,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    57499 TSF:MSG:FPAR OK,ID=0,D=1
    58765 TSM:FPAR:OK
    58767 TSM:ID
    58767 TSM:ID:OK
    58769 TSM:UPL
    58806 !TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1
    60815 TSM:UPL
    60852 !TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=1,st=NACK:1
    62861 TSM:UPL
    62863 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=2,st=OK:1
    64872 TSM:UPL
    64909 !TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1
    66918 !TSM:UPL:FAIL
    66920 TSM:FPAR
    66957 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=1,st=OK:
    68964 !TSM:FPAR:NO REPLY
    68966 TSM:FPAR
    69003 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    71012 !TSM:FPAR:NO REPLY
    71014 TSM:FPAR
    71051 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    73060 !TSM:FPAR:NO REPLY
    73062 TSM:FPAR
    73099 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    75108 !TSM:FPAR:FAIL
    75110 TSM:FAIL:CNT=4
    75112 TSM:FAIL:DIS
    75114 TSF:TDI:TSL
    

    Apparently, it sends correctly packets but can't receive any ACK or message from the gateway.
    I got this log by connecting a FTDI adapter with only the RX/TX cables. If ever I connect also the GRD and 3.3V of the FTDI, then I get no error message at all (even without the capacitor) and Domoticz receives all updates (and also sends as I use Domoticz to send customized sleep duration to the sensor).

    Should I try adding both the 0.1uF to VCC/GRD of arduino and also a 4.7uF to the 3.3/GRD of the NRF24 as suggested in the "Connect the Radio" page ?
    Any idea ?
    br,
    Rico


Log in to reply
 

Suggested Topics

64
Online

11.4k
Users

11.1k
Topics

112.7k
Posts