Battery Shield - Battery does not seem to be charging

I have a Battery shield hooked up to to my Particle Photon. I’m using a 200mAh 1S 3.7v 30C li-polymer battery and my charge source on the photon is my laptop USB.

Every 5 minutes I am taking a lipo voltage and soc reading and printing it out to the serial monitor.

It does not seem to be charging… Ideas?

It’s now been running for 3 hours, and I’m still reading 40.82%

Is it the Particle Power Shield or something else?

What does your code look like?

It is the SparkFun Photon Battery Shield

Here is the code.

#include "SparkFunMAX17043/SparkFunMAX17043.h"

#include "SparkFunMicroOLED/SparkFunMicroOLED.h"
#include "math.h"

#include "DS18.h"

DS18 sensor(D4); // DS18B20 Temperature Sensor
uint8_t addr[8];  // Cached sensor address
bool addressCached;

float minutesToSleep = 5; // Time between readings

MicroOLED oled;

bool useOLED = true;
bool useTempSensor = true;
bool useBattery = true;

/*
*/
void setup() {
  Time.zone(-6);
  Serial.begin(9600);

  pinMode(D7, OUTPUT);

  if (useOLED) {
    setupOLED();
  }

  if (useBattery) {
    lipo.begin();
    lipo.quickStart();
  }
}

/*
*/
void loop() {
  Serial.println(Time.timeStr());

  if (useTempSensor) {
    if (!addressCached) {
      cacheSensorAddress();
    }
    String temp = getTemp(addr);
    Serial.println("Temperature: [" + temp + "F.]" );

    if (useOLED){
      postTempToOLED(temp);
    }
  }

  delay(3000);

  if (useBattery) {
    float voltage = lipo.getVoltage();
    float soc = lipo.getSOC();
    Serial.println("Battery: [" + String(voltage, 2) + "v.] [" + String(soc, 2 ) + "%]" );

    if (useOLED){
      postBatteryStats(voltage, soc);
    }
  }

  //System.sleep(D0, RISING, 60);
  delay(minutesToSleep * 60 * 1000);
}

/*
*/
void setupOLED() {
  oled.begin();     // Initialize the OLED
  oled.clear(ALL);  // Clear the display's internal memory
  oled.display();   // Display what's in the buffer (splashscreen)
  delay(1000);      // Delay 1000 ms
  oled.clear(PAGE); // Clear the buffer.

  randomSeed(analogRead(A0) + analogRead(A1));
}

/*
*/
void postTempToOLED(String temp)
{
    oled.clear(PAGE);
    oled.setCursor(0, 0);
    oled.setFontType(0);
    oled.print("Pool Temp:");

    oled.setCursor(0, 12);
    oled.setFontType(2);
    oled.print(temp);

    oled.display();
}

/*
*/
void postBatteryStats(float voltage, float soc) {
  oled.clear(PAGE);
  oled.setCursor(0, 0);
  oled.setFontType(0);
  oled.print("Battery:");

  oled.setCursor(0, 10);
  oled.setFontType(1);
  oled.print(String(voltage, 1) + "v");

  oled.setCursor(0, 24);
  oled.setFontType(1);
  oled.print(String(soc, 1) + "%");

  oled.display();
}

/*
From the DS18.h readme:
 "Since it performs a 1-Wire search each time if you only have 1 sensor it's normal for this function (read()) to return `false` every other time."
 "If you have more than 1 sensor, check [`addr()`](#addr) to see which sensor was just read."
 "Read a specific sensor, skiping the search. You could set up your code to `read()` once in `setup()`, save the `addr` and in `loop` always read this sensor only."
*/
void cacheSensorAddress() {
  sensor.read();
  sensor.addr(addr);
  String address = String(addr[0]) + ":" + String(addr[1]) + ":" + String(addr[2]) + ":" + String(addr[3]) + ":" + String(addr[4]) + ":" + String(addr[5]) + ":" + String(addr[6]) + ":" + String(addr[7]);

  if (sensor.read(addr)) {
    Particle.publish("Temperature Sensor Address", address, PRIVATE);
    addressCached = true;
  }
  else if (sensor.crcError()) {
    Particle.publish("Temperature Sensor", "CRC Error", PRIVATE);
    addressCached = false;
  }
  else {
    addressCached = false;
  }
}

/*
According to the DS18.h readme, the default conversation time for the reading is 1000 ms
*/
String getTemp(uint8_t address[8]) {
  if (sensor.read(address)){
    float temp = sensor.fahrenheit();

    return String(temp, 1);
  }
  else
    return "Error";
}

/*
*/
void blinkLED(int pin, int times) {
  for (int i=0; i<times; i++){
    digitalWrite(pin, HIGH);
    delay(100);
    digitalWrite(pin, LOW);
    delay(100);
  }
}

Any ideas guys?

Much appreciated

I could have helped with the Particle Power Shield, but I don’t own a SparkFun Battery Shield - sorry.

Ok I understand. I submitted the same question on the Sparkfun forum, but there does not seem to be alot of activity there, so I’m not sure what I will get out of that.

If I can grab a few Particle power shields, do you think I will have better luck? Ability to charge via solar etc?

1 Like

You should have better luck with the Particle Power shield.

I have had good luck with the battery shield so far and even have a solar panel hooked up now.

The first thing that surprised me is the battery power is not going down either!
OK you do have sleep commands which will save power. Which makes me wonder which firmware you are using - that might be a source of the problem. Although I have found sleep does not work well in 0.6.0, but deep sleep is fine.

The key parts of your code seem correct, maybe go for simples and strip out all the code except for the battery stuff. Don’t include any sleep function and watch to see if the power drops.

Do you know the battery is good? Do you know the charge cable is good? A red LED should come on when the battery is charging.

In another thread @whip mentions that the red LED comes on.

Thepointof,

Just to make sure…You mentioned you are having good luck. Are you speaking of the Sparkfun Battery Shield or the Particle Power Shield. I just want to make sure as I was inadvertently/unknowingly interchanging the two.

Well good news.

I had ordered a spare sparkfun battery shield and i tried it out today. I charged my battery with an external charger and hooked up the 2nd battery shield with the charged battery. Everything seems to be working now. I see the battery discharging when running only battery alone, and then when I plug into my laptop, I’m getting an increasing value in my soc. It’s increasing about .15% every 5 seconds. Still one odd thing is though, that I’, seeing the soc go over 100% when i thought it was only a 0-100 value.

I do appreciate everyone’s thoughts/ideas. This is proving to be a good forum.

I am using the sparkfun board too.
Glad the replacement works.
Mine has also had a soc >100 when fully charged
If you decide to connect a solar panel you can’t get it wrong because there is a protective diode.

Thanks for the reply. Looking forward to hooking it all up.