Erratic battery reading when powering via RAW pin



  • I have pro mini 3.3 running with motion/battery sketch. I am using voltage divider and have a capacitor across R2.
    I am using a single cell 18650 for power with 5V step up regulator connected to Raw pin.
    The battery readings are pretty erratic even if remove power from the PIR sensor. Now and again it reports the correct voltage. I have tried the 18650 (4.1V) without the regulator direct to RAW....still the same

    Now the strange bit. If I remove battery power (just leaving battery connected to voltage divider) and power via 3.3VFTDI the readings stabilize and I get readings correct within 0.02V

    Maybe a noisy regulator on the pro mini?

    Maybe I should be stepping down to 3.3V rather than up to 5V. I was doing this in order to provide 5V to the PIR.



  • Can you attach some schematics?


  • Mod

    @grumpazoid how much does the voltage reading vary when it is erratic? 1V? 0.1V? What does it vary between? An unloaded battery will report higher voltage than a battery that is being used, maybe that's what you're observing?



  • Ok here is my feeble attempt at showing the circuit. I have omitted sensor and radio data cables.

    Not too sure what I did but it seems to be stabalizing.

    my screenshot/ image link
    my screenshot/ image link


  • Mod

    @grumpazoid a small drop (maybe 0.1V) can be expected when drawing power from the battery, but the dips down to less than 3.5 volts are strange, unless the battery is broken.

    Is the node sleeping? If so, could you add a reading of the voltage just after waking up? Similar to what I do in this sketch. This would help determine if the drop happens when power is drawn from the battery.



  • I had tried moving the battery reading part around in the sketch but it didn't seem to make much of a difference. It's strange that it is only when powered via RAW. I used my PSU instead of a battery with the same result.
    I'll maybe try another arduino first just in case.



  • @grumpazoid I would check on the contacts. 1V drop with the very low current draw of these components can only be

    a) depleted battery
    b) defective booster
    c) poor contact somewhere.

    Try to change the pins that you use on the protoboard, or check the solder joints.



  • Thanks to all your replies I think I've got it fixed.

    I tried another pro mini....still eratic.
    I then used that second pro mini and built an identical node on another breadboard. Result was perfect readings.
    I then rewired the problematic one and gave it another battery for good measure. It is now more than acceptable although still not as smooth a graph as the second node.
    At the moment, running direct from 18650 and not boosting to 5V does not seem to be an issue for the HC-SR501's.
    Maybe I will run into problems as the battery voltage lowers.
    Node2
    alt text
    Node1
    alt text



  • Maybe this is due to a timing issue inside the ATmega328 architecture, after wakeup from sleep, then try to wait 500 micro-sec before you are measuring the voltage

    https://www.sciencetronics.com/greenphotons/?p=1521


  • Mod



  • @yveaux
    Thanks for pointing at the code, then it should not be a timing issue in the ATmega328 as Mysensors are handling this 🙂



  • Hi, Just a few comments that you may find useful. Because this is a battery powered device, I assume battery life is reasonably important and there are improvements you can make.

    The IR Motion sensor you are using is actually a 3.3 volt device and has a regulator to drop the 5V input to 3.3v, so it's just a waste to use 5V only to drop it to 3.3v. Although I have not measured how much energy the regulator itself uses, but it may be more that the Motion Sensor itself which only draws 50 micro-amp (50 millionth's of an amp). The circuit for that device is available on the internet and you can actually bypass the regulator just by changing how one of the jumpers are setup, i.e. no soldering, or you will find posts here on how to remove the regulator (and a diode). Just look at the circuit, find the regulator and look at how it is connected to one of the jumpers and you should be able to work it out.

    Another option is to try running the motion sensor (as it is) direct from the battery. The regulator is probably an LDO (low drop-out) meaning it will accept an input from 5V down to a little more than about 3.4 volts (as the battery drops).

    If you are not already using sleep mode and interrupts, you should as it's possible to get the average power consumption to not much more than the battery's normal self discharge rate (shelf life). With that particular sensor, you should be able to achieve a fantastic battery life by putting the Arduino and radio to sleep and only waking when the motion sensor activates. You simply need to connect the motion sensor output to the Arduino pin 3 (which is an interrupt pin). There is a good example (with comments) about using interrupts in the MySensors examples folders, it's called something like "Binary Switch Interrupt". (I'm not at a computer with Arduino at the moment)

    A well designed interrupt based node can easily run more than a year on a set of batteries. I have been running a node with Temp, Humidity, Pressure and digital Lux sensor reporting whenever any data changes, or after 5 minutes with no data changes. It's been running two months now and hasn't even dropped one hundredth of a volt, so far so good.

    Good luck!

    Paul



  • @affordabletech Thanks for the advice.
    I have some 3.3V 662K regulators on order. So my plan would be to go from 18650 to regulator and then power everything from that supply.
    I have indeed been running a couple of motion test nodes straight from the battery. I started to get some false activations somewhere around 3.6V
    I had read that the regulator on the HC-SR501 could either be removed or bypassed, and will look into the possibility of doing this with a jumper.
    Yesterday, I removed the LED and regulator from one of my pro minis so hopefully this will reduce power consumption to a minimum.

    I use the sleep statement from the standard motion sketch as follows:

    sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    

    Hopefully that is correct?



  • @grumpazoid yes, you seem to be right on track.

    One other point that may save you some grief, mount the motion sensor away from the RF2401 and gron the voltage dropping device, assuming it's a 'buck regulator' (which is more efficient).

    Both the regular and the RF radio output high frequency noise which can cause false triggers by the notion sensor. But, be warned, distance is a double edge sword, the further away the motion sensor is (longer wires), the more prone it becomes to power supply noise. So just don't place the motion sensor right on top of the radio etc.

    On the positive side, 'electrical noise' can be fixed with a capacitor. Try putting a 47uF capacitor on the motion sensor across the points where the positive and negative power wires connect. (Note the capacitor is polarity sensitive (look for the negative marking). If you still get false triggers, you could try increasing the capacitor to 470uf, but in my opinion, if 47 doesn't work there is another problem somewhere.

    Also, from memory, those sensors need a fairly long warm up period before they stabilize, so you should get your code to ignore any readings initially. I think it's under a minute but do a google search for "HC-SR501 warm-up" to check.

    You can simply sleep(xxx) in the startup loop, or ignore all triggers with a statement like "if (millis() > 30000)". The value returned by the millis() function is the number if milliseconds since startup, so you could only do a 'send' command if the milliseconds are greater then the warm up period.

    Paul



  • @grumpazoid one thing I meant to add..

    The way you propose, using a battery and regulator is the ideal path. Removing the LED is critical as the LED would probably use more power than everything else.

    One thing you may not realise is the Arduino and motion sensor can run on as little as 1.8 volts, providing all regulators are removed and the battery starting voltage is no more than 3.3. If you use an alkaline battery, you can suck on those babies until they reach 1.8 volts, at which time they are pretty much empty. Whereas rechargeable lithium batteries have builtin 'over-discharge' protection which switches off the output a 3.[something] volts.

    I suggest considering 2 by 'AA' cells in a holder, with the Arduino mounted on the back of the holder with double sided sticky tape, or my preference where size is important is to use one CR23 (3 Volt) battery (they are about 2/3 the height of one 'AA' ). Either option should give you over a year between replacement.

    NOTE: On ALL MySensor nodes, make sure the antenna section of the (standard) RF2401 is not directly on top of anything metal. Where possible, let that antenna part overnang the battery pack for example. It's not critical, but could cost you 20% to 25% of your range IMHO, so I try to keep it clear wherever I can.

    I've seen it argued that metal behind the antenna, can act as a 'ground plane' and actually boost range. I'm certainly not a radio expert, but even if that is true, it will make the antenna very directional, meaning signals to/from behind the 'ground plane' will be blocked. All I can say is I haven't had any range problems will any of my nodes, including some in another building.

    Whatever battery arrangement you use, measure the voltage of a fresh set of batteries (in use), and make a note of the voltage when the node dies. This will then give you the useable voltage range which may be for example 1.83v to 3.12v. Once you know the usable range, you can then modify your code to calculate and send a very accurate "Battery Remaining %". In the meantime you can just guess the 'empty' voltage.

    Paul

    p.s. You don't have to wait a year, you can just put in a fairly 'empty' set of batteries just to see the point at which the node dies, if that makes sense.



  • @affordabletech Have been busy soldering today. Used pro mini with regulator and LED removed + HC-SR501 with regulator and diode removed. 18650 cell for power.
    The NRF24 radio us one of the bad ones from with poor range.

    On TX it used about 4mA but only 42uA while sleeping.
    Battery reporting is working well.

    alt text


Log in to reply
 

Suggested Topics

  • 87
  • 5
  • 7
  • 10
  • 3
  • 8

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts