Bafang SW102 Bluetooth LCD - OpenSource firmware and mobile app

Electric Motors and Controllers
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 » Nov 10 2019 2:14pm

geeksville wrote:
Nov 10 2019 1:18am
If there is a big problem with this release I'll quickly push out a new build ...
Thanks for the 'extra-mile/kilometer' support! I'll give it a try.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

stefkrger   1 mW

1 mW
Posts: 18
Joined: Dec 03 2018 11:49am

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

Post by stefkrger » Nov 10 2019 6:02pm

I just flashed my SW 102 according to the wiki. The log said everything went fine but the display does not come up at all.. is there any way to check if the display is working without connecting the motor? Should it come up when I connect the ST link v2 3.3v and GND or do I have to wire the display to the motor first?

User avatar
windburner   1 W

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

Re: New SW102 release 0.5.0-beta4

Post by windburner » Nov 10 2019 10:12pm

geeksville wrote:
Nov 09 2019 9:54pm
... This new release ... version is 0.5.0-beta-4. ... We look forward to your reports of great success (or failure, ahem) in this thread.
On initial testing, it appears that the SOC indication and automatic power off seem to be working properly. In addition, I found a couple new, hopefully unintended, features.
  • Info screen 2 has only once entered the configuration mode for me. Fortunately, I restored my preferred data display items this first time through, while exploring the new way the buttons function in this mode (which I presume was an intentional change!!!) Wanting to update my SW102 configuration document, I have tried multiple times without success to re-engage info screen 2 configure mode, even after an hour with system power off.
  • Under "Start Pwr", when the new attribute 'Need pedal' is set to 'always', start power is engaged, even though 'Feature disable' is selected.
On the subject of configuration, I thought that I had read some months back that settings were being retained across updates. They were not in my case with this update, and my memory of my preferred riding setting was strenuously tested. Lacking settings retention, a function to set the odometer value would be most excellent. I recall reading of such a function being available for one of the other displays.

I have yet to see any screen blobs from the cursor while navigating the settings configuration, as I have in past versions, and, so far, have not encountered the issue where some settings appear with a reversed background, nor the other screen irregularities from earlier versions.

So, it is really looking like a later stage Beta. Thanks Team!

P.S. In case you didn't know, anxiously waiting to see a SW102 interacting with V0.20. :wink:
Last edited by windburner on Nov 11 2019 12:41am, edited 1 time in total.
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 » Nov 10 2019 10:30pm

stefkrger wrote:
Nov 10 2019 6:02pm
I just flashed my SW 102 according to the wiki. The log said everything went fine but the display does not come up at all.. is there any way to check if the display is working without connecting the motor? Should it come up when I connect the ST link v2 3.3v and GND or do I have to wire the display to the motor first?
Presuming that this is the initial flash (of the bootloader and v0.19.x firmware via the wires). On the initial flash, after successful completion, it is supposed to start running a simulator and display as if it is connected to the motor, which it did for my case. If not, sounds like something went wrong.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

gatorsean   100 mW

100 mW
Posts: 36
Joined: Jun 12 2019 1:28am

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

Post by gatorsean » Nov 11 2019 12:03am

I am excited about this new 0.5.0 beta! I just got eclipse working and building this repo so I can start tweaking my new build and contributing around here.

One of the first things I am working on is enabling the throttle, which I noticed might have already been done in this build.

I noticed in state.c that for case 8 in the switch for send_tx_package, the default is now l2_vars.ui8_temperature_limit_feature_enabled & 3;

I installed the update, but my throttle isn't working. It does still show the ADC response in the config menu, so i am sure it just needs to be coded in. I am going to try to dig a little deeper, but thought i would reach out in case there is a trick or something i haven't noticed yet.
Last edited by gatorsean on Nov 11 2019 10:48pm, edited 1 time in total.

stefkrger   1 mW

1 mW
Posts: 18
Joined: Dec 03 2018 11:49am

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

Post by stefkrger » Nov 11 2019 2:37am

windburner wrote:
Nov 10 2019 10:30pm
Presuming that this is the initial flash (of the bootloader and v0.19.x firmware via the wires). On the initial flash, after successful completion, it is supposed to start running a simulator and display as if it is connected to the motor, which it did for my case. If not, sounds like something went wrong.
Thanks mate.. I hope I did not kill my display during soldering. I’ll try to flash it again later today. Is there any advantage having it connected to the motor power (like in the wiki) as opposed to the 3.3v from the stlink?

bikelpl   100 µW

100 µW
Posts: 9
Joined: Jul 09 2019 1:52am

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

Post by bikelpl » Nov 11 2019 4:02am

Info screen 2 has only once entered the configuration mode for me.
I have the same.

I also noticed that, when You press M button and return to main screen , the assist level digit dissapears.
You have to press ^ or v button to change .

