# Battery Shield - Battery does not seem to be charging

**URL:** <https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406>\
**Category:** Hardware\
**Created:** [February 19, 2017, 5:36pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406 "2017-02-19T17:36:06Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 19, 2017, 5:36pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/1 "2017-02-19T17:36:06Z")

</div>

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?

 ![](https://us1.discourse-cdn.com/flex026/uploads/particle/original/2X/2/2a578566e1ada8de81024ff45d1039b2bbd687f9.PNG)

---

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 19, 2017, 8:26pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/2 "2017-02-19T20:26:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [February 19, 2017, 8:47pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/3 "2017-02-19T20:47:42Z")

</div>

Is it the Particle Power Shield or something else?

What does your code look like?

---

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 19, 2017, 8:53pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/4 "2017-02-19T20:53:08Z")

</div>

It is the SparkFun Photon Battery Shield

> **[SparkFun Photon Battery Shield - DEV-13626 - SparkFun Electronics](https://www.sparkfun.com/products/13626)**
>
> The SparkFun Photon Battery Shield provides you with an easy way to power your Photon module with a Lithium Polymer (LiPo) battery. Not only can the Batter

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);
  }
}
```

---

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 20, 2017, 2:17am UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/5 "2017-02-20T02:17:24Z")

</div>

Any ideas guys?

Much appreciated

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [February 20, 2017, 9:42am UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/6 "2017-02-20T09:42:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 21, 2017, 8:12pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/7 "2017-02-21T20:12:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [February 21, 2017, 8:13pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/8 "2017-02-21T20:13:32Z")

</div>

> [@whip](#):
>
> If I can grab a few Particle power shields, do you think I will have better luck? Ability to charge via solar etc?

You should have better luck with the Particle Power shield.

---

<div class="post-metadata">

**Author:** ![Thepointof](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@Thepointof](https://community.particle.io/u/Thepointof)\
**Post date:** [February 21, 2017, 9:11pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/9 "2017-02-21T21:11:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [February 21, 2017, 9:13pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/10 "2017-02-21T21:13:40Z")

</div>

> [@Thepointof](#):
>
> 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.

> [@Any way to determine if my battery is being charged?](https://community.particle.io/t/any-way-to-determine-if-my-battery-is-being-charged/29400/3):
>
> Thanks for the quick response. Are you suggesting just reading voltage and soc for an upward change, and assume it’s being charged? I thought of this as well but was hoping there was a better solution. When I plug the photons micro-b usb to my laptop, a red LED on the battery shield lights to indicate a charge source has been connected. I was really looking forward to somehow tap into whatever logic is determining this.

---

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 21, 2017, 10:10pm UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/11 "2017-02-21T22:10:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 22, 2017, 2:36am UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/12 "2017-02-22T02:36:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Thepointof](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@Thepointof](https://community.particle.io/u/Thepointof)\
**Post date:** [February 22, 2017, 6:10am UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/13 "2017-02-22T06:10:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![whip](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@whip](https://community.particle.io/u/whip)\
**Post date:** [February 22, 2017, 6:11am UTC](https://community.particle.io/t/battery-shield-battery-does-not-seem-to-be-charging/29406/14 "2017-02-22T06:11:44Z")

</div>

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