Skip to content

Commit

Permalink
New Pairing circumvention without requring the BMS serial.
Browse files Browse the repository at this point in the history
  • Loading branch information
lolwheel committed Jun 20, 2022
1 parent c3f298a commit 0225fc9
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 77 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/lolwheel/Owie)

This project is inspired by the JWFFM modchip and unlocks battery expansion possibilities on otherwise
locked Onewheels.
This project is unlocks battery expansion possibilities on otherwise
locked Onewheels, adds WiFi-based monitoring of various battery health signals such as individual cell voltages, current, etc.

# Disclaimer

Expand Down Expand Up @@ -33,37 +33,37 @@ This is a hobby projet for its contributors and comes with absolutely no guarant
## Flashing Owie for the first time

1. Download the latest [`firmware.bin`](https://github.com/lolwheel/Owie/releases/latest/download/firmware.bin).
1. Use the ESP WebTools page provided [here](https://ow-breaker.github.io/). \[DEPRECATED instruction, being replaced\]
1. Follow the instructions on that page to flash the firmware.
1. Verify the flash success: When the chip is on, you should see
2. Follow the instruction on the ESP WebTools page [here](https://ow-breaker.github.io/). Note that firmware flashed through this website might be older than the latest official release. To make sure that you're running the latest version, follow the instructions in the "Updating Owie" section below after the initial flash.
3. Verify the flash success: When the chip is on, you should see
a WiFi network called `Owie-XXXX`. Connecting to it should send you
straight to the status page of the Owie board. Don't worry about the data because the board isn't hooked up yet.

## Installation:
## Installation into the board:

NEW: Follow this step-by-step installation video made by one of the community members - https://www.youtube.com/watch?v=HhKdwnYUbA0

Or follow these instructions below:

1. Install Owie fimrware onto your Wemos D1 mini as instructed above.
1. Disassemble your board and open the battery enclosure.
1. Disconnect all wires from BMS, strictly in the following order:
2. NEW: I highly recommend physically removing the reset button from the chip with pliers to exclude possibility of it accidentally getting pressed while inside of your Onewheel.
3. Disassemble your board and open the battery enclosure.
4. Disconnect all wires from BMS, strictly in the following order:
1. Battery balance lead - the leftmost connector (24 wires) on the BMS.
1. Battery main lead - an XT60 connector on the rightmost side of the BMS.
1. All the other wires to the BMS, the order here doesn't matter.
1. Prepare your Wemos D1 Mini and BMS:
2. Battery main lead - an XT60 connector on the rightmost side of the BMS.
3. All the other wires to the BMS, the order here doesn't matter.
5. Prepare your Wemos D1 Mini and BMS:
1. Tin 4 consecutive pins on Wemos D1 Mini marked as **TX, RX, D1, D2** as well as **5v, GND** pins.
1. Solder a small wire **on the top of the board** connecting the pin marked as **TX** to the pin marked as **D2**
1. Solder power pickup wires to the BMS. The JWFFM chip installation video demonstrates this well - [Youtube: Power pickup from BMS](https://youtu.be/kSWicH8hUFo?t=1028)
1. Cut the **WHITE** and **GREEN** wires from the three-wire connector around 3/4 of an inch from the connector. Wrap the Green wire **leading to the BMS**(the 3/4 inch stub) in an isolating wire as we won't be needing it. Tin the other three wire endings, you'll be soldering those to the Wemos D1 Mini.
2. Solder a small wire **on the top of the board** connecting the pin marked as **TX** to the pin marked as **D2**
3. Solder power pickup wires to the BMS. The JWFFM chip installation video demonstrates this well - [Youtube: Power pickup from BMS](https://youtu.be/kSWicH8hUFo?t=1028)
4. Cut the **WHITE** and **GREEN** wires from the three-wire connector around 3/4 of an inch from the connector. Wrap the Green wire **leading to the BMS**(the 3/4 inch stub) in an isolating wire as we won't be needing it. Tin the other three wire endings, you'll be soldering those to the Wemos D1 Mini.
Again, JWFFM install video has a good demonstration of this: [Youtube: Cutting GREEN and WHITE wires](https://youtu.be/kSWicH8hUFo?t=453)
1. Connecting wires to your Wemos D1 Mini. I found it much easier to solder these to the bottom of the board:
6. Connecting wires to your Wemos D1 Mini. I found it much easier to solder these to the bottom of the board:
1. Connect the **GROUND** wire from the **BMS**, the middle wire out of the BMS 5 pin connector to **GND** on Wemos D1.
1. Connect the **5v** wire, the other one from BMS to the **5v** on the board.
1. Connect the **WHITE** wire **RUNNING TO THE MAIN BOARD** to the **TX** pin on the board.
1. Connect the **GREEN** wire **RUNNING TO THE MAIN BOARD** to the **D1** pin on the board.
1. Connect the **WHITE** stubby wire running to the **BMS** to the **RX** pin on the board.
1. Cover the bottom of the Wemos D1 mini with either fish tape or isolating tape so that non of the exposed soldering joints have any chance of contacting anything on the BMS. I also put a bunch of tape on the top of the board, just in case.
2. Connect the **5v** wire, the other one from BMS to the **5v** on the board.
3. Connect the **WHITE** wire **RUNNING TO THE MAIN BOARD** to the **TX** pin on the board.
4. Connect the **GREEN** wire **RUNNING TO THE MAIN BOARD** to the **D1** pin on the board.
5. Connect the **WHITE** stubby wire running to the **BMS** to the **RX** pin on the board.
6. Cover the bottom of the Wemos D1 mini with either fish tape or isolating tape so that non of the exposed soldering joints have any chance of contacting anything on the BMS. I also put a bunch of tape on the top of the board, just in case.

DONE!

Expand Down
13 changes: 3 additions & 10 deletions data/settings.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
<form method="post" action="/settings">
<fieldset>
<legend>BMS pairing:</legend>
<p>Serial of the currently hooked up BMS:</p>
<p><b>%BMS_CURRENT_SERIAL%</b></p>
<hr>
<p>Override the BMS serial:<input placeholder="Last 6 digits of the BMS serial"
value="%BMS_SERIAL_OVERRIDE%" name="bs"></p>
</fieldset>
<fieldset>
<legend>WiFi options:</legend>
<p>Owie WiFi network name override:<br><input placeholder="WiFi network name" value="%AP_SELF_NAME%" name="apselfname"></p>
<p>Owie WiFi network name override:<br><input placeholder="WiFi network name" value="%AP_SELF_NAME%"
name="apselfname"></p>
<p>Password:<br><input placeholder="Between 8 and 31 characters" value="%AP_PASSWORD%" name="pw"></p>
<p>Power (dBm):<br>
<select value="%WIFI_POWER%" name="wifipower">
Expand Down Expand Up @@ -39,7 +32,7 @@
return;
}
btn.removeAttribute('style');

function updateButton() {
const isEnabled = !!btn.dataset.enabled;
btn.removeAttribute("disabled");
Expand Down
4 changes: 2 additions & 2 deletions lib/bms/charging_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "packet.h"

ChargingTracker::ChargingTracker(BmsRelay* relay, uint32_t makeNewPointAfterMah, const std::function<void(ChargingTracker*)>& newPointCallback)
ChargingTracker::ChargingTracker(BmsRelay* relay, int32_t makeNewPointAfterMah, const std::function<void(ChargingTracker*)>& newPointCallback)
: makePointAfterMah_(makeNewPointAfterMah), newPointCallback_(newPointCallback) {
// This takes advantage of the fact that the current packets are forwarded iff
// the board is charging
Expand All @@ -14,7 +14,7 @@ ChargingTracker::ChargingTracker(BmsRelay* relay, uint32_t makeNewPointAfterMah,
if (relay->getTotalVoltageMillivolts() < 1) {
return;
}
const uint32_t totalChargedMah = relay->getRegeneratedChargeMah();
const int32_t totalChargedMah = relay->getRegeneratedChargeMah();

// Initialize the first data point to absolute value of the voltage and
// whatever mah we've recorded already.
Expand Down
8 changes: 4 additions & 4 deletions lib/bms/charging_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

class ChargingTracker {
public:
ChargingTracker(BmsRelay* relay, uint32_t makeNewPointAfterMah, const std::function<void(ChargingTracker*)>& newPointCallback);
ChargingTracker(BmsRelay* relay, int32_t makeNewPointAfterMah, const std::function<void(ChargingTracker*)>& newPointCallback);

typedef struct {
uint32_t millivolts;
uint32_t totalMah;
int32_t millivolts;
int32_t totalMah;
} ChargingPoint_t;

const std::vector<ChargingPoint_t>& getChargingPoints() { return chargingPoints_;}
uint8_t getTrackedCellIndex() { return tracked_cell_index_;}

private:
std::vector<ChargingPoint_t> chargingPoints_;
const uint32_t makePointAfterMah_;
const int32_t makePointAfterMah_;
std::function<void(ChargingTracker*)> newPointCallback_;
uint8_t tracked_cell_index_ = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions proto/settings.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ syntax = "proto3";
message ChargingDataMsg {
uint32 tracked_cell_index = 1;
// Parallel arrays.
repeated uint32 voltage_offsets = 2;
repeated int32 voltage_offsets = 2;
repeated uint32 mah_offsets = 3;
}

Expand All @@ -14,7 +14,7 @@ message SettingsMsg {
string ap_name = 2;
string ap_password = 3;
int32 graceful_shutdown_count = 4;
uint32 bms_serial = 5;
reserved 5; // used to be BMS serial override
string ap_self_password = 6;
string ap_self_name = 7;
int32 wifi_power = 8;
Expand Down
4 changes: 1 addition & 3 deletions src/bms_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ void bms_setup() {
saveSettings();
});

if (Settings->bms_serial != 0) {
relay->setBMSSerialOverride(Settings->bms_serial);
}
relay->setBMSSerialOverride(0xFFABCDEF);

setupWifi();
setupWebServer(relay);
Expand Down
23 changes: 1 addition & 22 deletions src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AsyncWebSocket ws("/rawdata");
const String defaultPass("****");
BmsRelay *relay;

const String owie_version = "1.2.1";
const String owie_version = "1.3.0";

String dumpChargingPointsFromSettings() {
String val;
Expand Down Expand Up @@ -140,17 +140,8 @@ String templateProcessor(const String &var) {
out.concat("<tr>");
}
return out;
} else if (var == "BMS_SERIAL_OVERRIDE") {
// so it doesn't return 0 when no override is set
if (Settings->bms_serial == 0) {
return "";
} else {
return String(Settings->bms_serial);
}
} else if (var == "AP_PASSWORD") {
return Settings->ap_self_password;
} else if (var == "BMS_CURRENT_SERIAL") {
return String(relay->getCapturedBMSSerial());
} else if (var == "AP_SELF_NAME") {
return Settings->ap_self_name;
} else if (var == "DISPLAY_AP_NAME") {
Expand Down Expand Up @@ -269,14 +260,9 @@ void setupWebServer(BmsRelay *bmsRelay) {
SETTINGS_HTML_SIZE, templateProcessor);
return;
case HTTP_POST:
const auto bmsSerialParam = request->getParam("bs", true);
const auto apSelfPassword = request->getParam("pw", true);
const auto apSelfName = request->getParam("apselfname", true);
const auto wifiPower = request->getParam("wifipower", true);
if (bmsSerialParam == nullptr) {
request->send(400, "text/html", "Invalid BMS Serial number.");
return;
}
if (apSelfPassword == nullptr ||
apSelfPassword->value().length() >
sizeof(Settings->ap_self_password) ||
Expand All @@ -294,13 +280,6 @@ void setupWebServer(BmsRelay *bmsRelay) {
request->send(400, "text/html", "Invalid Custom AP Name.");
return;
}
// allows user to leave bms serial field blank instead of having to put
// 0
if (bmsSerialParam->value().length() == 0) {
Settings->bms_serial = 0;
} else {
Settings->bms_serial = strtoul(bmsSerialParam->value().c_str(), nullptr, 0);
}

// Set wifi power
// add aditional sanity checks, so that the power range is between 8 and
Expand Down
28 changes: 14 additions & 14 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ EEPROM_Rotate& getEeprom() {
}
} // namespace

SettingsMsg *Settings = &__settings;
SettingsMsg* Settings = &__settings;

void sanitizeWifiPowerSetting() {
// check the wifi power Setting and write back a sane default if is out of bounds
// the defined sane range is between 8dBm and 17dBm. Lower values may prevent the WLAN to show up under the batterybox
// and a to high setting may generate signal noise.
// defaulting to 9 brings up the WLAN with a decent range of ~1-2 meters on PINTS and ~1 meter on a XR with an acceptable signal strength.
// check the wifi power Setting and write back a sane default if is out of
// bounds the defined sane range is between 8dBm and 17dBm. Lower values may
// prevent the WLAN to show up under the batterybox and a to high setting may
// generate signal noise. defaulting to 9 brings up the WLAN with a decent
// range of ~1-2 meters on PINTS and ~1 meter on a XR with an acceptable
// signal strength.
if (Settings->wifi_power < 8 || Settings->wifi_power > 17) {
Settings->wifi_power = 9;
}
Expand All @@ -45,17 +47,15 @@ void sanitizeWifiPowerSetting() {
void loadSettings() {
auto& e = getEeprom();
uint16_t len = *(uint16_t*)e.getConstDataPtr();
if (len <= MAX_SETTINGS_SIZE) {
auto istream =
pb_istream_from_buffer(getEeprom().getConstDataPtr() + 2, len);
if (pb_decode(&istream, &SettingsMsg_msg, Settings)) {
DPRINTF("Read and decoded settings, size = %d bytes.", len);
sanitizeWifiPowerSetting();
return;
}
auto istream = pb_istream_from_buffer(getEeprom().getConstDataPtr() + 2,
min<uint16_t>(len, MAX_SETTINGS_SIZE));
if (pb_decode(&istream, &SettingsMsg_msg, Settings)) {
DPRINTF("Read and decoded settings, size = %d bytes.", len);
sanitizeWifiPowerSetting();
return;
}
DPRINTLN("Failed to decode settings, resetting.");
nukeSettings(); // nukeSettings() calls saveSettings()
nukeSettings(); // nukeSettings() calls saveSettings()
}

int32_t saveSettings() {
Expand Down

0 comments on commit 0225fc9

Please sign in to comment.