Skip to content

Commit

Permalink
Merge pull request #42 from nicholaswilde/add-bq27074-ina260
Browse files Browse the repository at this point in the history
Add bq24074 ina260
  • Loading branch information
nicholaswilde authored Mar 22, 2022
2 parents db4e9c9 + 757c3b7 commit 73aff54
Show file tree
Hide file tree
Showing 22 changed files with 591 additions and 333 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ jobs:
strategy:
matrix:
arduino-platform:
- "esp8266:esp8266"
- "esp32:esp32"
include:
- arduino-platform: "esp8266:esp8266"
fqbn: "esp8266:esp8266:huzzah"
- arduino-platform: "esp32:esp32"
fqbn: "esp32:esp32:featheresp32"

Expand Down
22 changes: 12 additions & 10 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

// Change these parameters
#define BAUD_RATE 115200 // baud rate used for Serial console
#define R1 1000000 // resistor 1 on the voltage divider (Ω)
#define R2 220000 // resistor 2 on the voltage divider (Ω)

// ThingSpeak fields
#define FIELD_NO_PERCENTAGE 1 // field number of battery percentage
#define FIELD_NO_LEVEL 2 // field number of battery level
#define FIELD_NO_CURRENT 2 // field number of battery level
#define FIELD_NO_VOLTAGE 3 // field number of battery voltage
#define FIELD_NO_POWER 4 // field number of battery power

#define SLEEP_TIME 15 // the time the Feather goes into a deep sleep (m)
#define VOLTAGE_MAX 4.2 // max voltage of lipo battery (V)
#define VOLTAGE_MIN 2.64 // min voltage of lipo battery (V)

#if defined(ESP8266)
#define BUTTON_A 2
#define ANALOG_PIN_NO A0 // analog pin number
#elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
#define BUTTON_A 15
#define ANALOG_PIN_NO A2 // analog pin number
#endif
// Pins
#define BUTTON_A 15
#define BUTTON_POWERBOOST 33

const int batteryCapacity = 3000; // Battery capacity in mAh
const int batteryQuantity = 2; // Quantity of batteries

// clear the channel if it's a new day.
bool doClear = false;
Expand Down Expand Up @@ -47,6 +48,7 @@ const char * myUserAPIKey = SECRET_USER_APIKEY;

unsigned int localPort = 8888; // local port to listen for UDP packets
const int ledPin = LED_BUILTIN;
const long interval = 1; // interval for updating discharge loop

#define DELAY_WIFI 5 // delay between samples (s)
#define DELAY_SCREEN1 2 // delay after screen 1 (s)
Expand Down
40 changes: 13 additions & 27 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

A solar battery charger to charge lithium ion (li-ion) 18650, 9V, and coin batteries and Ni-MH AA and AAA batteries.

<img src="./assets/images/charger.jpg" width="480">
<img src="./assets/images/panel-front.jpg" width="480">

<img src="./assets/images/front.jpg" width="480">

<img src="./assets/images/back.jpg" width="480">
<img src="./assets/images/wires.jpg" width="480">

<img src="./assets/images/thingspeak.png" width="480">

