particle-iot / PowerShield

The Power Shield library provides functions to use the on-board MAX17043 fuel gauge via I2C
Other
12 stars 5 forks source link

getSoC() returns "data":"255.996094" (voltage returns 5) - once it does, keeps at it. #8

Open ventz opened 8 years ago

ventz commented 8 years ago

{"name":"# Voltage ==>","data":"5.000000","ttl":"60","published_at":"2016-08-30T03:41:16.879Z","coreid":"removed"} {"name":"# Charge ==>","data":"255.996094","ttl":"60","published_at":"2016-08-30T03:41:16.900Z","coreid":"removed"}

This is while charging from a laptop USB port.

Once this happens, it keeps going.

ventz commented 8 years ago

It seems that even after a battery unplug/replug, re-insert into the USB power source, and even a photon reset -- it still ends up showing these values.

UPDATE: This seems to be related to another item using the headers. I was guessing that it's voltage related, but so far it doesn't seem to be. Using it with a range finder (echo/ping module - HC-SR04) and whenever it is plugged in, I get these values.

UPDATE2: Guessed that D0 was reserved. Confirmed that D0 and D1 are not to be used by any non I2C devices (with different addresses). D3 should also be reserved for alert.

kennethlimcp commented 8 years ago

@ventz does it happen with only the PowerShield and Photon?

ventz commented 8 years ago

@kennethlimcp - It seems to be related to anything being plugged in. After a bit of trial and error -- seems like pins D0 and D1 are actually used (probably for the power gauge meter would be my guess?).

The issue is that when using D2+, it's still not powering anything, even when I just need 3v. And this is when I have the microUSB adapter plugged in and not just from the LiPo power.

technobly commented 8 years ago

@ventz two things, do not use D0, D1, D3 as they are used by the power shield https://github.com/spark/PowerShield/blob/master/firmware/PowerShield.cpp#L11-L23

Notice this new note (perhaps it affects your case?):

NOTE: There is a know issue on the v2.1.0 of the Power Shield where the shield will fail to power up the Photon when the battery is inserted for the first time or reinserted after a long time (>60mins). The user will need to unplug and plug the battery back again for the shield to power up. The issue arises by the fact that on startup, the battery charger confuses the Photon booting up to there being a short circuit and powers off to save the device. If you are feeling adventurous, you can fix this issue by soldering a 10nF capacitor across the DPPM pin and GND. This delays the short-circuit protection at startup and lets the Photon bootup without any issues. https://docs.particle.io/datasheets/particle-shields/#power-shield

technobly commented 8 years ago

@ventz to clarify... you can use D0, D1 if they are for I2C with a device at a different address other than 0x36. D3 should be avoided, but can be used to detect the alert interrupt output from the power shield.

ventz commented 8 years ago