Image

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 » Nov 11 2019 9:28am

stefkrger wrote:
Nov 11 2019 2:37am
Is there any advantage having it connected to the motor power (like in the wiki) as opposed to the 3.3v from the stlink?
I used the 3.3v from the stlink. After having gone through the pain of making the other three connections, what's another one?
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 » Nov 11 2019 9:32am

bikelpl wrote:
Nov 11 2019 4:02am
I also noticed that, when You press M button and return to main screen , the assist level digit dissapears.
:thumb: Yes, I saw that too. Since it has been a long term issue, I didn't think to report it.
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

stefkrger   1 mW

1 mW
Posts: 18
Joined: Dec 03 2018 11:49am

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

Post by stefkrger » Nov 11 2019 1:44pm

So I've just tried the flashing again.
The device is still not coming up after the routine.

Everything looks pretty similar to the screenshot in the wiki entry, however I've noticed a slight difference (marked in the picture below). In the wiki screenshot this line says:
info : nRF51822-QFAC(build code: A1) 256 kB Flash

What could be the issue here?
screenshot.PNG
screenshot.PNG (39.07 KiB) Viewed 4064 times

Nfer   10 W

10 W
Posts: 83
Joined: Sep 17 2019 6:51am

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

Post by Nfer » Nov 11 2019 5:01pm

geeksville wrote:
Nov 10 2019 1:20am
windburner wrote:
Nov 09 2019 11:13am
Nfer wrote:
Nov 09 2019 8:43am
I tried to open the sw102 cutting the glue at sides of the keypad and I killed the down button contact. It was my fault, instructions are good. Is it possible to use the display without the down button?
The Down button is critical for the configuration process, as well as adjusting the Assist Level, so, I'd say no. Can you solder in a wire or something to bridge the break? (I know it is tight working, as I hope to never have to mess about inside my SW102 again.)
If you do need to fix your button, you can try removing the PCB (it comes out with a little connector on the back - just flip the black tab up to release the cable). This should give you better access to plug in a jumper. But if that won't work, yeah you'll need to plunk down another $35.
I was able to flash the display with the solder less method after several attempts. Just ordered a new display. I hope you will find a way to flash it without risk. Thanks for your effort in this amazing project. The sw102 looks fantastic

hefest   100 W

100 W
Posts: 154
Joined: Jan 11 2019 4:55am

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

Post by hefest » Nov 13 2019 3:49pm

I've just ordered sw102 and while looking for the instructions how to flash it initially I've noticed that instructions how to open sw102 from the side, without destroying keypad waterproofing are nowhere to be found. I clearly remember seeing it on github but it's not there anymore. Am I missing something?

Nfer   10 W

10 W
Posts: 83
Joined: Sep 17 2019 6:51am

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

Post by Nfer » Nov 13 2019 4:35pm

hefest wrote:
Nov 13 2019 3:49pm
I've just ordered sw102 and while looking for the instructions how to flash it initially I've noticed that instructions how to open sw102 from the side, without destroying keypad waterproofing are nowhere to be found. I clearly remember seeing it on github but it's not there anymore. Am I missing something?
https://github.com/OpenSource-EBike-fir ... -SWD-wires

User avatar
windburner   1 W

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

Re: New SW102 release 0.5.0-beta4

Post by windburner » Nov 14 2019 12:50pm

geeksville wrote:
Nov 09 2019 9:54pm
... new release ... version is 0.5.0-beta-4. ...
So far, on the OSF for the SW102, the Trip Meter and Odometer values on Info Screen 2 display without a decimal point, i.e., 0.1 miles displays as 01, 1.1 as 11, and I don't recall what happens >=10.0 miles given the resets with the version updates (I wish I knew for 5-beta-4, but, the snow/cold is in my way). Is it planned that the display of these values (especially Trip) will eventually get the decimal point? If not planned, can it be considered? Thanks
TerraTrike Rover Tandem - TSDZ2 48V 750W - 13AH Batteries - VLCD6-->SW102/v0.6.8 OSF-->VLCD6 -->XH18

casainho   10 GW

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

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

Post by casainho » Nov 14 2019 1:13pm

stefkrger wrote:
Nov 11 2019 1:44pm
So I've just tried the flashing again.
The device is still not coming up after the routine.

Everything looks pretty similar to the screenshot in the wiki entry, however I've noticed a slight difference (marked in the picture below). In the wiki screenshot this line says:
info : nRF51822-QFAC(build code: A1) 256 kB Flash

What could be the issue here?

screenshot.PNG
I would say you have no connection on SWD pins. Verify again your connection on SWD pins to the SW102 and try again.
- 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

stefkrger   1 mW

1 mW
Posts: 18
Joined: Dec 03 2018 11:49am

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

Post by stefkrger » Nov 19 2019 5:00pm

