Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Electric Motors and Controllers
mittkonto   100 mW

100 mW
Posts: 35
Joined: Mar 02 2019 2:31am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by mittkonto » Oct 01 2019 5:30am

Any news on the "Making the SF102 update using the BLE factory bootloader (no need to open the case) #35"-front?

Got a SW102 ready to flash, got 0.20.0 in the tsdz2, holding of a bit till its supported. I'm a eager guinea pig though.
By the wholesome Code Gods of Muchgivings!!? A tidy TSDZ2 spliced cable and a nice chunk of HIGO-Z812-B with a tad of temperature mods sprinkled on top, you say?

casainho   10 GW

10 GW
Posts: 4436
Joined: Feb 14 2011 2:43pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by casainho » Oct 01 2019 5:38am

mittkonto wrote:
Oct 01 2019 5:30am
Any news on the "Making the SF102 update using the BLE factory bootloader (no need to open the case) #35"-front?

Got a SW102 ready to flash, got 0.20.0 in the tsdz2, holding of a bit till its supported. I'm a eager guinea pig though.
The good news is the geeksville is working on it currently and had some good achievements. Please don't ask for a time to get it done - but this is my opinion.
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

User avatar
doomy   100 µW

100 µW
Posts: 9
Joined: Feb 07 2018 11:39am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by doomy » Oct 01 2019 7:18am

casainho wrote:
Oct 01 2019 2:13am
Yes there is, here is the 2 ways listed: https://github.com/OpenSource-EBike-fir ... -using-SWD
I mean this page, there is also a link to it on the first page.

https://github.com/OpenSource-EBike-fir ... -LCD-SW102

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 01 2019 6:41pm

Interesting! Tomorrow night I'll do two things:

Repro the problem you describe and then push out s new version.

Push out a version of the classic 0.19.13 build with a special flag set that tells the bootloader to ignore the version info. From now on I'll always set this flag.

Sorry about these recent bugs - usually I use a release on my bike for a few days before releasing - but currently my bike is disassembled (upgrading to a new bike 😁)
windburner wrote:
Sep 29 2019 10:40pm
windburner wrote:
Sep 29 2019 7:55pm

I think that reversing a version is very important ...
Looks like my "reversing a version via bluetooth" comment was very much appropriate, as I'll need to do a bit of soldering to revert to 0.19.11 for tomorrow morning's ride (or revert to the TSDZ2 factory firmware and to the VLCD6 display and wait for the next SW102 update).

The update via bluetooth from .11 to .15 went very easy. However, with 0.19.15, using UP+DOWN to go between screens, the sequence for my unit is, main screen, info screen, settings screen, to OFF!!! Just in case, I waited for some time (up to 180 seconds) to see if it would reboot and return with a fault code, but it remained off. In fact, I got to a black screen in many ways, without touching the power button.

The reason I need to revert is the fact that, no matter what I did, no setting changes were ever saved, thus, it can't be configured for my trike and ride profile, and the default settings will not work.

Also, I experimented with the ability to change the info screen configuration, which is a nice feature, and these too could not be saved.

Will attempt to report an issue, which could be a large report if I tried to report everything encountered.

On the positive side, I do see lots of promise with these changes.

ebentrider   1 mW

1 mW
Posts: 12
Joined: Aug 08 2018 10:31am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by ebentrider » Oct 01 2019 7:07pm

looks like you have made some progress. I hacked open my display and flashed back to v.11 via SWD, which I was enjoying before. All the weird motor issues went away and seems better now, so I think I didn't fry my motor on the second ride yay! i will move up to the latest version eventually but liking the way it rides so I'm leaving it with the old one for now.

I prefer pressing single buttons, use the M or power button, up or down, but pressing up and down together I need to stop and use two hands. The buttons don't work so great after hacking into the display.

User avatar
windburner   1 W

1 W
Posts: 54
Joined: Sep 24 2019 3:45pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by windburner » Oct 02 2019 9:47am

