Hooks into the CE pin of TP4056 to add some extra features - overvolt cutoff - overtime cutoff - overtemperature cutoff (by use of MCP9808) - info on little OLED screen - battery presence detection Future features - current detection and cutoff (waiting for INA219 breakout for this) - Runtime configurable parameters by serial - Send stats over serial to desktop application Known flaws - see readme Circuit schematic coming soon (tm), see readme Designed and tested for nucleo F303RE but should be easily adaptable to any board. License: GPL v3
Dependencies: OLED_SSD1306 MCP9808
Diff: main.cpp
- Revision:
- 3:0bad8eec80ee
- Parent:
- 2:18d8f9d3286c
- Child:
- 4:f63aab9fec77
diff -r 18d8f9d3286c -r 0bad8eec80ee main.cpp --- a/main.cpp Mon Aug 24 08:27:27 2020 +0000 +++ b/main.cpp Wed Aug 26 02:21:29 2020 +0000 @@ -12,7 +12,7 @@ #define OLED_SDA I2C_SDA #define OLED_SCL I2C_SCL -#define DS18B20_DATA PB_4 +#define DS18B20_DATA D4 // Blinking rate in milliseconds @@ -211,7 +211,8 @@ while(true) { //First check conditions to see if charging should be enabled or disabled - bool temperature_en = ( ( ds18b20_temperature < MAX_TEMPERATURE ) && ( ds18b20_temperature > MIN_TEMPERATURE ) ); + // bool temperature_en = ( ( ds18b20_temperature < MAX_TEMPERATURE ) && ( ds18b20_temperature > MIN_TEMPERATURE ) ); + bool temperature_en = true; //override as sensor code is bugged bool voltage_en = ( ( bat_voltage_avg < MAX_VOLTAGE ) && ( bat_voltage_avg > MIN_VOLTAGE ) ); bool presence_en = batteryPresenceState; bool charge_time_exceeded = ( (Kernel::get_ms_count() - chargeStartTime ) > MAX_TIME_ms); @@ -236,7 +237,8 @@ } //or if user pushed button else if(buttonPressed) - { + { + enableCharging = false; buttonPressed = false; } }