Expand All @@ -22,31 +22,13 @@ Create [`secrets.h`](https://nicholaswilde.io/solar-battery-charger/configuratio

```shell
(
sudo apt install python3-serial screen
brew install arduino-cli
arduino-cli config init
arduino-cli config add board_manager.additional_urls http://arduino.esp8266.com/stable/package_esp8266com_index.json
arduino-cli config add board_manager.additional_urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-cli core update-index
arduino-cli core install esp8266:esp8266 esp32:esp32
arduino-cli lib install ThingSpeak "Adafruit SH110X" Timezone
)
```

### ESP8266

```shell
(
arduino-cli compile -b esp8266:esp8266:huzzah .
arduino-cli upload -b esp8266:esp8266:huzzah . -p /dev/ttyUSB0 .
screen /dev/ttyUSB0 115200
)
```

### ESP32

```shell
(
sudo apt install python3-serial
arduino-cli core install esp32:esp32
arduino-cli lib install ThingSpeak "Adafruit SH110X" "Adafruit INA260 Library" Timezone
arduino-cli compile -b esp32:esp32:featheresp32 .
arduino-cli upload -b esp32:esp32:featheresp32 . -p /dev/ttyUSB0 .
screen /dev/ttyUSB0 115200
Expand All @@ -58,15 +40,17 @@ Create [`secrets.h`](https://nicholaswilde.io/solar-battery-charger/configuratio
Mode: recharge

```shell
Mode: recharge
SSID: MySSID
Connecting.........
Connected!
IP: 192.168.1.77
Hostname: Feather
Battery:
Level: 745
Percentage: 90%
Voltage: 4.04V
Voltage: 4.04 V
Current: 700 mA
Power: 2.6 W
Channel:
Number: 1642208
Status: success
Expand All @@ -76,10 +60,12 @@ Sleep time: 15m
Mode: discharge

```shell
Mode: discharge
Battery:
Level: 745
Percentage: 90%
Voltage: 4.04V
Voltage: 4.04 V
Current: 700 mA
Power: 2.6 W
```

---
Expand Down
24 changes: 15 additions & 9 deletions docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
- Monitor the rate of charging via an online IOT service such as
[ThingSpeak][1] or [Adafruit IO][2].
- Learn about solar cells, panels, li-ion, and [Ni-MH batteries][3].
- Visually monitor the battery voltage, current, and capacity during discharge.
- Turn on and off the Powerboost 1000 Basic using button `A` on the OLED.
- Display the current voltage, current, power, and percentage by pressing the
`A` button on the OLED without uploading to an online service when the
Feather is in a deep sleep.

## :frame_with_picture: Background

Expand All @@ -30,23 +35,24 @@ batteries and then use the charged li-ion batteries to charge Ni-MH batteries
via existing USB chargers. The li-ion batteries are to be disconnectable from
the solar panel to make more portable to recharge other devices and batteries.

Monitoring is handled by an Adafruit Feather Huzzah (Feather) that has built in
Monitoring is handled by an Adafruit Feather HUZZAH32 (Feather) that has built in
wifi support which makes it easy to monitor remotely as well as collect data.
The board will monitor when the li-ion battery is charging and when charging is
complete. It can also send notifications when the charge is complete via
ThingSpeak and IFTTT.

## :raised_hand: Current Limitations

- As of the time of this writing, charging the li-ion batteries and using the
USB port need to happen separately. Therefore, charging the li-ion batteries
and charging other things with the USB port can't happen at the same time.
- The Feather is being powered by the charging li-ion batteries and so the
Feather won't turn on unless there is enough juice in the batteries.
- The Feather is draining the charging li-ion batteries as they are charging.
- The voltage divider used to measure the battery voltage is constantly
draining the battery.
- The Feather is using some power during the charging of the li-ion batteries.
- The Feather turns off during high current discharge. See [issue #39][4].
- I have had issues with two bq24074 chargers where it would suddenly stop
charting the batteries. The voltage reading of the `LIPO` pin would
oscillate between 0 and 3V. I suspect the IC was damaged due to a too
high of voltage being output by the panel. This still needs to be
verified.

[1]: https://thingspeak.com/
[2]: https://io.adafruit.com/
[3]: https://en.wikipedia.org/wiki/Nickel%E2%80%93metal_hydride_battery
[4]: https://github.com/nicholaswilde/solar-battery-charger/issues/39
[5]: https://github.com/nicholaswilde/solar-battery-charger/issues/40
Binary file added docs/assets/images/battery-front.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/battery-left.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/battery-right.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/bms-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/bms-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/images/circuit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/images/front.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/images/panel-back.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/wires.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 73aff54

Please sign in to comment.