ebentrider wrote:
Oct 01 2019 7:07pm
... I hacked open my display and flashed back to v.11 via SWD, ...
I didn't want to dig into that again, so, I decided to wait for the next progression of SW102 FW, and flashed the TSDZ2 back to factory while switching back to the VLCD6 display. Still an enjoyable ride.

Looking forward to test the 0.20.x compatible variant!
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

pau1phi11ips   1 µW

1 µW
Posts: 1
Joined: Oct 06 2019 2:51am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by pau1phi11ips » Oct 06 2019 2:55am

hex4def6 wrote:
Sep 30 2019 8:23pm
head --> desk...

Guess I didn't realize this was for the TZD2 only, not the bafang motors.... Oops.
You're not the only one. I was looking forward to trying this out with my Bafang too. Sad times...

hex4def6   100 µW

100 µW
Posts: 8
Joined: Apr 14 2017 12:20pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by hex4def6 » Oct 07 2019 2:11pm

If anyone is planning on flashing the to a fresh device, I'd appreciate if you could try grabbing a copy of the existing factory firmware off the device using the method suggested on the first page of this thread. Thanks!

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 09 2019 4:51pm

hex4def6 wrote:
Oct 07 2019 2:11pm
If anyone is planning on flashing the to a fresh device, I'd appreciate if you could try grabbing a copy of the existing factory firmware off the device using the method suggested on the first page of this thread. Thanks!
You can't copy the factory firmware off normally (because it is read protected). However, I can help you out - PM me ;-).

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

0.19.17 released - please try soon

Post by geeksville » Oct 09 2019 4:51pm

Hi ya'll,

The 0.19.15 had a serious bug with saving settings. This release fixes that, it also returns the M/ONOFF key usage to the more popular choices.