casainho wrote:
Nov 14 2019 1:13pm
I would say you have no connection on SWD pins. Verify again your connection on SWD pins to the SW102 and try again.
I just removed the soldered wires and tried with the solderless method using a 2mm 1x4 pin header. With that method I could not get a connection. Then I soldered the wires again and now I‘m seeing the same log output as in the screenshot I posted earlier.

It seems it does flash something and the connection check works as well. It’s just that my display does not turn on..

casainho   10 GW

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

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

Post by casainho » Nov 19 2019 5:05pm

stefkrger wrote:
Nov 19 2019 5:00pm
casainho wrote:
Nov 14 2019 1:13pm
I would say you have no connection on SWD pins. Verify again your connection on SWD pins to the SW102 and try again.
I just removed the soldered wires and tried with the solderless method using a 2mm 1x4 pin header. With that method I could not get a connection. Then I soldered the wires again and now I‘m seeing the same log output as in the screenshot I posted earlier.

It seems it does flash something and the connection check works as well. It’s just that my display does not turn on..
Then I would say you have a faulty unit.
- 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

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 » Nov 19 2019 10:22pm

Don't want to spam, but if anyone is considering flashing their unit -- could you please dump the FW using the method nick / geeksville mentioned first?

I'm the idiot that didn't realize this FW isn't compatible with the BBS02... :lol:

Thanks in advance! :bigthumb:

stefkrger   1 mW

1 mW
Posts: 18
Joined: Dec 03 2018 11:49am

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

Post by stefkrger » Nov 20 2019 7:49am

casainho wrote:
Nov 19 2019 5:05pm
Then I would say you have a faulty unit.
I’m afraid so.. however it will be quite hard to return with the cut open side :lol:

It could also be that something went wrong during the first flash attempt. I remember it failed with some weird error message. Maybe it corrupted some part of the firmware?

Update:
I ordered a new SW102 which arrived today.. opened it, soldered the wires, flashed it, and it worked. Guess I was really unlucky and the first display I got was just broken.

obcd   100 W

100 W
Posts: 158
Joined: Jul 16 2019 3:45pm

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

Post by obcd » Nov 25 2019 6:56am

Will it work on any SW102 to reflash it over bluetooth (when that method is ready), or will we need one with a specific firmware to start with? I assume it needs to have a bootloader with bluetooth enabled, but it's unclear if they all use the same bootloader at the moment?

casainho   10 GW

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

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

Post by casainho » Nov 25 2019 7:00am

obcd wrote:
Nov 25 2019 6:56am
Will it work on any SW102 to reflash it over bluetooth (when that method is ready), or will we need one with a specific firmware to start with? I assume it needs to have a bootloader with bluetooth enabled, but it's unclear if they all use the same bootloader at the moment?
As far as we know, should work in every SW102 coming from the factory.
- 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

hefest   100 W

100 W
Posts: 154
Joined: Jan 11 2019 4:55am

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

Post by hefest » Dec 02 2019 2:41pm

Opened sw102 and about to solder the wires and flash it for the first time.

At the moment i have some older 0.19.x version of the firmware on the motor. Can I flash latest 0.19.x sw102 and will it be compatible with the current firmware on the motor?

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 » Dec 02 2019 3:22pm

hefest wrote:
Dec 02 2019 2:41pm
Opened sw102 and about to solder the wires and flash it for the first time.

At the moment i have some older 0.19.x version of the firmware on the motor. Can I flash latest 0.19.x sw102 and will it be compatible with the current firmware on the motor?
Latest SW102 firmware is only compatible with 0.19.x firmware. 0.20 motor firmware isn't yet supported

hefest   100 W

100 W
Posts: 154
Joined: Jan 11 2019 4:55am

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

Post by hefest » Dec 03 2019 4:16am

Well crap. Wired sw102 wire color to wire color to the jack where ktlcd3 was wired. I think i fried the sw102 .

PS: connected P+ batt voltage to uart tx on sw102, definitely fried.

gatorsean   100 mW

100 mW
Posts: 36
Joined: Jun 12 2019 1:28am

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

Post by gatorsean » Dec 09 2019 1:50am

I am trying to get throttle working on the SW102 and noticed in configscreen.c in the define section for SW102, there is only two options for the ADC (temp sensor or off):
Line 80:
FIELD_EDITABLE_ENUM("Feature", &l3_vars.ui8_temperature_limit_feature_enabled, "disable", "enable"), // FIXME, share one array of disable/enable strings

Is there some reason we cannot have all three options like 850C?
Lin 204:
FIELD_EDITABLE_ENUM("Feature", &l3_vars.ui8_temperature_limit_feature_enabled, "disable", "temperature", "throttle"), // FIXME, share one array of disable/enable strings

Thanks for any tips!

Post Reply