@technobly - Thanks (good to confirm D0, D1. I thought D3 was alert only if you solder the bridge -- but either way I'll skip that too).

Yea, I saw the note last night when I started searching about why it was not powering up. Honestly, it really frustrated me when I saw it.

What is the recommended way to attach (without soldering anything) female jumpers to the headers sticking out of the power shield? My usual female jumpers are either loose, or if you turn them by 90*, they will barely stay on -- and I am not sure if they are making contact. I was planning on using aligator clips just to test. (Assuming there is a better way to plug external things like motion sensors/range finders/etc. I could not find any info online about this)

technobly commented 8 years ago

The gold plated holes on the sides are meant for soldering. There is really no good way to plug any kind of jumper into them. You can solder the extra row of female headers which should allow you to plug the power shield into a breadboard, and also you can then plug wires into the headers.

ventz commented 8 years ago

@technobly, @kennethlimcp - noticed every once in a while the values I get back are: stateOfCharge: 172.332 and cellVoltage: 4.647

Any idea why this is happening? It makes sense why the stateOfCharge will be slightly over 100 (101, 102, maybe even 103), but not more than that.

technobly commented 8 years ago

4.2V should be your batteries MAX voltage. Please put a volt meter on the battery and see what it really is... > 4.2 is dangerous and can cause damage to the battery and possibly 🔥

I'm not familiar with how the Photon power shield limits the max charging voltage, @mohitbhoite would you please comment on this?

technobly commented 8 years ago

every once in a while

@ventz Just noticed you said this... what are the readings on average? This could possibly be noise creeping into the readings.

ventz commented 8 years ago

@technobly I am remote right now so I can't toggle the power/unplug the battery, but just re-flashed with some debug code, and getting:

{"name":"Debug","data":"173.121094 | 4.649500","ttl":"60","published_at":"2016-09-07T19:59:05.779Z","coreid":"removed"} {"name":"Debug","data":"173.121094 | 4.648300","ttl":"60","published_at":"2016-09-07T19:59:07.722Z","coreid":"removed"} {"name":"Debug","data":"173.121094 | 4.648300","ttl":"60","published_at":"2016-09-07T19:59:09.722Z","coreid":"removed"} {"name":"Debug","data":"173.121094 | 4.649500","ttl":"60","published_at":"2016-09-07T19:59:11.745Z","coreid":"removed"} {"name":"Debug","data":"173.121094 | 4.648300","ttl":"60","published_at":"2016-09-07T19:59:13.743Z","coreid":"removed"} {"name":"Debug","data":"173.121094 | 4.649500","ttl":"60","published_at":"2016-09-07T19:59:15.729Z","coreid":"removed"}

ventz commented 8 years ago

Here's the results from my other one (the original which I had been testing all of this here, and which was at one point last night drained to ~75% at which point it shutdown...assuming due to the voltage actually being drained):

{"name":"Debug","data":"99.875000 | 4.092700","ttl":"60","published_at":"2016-09-07T20:02:29.828Z","coreid":"removed"} {"name":"Debug","data":"99.875000 | 4.092700","ttl":"60","published_at":"2016-09-07T20:02:31.843Z","coreid":"removed"} {"name":"Debug","data":"99.875000 | 4.092700","ttl":"60","published_at":"2016-09-07T20:02:35.361Z","coreid":"removed"} {"name":"Debug","data":"99.875000 | 4.092700","ttl":"60","published_at":"2016-09-07T20:02:35.888Z","coreid":"removed"}

Something definitely seems off about these :(

technobly commented 8 years ago

@ventz yeah that doesn't look like noise... what is the environment like where it's at? Can it survive a fire? Charging LiPo's unattended is typically not recommended unless you have contained the battery in something flame retardant. What is providing the charging voltage and what's your code look like?

It should not also be shutting down at 75%. It could dropout somewhere between 10% and 0% though.

ventz commented 8 years ago

@technobly - The photon is plugged into the particle powershield, which has the battery connected. The powershield is plugged in via usb into a usb-brick style charger (same size as iphone ones).

It's sitting in a remote house currently, so I truly hope it's not on fire.

I am assuming by design the point (other than having portable power) is to be able to sustain power failures -- that is, if the main AC cuts out, it will cut over to the powershield/battery. When the power comes back up, it will resume and top off the battery. I would hope this is not a problem since this is the only reason I bought a bunch of these. Are you saying this can't/should not be done unattended?

The part from the code that's relevant to the power:

// This #include statement was automatically added by the Particle IDE.
#include "PowerShield/PowerShield.h"

// Power Shield
PowerShield batteryMonitor;
float lastCharge;

void setup() {
    // BATTERY SETUP
    // This essentially starts the I2C bus
    batteryMonitor.begin(); 

    // This sets up the fuel gauge
    batteryMonitor.quickStart();

    // Wait for it to settle down
    delay(1000);

    // Sync the last charge to the current stateOfCharge
    lastCharge = batteryMonitor.getSoC();

   //pin setup for relay

   // functions for toggling relays and such, + reading status variables
}

void loop() {
 // Read the volatge of the LiPo
    float cellVoltage = batteryMonitor.getVCell();
    // Read the State of Charge of the LiPo
    float stateOfCharge = batteryMonitor.getSoC();

    if(stateOfCharge < lastCharge) {
        lastCharge = stateOfCharge;
        Particle.publish("Power", "Battery - Draining: "+String(stateOfCharge,3)+" | "+String(cellVoltage,3), 60, PRIVATE);
        delay(10000);
        //System.sleep(SLEEP_MODE_DEEP, 600);
    }
    else if(stateOfCharge > lastCharge) {
        lastCharge = stateOfCharge;
        Particle.publish("Power", "AC - Charging: "+String(stateOfCharge,3)+" | "+String(cellVoltage,3), 60, PRIVATE);
        delay(30000);
    }
    else {
        //Publish Cell Voltage to cloud
        //Spark.publish("# Voltage #", String(cellVoltage));

        //Publish State of Charge to Cloud
        ////Spark.publish("# Charge #", String(stateOfCharge));
        //delay(3000);
    }
    Particle.publish("Debug", (String)stateOfCharge+" | "+(String)cellVoltage, 60, PRIVATE);
    delay(2000);
}

About the second one: I was testing with the 2nd one yesterday, and I was plugged into a power strip that was turned off, so eventually it shut down. I am assuming it's because it had a motion sensor and a ping sensor -- I think eventually the voltage dropped too low (a 5v booster would solve this I think).

ventz commented 8 years ago

@technobly @mohitbhoite - it looks like there's definitely something going on with the library:

Here is the status once I unplugged the AC (via USB) power -- it signals every time the charge is lower (or higher) than the "last seen". Notice the jump from 158.410 to 88.211 -- that was in 30 seconds with nothing using it other than the photon itself and few times toggling a pin from HIGH->LOW->HIGH:

Battery - Draining: 169.008 | 4.002
Battery - Draining: 168.375 | 4.001
Battery - Draining: 167.742 | 4.001
Battery - Draining: 167.270 | 4.001
Battery - Draining: 166.637 | 4.001
Battery - Draining: 166.160 | 4.001
Battery - Draining: 165.527 | 4.001
Battery - Draining: 165.055 | 4.001
Battery - Draining: 164.422 | 4.000
Battery - Draining: 163.945 | 4.000
Battery - Draining: 163.313 | 4.000
Battery - Draining: 162.840 | 4.000
Battery - Draining: 162.207 | 3.999
Battery - Draining: 161.730 | 3.999
Battery - Draining: 161.258 | 3.999
Battery - Draining: 160.625 | 3.999
Battery - Draining: 160.148 | 3.999
Battery - Draining: 159.676 | 3.999
Battery - Draining: 159.043 | 3.999
Battery - Draining: 158.410 | 3.999
# NOTE: notice this change. This was < 30 seconds apart
Battery - Draining: 88.211 | 3.993
Battery - Draining: 88.066 | 3.989
Battery - Draining: 87.926 | 3.987
Battery - Draining: 87.781 | 3.984
MadMike92 commented 4 years ago

Old thread, but I'm seeing this as well on a Photon w battery shield. Using the battery that Particle ships w the powershield. Flashed the powershield.ino demo, have the Photon plugged into USB port on laptop; seeing numbers like:

4.71 | 171.54 4.71 | 171.54 4.71 | 171.54 4.71 | 171.54 4.72 | 171.7 4.72 | 171.7 4.71 | 171.7 4.72 | 171.7 4.72 | 171.7 4.72 | 171.7 4.72 | 171.86 4.72 | 171.86 4.72 | 171.86 4.72 | 171.86 4.72 | 171.86