New features (full changelist [here](https://github.com/OpenSource-EBike-fir ... CD/pull/27)):

* Fix settings saving
* Change back to using M to start/stop field editing
* Change back to using ONOFF to go to the next screen or exit from nested menus
* Fix a few drawing bugs
* (And as usual - we might have made new bugs - oops. If that happens _please_ log a bug on github). We read the forums but making a real bug makes it less likely we'll forget to fix what you found.

The initial install (mainly getting access to the programming pins) is a bit of a hassle but we've written [instructions](https://github.com/OpenSource-EBike-fir ... re-install) to make it easier. Every installation after that is very painless via our bluetooth bootloader software-update.

If you are upgrading from a previous release, you can upgrade over bluetooth. The procedure is:

* Install "nRF Connect" from your appstore of choice (Google Play or whatever)
* Download our [sw102-otauptdate-xxx.zip](https://github.com/OpenSource-EBike-fir ... D/releases) file onto your phone (do not unzip)
* Press and hold the M key on the SW102, then press and hold the power button. Keep both buttons pressed down for at least eight seconds. You can then release the buttons. You will know you are in the bootloader if the screen stays dark.
* Run the "nRF Connect" app. You should see "SW102 DFU" list, click on Connect
* On this new pane you will see a small DFU icon in the upper right of the screen. Click on it.
* Select our "application bundle" and our zip file.
* The update should start and show progress as it progresses
* After the upload completes turn your bike completely off
* Then start your new SW102 load as normal (a long press on the power button)

Future releases will include release notes, but for now here's a link to our [TODO list](https://github.com/OpenSource-EBike-fir ... re/TODO.md). If you encounter bugs please open as issue [here](https://github.com/OpenSource-EBike-fir ... LCD/issues). Make sure you mention you were using a SW102 and include as much information as possible.

We look forward to your reports of great success (or failure, ahem) in this [thread](viewtopic.php?f=30&t=99698).

User avatar
windburner   1 W

1 W
Posts: 54
Joined: Sep 24 2019 3:45pm

Re: 0.19.17 released - please try soon

Post by windburner » Oct 10 2019 12:46am

geeksville wrote:
Oct 09 2019 4:51pm
Hi ya'll, ...
We look forward to your reports of great success (or failure, ahem) in this thread ...
With the closing of the issue reported with 0.19.15, a request was made to try it quick, just in case, so I complied.

The update from 0.19.15 to 0.19.17 went smoothly via bluetooth. The system power was removed, waited some seconds, then system power on and startup via a ~3 second power button press.

Unfortunately, the SW102 powered up to a blank screen in DFU mode (as seen by still being available as "SW102 DFU" from the DFU Utility). Tried two more power off/on cycles, no success. Then, again attempted to uploaded the 0.19.17 update via the DFU Utility, successfully. Wow! Same outcome. Also tried a few key press combinations (+M, +V, etc.) at startup without success.

Also tried to upload the 0.19.11 update, but, it was a no go.

Oh well. Thanks for trying.

I'll leave the TSDZ2 with the OSF (for the next several hours) in case there are suggestions of other things to try with the SW102 at 0.19.17.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 10 2019 11:12am

Hmm. Were you using the nrf connect app to do the upgrade? (I updated two bikes here and my dev SW102 without problem)

User avatar
windburner   1 W

1 W
Posts: 54
Joined: Sep 24 2019 3:45pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by windburner » Oct 10 2019 12:59pm

geeksville wrote:
Oct 10 2019 11:12am
Hmm. Were you using the nrf connect app to do the upgrade? (I updated two bikes here and my dev SW102 without problem)
Yes, and it did report that the upload was successful.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

isiorg   10 µW

10 µW
Posts: 5
Joined: May 25 2017 7:31pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by isiorg » Oct 10 2019 1:14pm

Nrf toolbox not nrf connect!!!

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 10 2019 2:15pm

Please try nrf connect. The updater in nrf toolbox seems flaky to me.

User avatar
windburner   1 W

1 W
Posts: 54
Joined: Sep 24 2019 3:45pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by windburner » Oct 10 2019 3:16pm

geeksville wrote:
Oct 10 2019 2:15pm
Please try nrf connect. The updater in nrf toolbox seems flaky to me.
So, reading is fundamental! My first answer should have been: No, I used "nrf toolbox".

So, I downloaded "nrf connect", and tried the "dfu". It did not ask the "scope" question, and immediately proceeded to the upload and install step. After reporting success, I powered off the trike and tried again. Same results, in that is still starts up in DFU (is that also called bootloader?) mode!

My SW102, purchased in September, was reported to be "the latest generation". Perhaps that is the difference?

... Time passes ...

I tried again using "nrf connect" and the SW102 got lost, still powering up in DFU mode, but "nrf connect" could not get sustain a connection.

... More time passes ...

I tried an upload again using "nrf toolbox" and left it sit while I typed in the second "nrf connect" trial info. Then I went back, did a full power off, counted to 10, powered on the trike, then pressed the power button.

I GOT A DISPLAY!!!

I am not sure what all of this back and forth was about, but, now, I'll go do some configuring/testing.

P.S. The flash screen is so/too fast, << 1.0 second, I think that I saw that it was 0.19.17.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 10 2019 3:50pm

If you hold down the power button the not screen will stay on. Also, it takes a long time for the
Unit to power down after the battery is disconnected, maybe even 30 seconds.

User avatar
windburner   1 W

1 W
Posts: 54
Joined: Sep 24 2019 3:45pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by windburner » Oct 10 2019 8:10pm

Well, more mostly good news. Testing of the SW102 with the 0.19.17 firmware went OK.
- Feature settings and screen configurations are now being saved.
- Changing units to mph from kph now seems to display mph (fairly close correlation with my GPS)

Re preceding geeksville comment:
While my typical power down was on the order of 10 seconds, during the first constant bootloader issue period, there were several 5 minute power downs, in fact, one overnighter. For a normal power up, I hold the power button for up to 3 seconds, versus the 8 seconds to activate the bootloader mode.

One big query:
On the TSDZ2 v0.19 OSF with the modified SW102 firmware at both 0.19.11 and 0.19.17 levels, the startup power feature seemed to have no positive effect. While the default was 'disable', when changed to 'enable', it actually delays the onset of pedal assist by the value of 'duration', instead of boosting for 'duration', no matter what Motor Duty Cycle value is set for Level1-X. Am I misunderstanding what this should do? Is this a known abnormality of v0.19 OSF? Or does this seem to be an error introduced with the SW102? This is important right now, as the onset of pedal assist with v0.19 OSF seems to lag well behind the factory firmware.

Issue Reports:
1. For the Odometer and Trip Distance, using mph as units, the decimal point is missing (i.e., 6.8 miles displays as 68). The miles were a close match to the GPS.
2. While scrolling through the feature menu, I did from time to time get the remnant of a cursor blink (I think this might have been called a 'screen turd' in one version of the todo list), usually when moving down the feature menu, versus up.
3. Again with both versions I've tested, when going through a feature sub-menu, some settings would be inverted, with a white background which blanked the still white descriptor text, while the value field was reversed to black and clearly visible. A power off/on usually solved this.

I still like the potential of the SW102 over the VLCD6 as a compact display, and am willing to keep at it to get it to Beta and Beyond. Although, the closely packed assist up/down buttons will definitely take some finger memory re-development to prevent control dribbles.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 11 2019 2:42am

I use the startup power option also with my sw102. However to get it to respond quickly you need to also turn on the option to not require cadence before starting (ie just pedal pressure is sufficient). This is a trait of the 0.19 tsdz2 code - not the display code.

Unfortunately I don't remember the name of that option exactly and I'm on a long plane flight now. Hopefully someone can chime in with more details.

User avatar
windburner   1 W

1 W
Posts: 54
Joined: Sep 24 2019 3:45pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by windburner » Oct 11 2019 8:31am

geeksville wrote:
Oct 11 2019 2:42am
... you need to also turn on the option to not require cadence before starting (ie just pedal pressure is sufficient)...
Aha! That must be that option under Various called "Motor Assist" which by default is "disable". I'll give "enable" a try. Thanks.

EDIT: Yes, that's it, although, the 'torque for activation threshold' probably needs to be adjustable, as I once inadvertently activated the boost (momentarily) just mounting my feet to the pedals.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

User avatar
windburner   1 W

1 W
Posts: 54
Joined: Sep 24 2019 3:45pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by windburner » Oct 12 2019 11:48pm

Follow-up Notes on SW102 with 0.19.17 firmware testing:
1.The Display-->Auto power off Feature has a 15 'minutes' default, but, in my testing, the display powers off after 9 minutes no matter the default or any value I've set. I experienced something similar to this same behavior in 0.19.11, but I never timed it.
2.The "Trip Distance" attribute resets with each power off, thus, you can't pause on a trip for more than 9 minutes to smell the wild flowers, or watch the ripples where two branches of a river rejoin.

Features Suggestions:
1.Allow user-only Trip Distance reset versus with every power off. (I checked the TODO and did not see any such mention.)
2.Add an Option where Trip Time only accumulates when Cadence&Speed != Zero(+any appropriate buffering), allowing user-only reset, as above.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18


jimmyfergus   100 mW

100 mW
Posts: 49
Joined: Jul 17 2018 4:19pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by jimmyfergus » Oct 15 2019 9:35am

Just a quick post to report I had no problem going from 0.19.11 to 0.19.17 with nrf connect. Some of the chat here made me nervous about updating.

Startup is way faster - that's very welcome! Also, MPH works. As a very minor issue the 'mph' label seems to overlap the speed digits. The battery capacity display seems to still have the issue of drastically underestimating the remaining charge. I've disabled the SoC display so that I can see voltage to guestimate the charge level.

I had some strange behavior in the settings menu where after a while some items show up in inverse video, and sometimes it seemed to freeze up mildly. Sorry this report isn't very useful for bug chasing - I'll try to work out how to reproduce.

Thank you for the work on this!

geeksville   10 W

10 W
Posts: 89
Joined: Aug 02 2019 6:44pm

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by geeksville » Oct 16 2019 5:03pm

Thanks! The SOC thing I think shares a common bug with the 850C version. So when we fix it it will work for both devices.

JaiCee   1 mW

1 mW
Posts: 10
Joined: May 06 2019 4:57am

Re: Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Post by JaiCee » Oct 17 2019 12:37am

It looks like Strava is dropping support for Bluetooth devices which is a bit of a bummer now that this project was so close to supporting it

Post Reply