New TSDZ2 Open Source firmware with Bluetooth interface

I'm having some problems with 'street mode' in combination with the Enerpower SW102 (Enerpower SW102 Display UART Tongsheng compatible 6-Pins)

Wiki states:
Street mode is selected on the LCD with the enable/disable 25Km/h setup option

But on the Enerpower SW102 i have, i can't ENABLE/DISABLE the 25km/h setup option.
I only can CHANGE the Speed limit from 15km/h to max. 60 km/h in the config menu (no enable/disable option)
It seems that the ESP32 can't read this value from the display, so 'street mode' (fallback from STREET_MODE_LCD_MASTER) is always activated when i power on the bike.

Can this be altered/hardcoded in the ESP32 firmware code, so that by default 'street mode' is turned off when starting the bike?

@mspider65 : is this the right place?
tsdz_data.c
volatile uint8_t ui8_app_street_mode = STREET_MODE_LCD_MASTER;

changing into:
volatile uint8_t ui8_app_street_mode = STREET_MODE_FORCE_OFF;

???

Addon: i'm getting this error when trying to build from source:
[1110/1160] Building C object esp-idf/mqtt/CMakeFiles/__idf_mqtt.dir/esp-mqtt/mqtt_client.c.objninja: build stopped: subcommand failed.
Fixed: downgraded to ESP-IDF 4.1. Build is now succesfull

Addon:
When i try to upload my TSD2-ESP32-Main.bin over OTA i get a message
Error 30 (communication error) on the display and then ESP32 started! Update error:10 in the app (firmware is not updated)
Flashing with FTDI does not work anymore (Failed to connect to Espressif device: Timed out waiting for packet header). Even when i try the original bin file (otherwise the board is working, i can connect etc. to it)
What could be wrong?
BTW: i'm using a v3 board

So, if you want to use the TSDZ2-ESP32 with an Enerpower SW102 please be aware:
It works in general out of the box but there are 3 things you have to take into account:
1. You can't update the esp32 over OTA (error 30 on the display, error 10 in the app). Fix: Just hookup the original VLCD5 display before you do the OTA update. It then will update fine.
2. It will always boot-up in street mode
3. the display has 5 assist modes (0 - off, 1 ,2 ,3 ,4 ,5) but the esp32/app/controller firmware only handles 4 (0-off, 1, 2, 3 ,4) which results in:
0 - off on the display results in 0 in the esp32/app
1 on the display does nothing in the esp32/app/controller
2 on the display maps to 1 in the esp32/app/controller
3 on the display maps to 2 in the esp32/app/controller
4 on the display maps to 3 in the esp32/app/controller
5 on the display maps to 4 in the esp32/app/controller

This is no show-stopper for me, but it is something to consider if you plan to use this Enerpower SW102 display (UART Tongsheng compatible 6-Pins)
 
Last edited:
I have received my V4 boards from PCBWAY. I have downloaded and installed esptool. I have downloaded the necessary files and installed in the FW directory. I have connected the board to the FTDI adapter with jumper in place and ran the Flash bat file. I have removed the jumper and powered up the board again from the FTDI adapter. When I do a bluetooth scan from the app, I do not see the ESP32 board. Any suggestions?
 
Hello. Same problem for me, there are some comments through this discussion about BT issues. Do you have an older phone to try, my Android 9 phone finds it without a problem, my Android 13 hasn't managed to yet, but if i do solve it i'll post here.
 
Hello. I just got it to work version 12 and change the dev settings on my phone so it uses Bluetooth AVRCP version AVRCP 1.6 (you need to enable developer options on your phone (very easy, google it) to get to this setting, I hope that works for you. This was done whilst powering it using the USB adapter I used to program it. Here's a link to enabling the Dev Options

 
Last edited:
Hello. I just got it to work version 12 and change the dev settings on my phone so it uses Bluetooth AVRCP version AVRCP 1.6 (you need to enable developer options on your phone (very easy, google it) to get to this setting, I hope that works for you. This was done whilst powering it using the USB adapter I used to program it. Here's a link to enabling the Dev Options

Thanks, My phone is using Android 13. I changed the setting to use version AVRCP 1.6 but it still does not find the Bluetooth from this board.
 
Thanks, My phone is using Android 13. I changed the setting to use version AVRCP 1.6 but it still does not find the Bluetooth from this board.
Did you remove the jumper after flashing? If you still have the jumper connector in place, the esp32 stays in bootloader/flashing mode (ready for flashing) and then you won't see the esp32 bluetooth device (it won't advertise).
EDIT: sorry, i see in your post that you did remove the jumper after flashing

Also make sure that the app/esp32/controller firmware versions are compatible with eachother

My versions:
App: FW version: 2.1.12
esp32: FW version: 1.2.1
TSDZ2 FW version: 16

As of this writing i believe these are the latest versions

Good luck,

Cheers,
Ray

ADDON: I just thinking about something:
1. Also turn on location (gps) function on you phone before you try to discover the esp32 device over BLE
2. Check the app permissions (in my case the app has permissions for location and write access to disc)
3. Install an app called BLE scanner on you phone, run the scan and check if you see the ESP32 device in this app (if you see it in this app, you can be 100% sure that the problem is not ESP32 hardware/firmware, phone related)
 
Last edited:
Did you remove the jumper after flashing? If you still have the jumper connector in place, the esp32 stays in bootloader/flashing mode (ready for flashing) and then you won't see the esp32 bluetooth device (it won't advertise).

Also make sure that the app/esp32/controller firmware versions are compatible with eachother

My versions:
App: FW version: 2.1.12
esp32: FW version: 1.2.1
TSDZ2 FW version: 16

As of this writing i believe these are the latest versions

Good luck,

Cheers,
Ray
Thanks. I did remove the jumper. I do have the latest versions. (The app is now 2.1.13)
I do have a question about the behavior of the FTDI board. When I connect it to the ESP32 board without the jumper, the red LED comes on for about 10 seconds and then goes out. The blue LED comes on flashing and continues after the red one goes out. When I connect up to program it, with the jumper installed, only the red LED comes on for 10 seconds and then goes out. No LED's light up when I flash it. Does that seem normal?
 
Thanks. I did remove the jumper. I do have the latest versions. (The app is now 2.1.13)
I do have a question about the behavior of the FTDI board. When I connect it to the ESP32 board without the jumper, the red LED comes on for about 10 seconds and then goes out. The blue LED comes on flashing and continues after the red one goes out. When I connect up to program it, with the jumper installed, only the red LED comes on for 10 seconds and then goes out. No LED's light up when I flash it. Does that seem normal?
Can't remember the flashing leds order/colors, but i think you see something like 'flashing done' at the end of the flashing.
Also try to run the esptool with administrative rights (Windows Start button, CMD, run as administrator -> console/dos box, cd to the esptool directory and then run flash.bat)

ADDON:
1. when you start the flashing i can remember that you also see some kind of message that the FTDI is connected to COMx (com5 in my case)
2. you can also try to set/change the specific com setting in windows device manager to:
Bits per second: 115200 (default it is 9600 i think)
data bits: 8
parity: none
stop bits: 1
flow control: none

1680116992701.png
 
Last edited:
I think you may be on to something here. I tried running CMD as administrator but I still get this error:
.\flash.ps1 : File C:\Users\Bob\Downloads\esptool\esptool\flash.ps1 cannot be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ &{.\flash.ps1 }
+ ~~~~~~~~~~~
+ CategoryInfo : SecurityError: :)) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
 
I think you may be on to something here. I tried running CMD as administrator but I still get this error:
.\flash.ps1 : File C:\Users\Bob\Downloads\esptool\esptool\flash.ps1 cannot be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ &{.\flash.ps1 }
+ ~~~~~~~~~~~
+ CategoryInfo : SecurityError: :)) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
That does not look good. I think you did not flash the esp32 (flashing never happened), hence you don't see it in the app.
Try this solution and flash again:
 
Last edited:
Thanks. I was able to change the permissions and run the script. The board flashed and confirmed. From the app now I can see the bluetooth from the ESP32 and pair with it. Pairing succeeded. However the bluetooth icon at the top of the app is still greyed out with a slash through it. Also the ESP32 configuration and Bike configuration are greyed out in the menu. When I click on the icon at the bottom of the app (white arrow in red circle) the app closes with this message.
 

Attachments

  • Screenshot_20230329_161254_Device care.jpg
    Screenshot_20230329_161254_Device care.jpg
    119.8 KB · Views: 4
Thanks. I was able to change the permissions and run the script. The board flashed and confirmed. From the app now I can see the bluetooth from the ESP32 and pair with it. Pairing succeeded. However the bluetooth icon at the top of the app is still greyed out with a slash through it. Also the ESP32 configuration and Bike configuration are greyed out in the menu. When I click on the icon at the bottom of the app (white arrow in red circle) the app closes with this message.
OK I have disconnected the TX and RX pins from the FTDI board and only using the 3V and ground. In the app I can see and pair with the ESP32 and I do not get the error message. The BT symbol is still greyed out. Maybe I just need to install it in the TSDZ2 now.
 
Thanks. I was able to change the permissions and run the script. The board flashed and confirmed. From the app now I can see the bluetooth from the ESP32 and pair with it. Pairing succeeded. However the bluetooth icon at the top of the app is still greyed out with a slash through it. Also the ESP32 configuration and Bike configuration are greyed out in the menu. When I click on the icon at the bottom of the app (white arrow in red circle) the app closes with this message.
1. Did you already connect the display and TSDZ2 to the board? If not, it is normal that you don't see all options (some are grayed out). However the icon should be green, but you should see an extra red exclamation mark (red triangle) when the LCD and/or TSDZ2 controller are not connected.
1680124277033.png

2. 'When I click on the icon at the bottom of the app (white arrow in red circle) the app closes with this message' -> remove the 2.1.13 app version and install the 2.1.12 version (i think the 2.1.13 version was never officially released, 2.1.12 is the latest release on github)

BTW: are you using the TSDZ2 with throttle pin (8 pins instead of 6 pins)? The wiki only shows the 6 pins wiring diagram.
If you have the 8 pins connector (extra throttle pins) you can use my wiring diagram for the correct wire colors (check them to be sure with a volt meter):

1680123589709.png

Cutting/splitting/soldering the extra wire connectors (JST) should be straight forward. Just don't rush it, take your time and do 1 wire at a time.
 
Last edited:
1. Did you already connect the display and TSDZ2 to the board? If not, it is normal that you don't see all options (some are grayed out). However the icon should be green, but you should see an extra red exclamation mark (red triangle) when the LCD and/or TSDZ2 controller are not connected.
View attachment 331987

2. 'When I click on the icon at the bottom of the app (white arrow in red circle) the app closes with this message' -> remove the 2.1.13 app version and install the 2.1.12 version (i think the 2.1.13 version was never officially released, 2.1.12 is the latest release on github)

BTW: are you using the TSDZ2 with throttle pin (8 pins instead of 6 pins)? The wiki only shows the 6 pins wiring diagram.
If you have the 8 pins connector (extra throttle pins) you can use my wiring diagram for the correct wire colors (check them to be sure with a volt meter):

View attachment 331986
I have not yet connected to the display and TSDZ2 controller. I do have the 8 pin version with throttle. Thanks for the diagram. I will also plan to install a temperature sensor.
The WIKI shows the app updated in Nov 22. New Android apk release · TSDZ2-ESP32/TSDZ2-ESP32-Wiki@78f0277
 
I have not yet connected to the display and TSDZ2 controller. I do have the 8 pin version with throttle. Thanks for the diagram. I will also plan to install a temperature sensor.
The WIKI shows the app updated in Nov 22. New Android apk release · TSDZ2-ESP32/TSDZ2-ESP32-Wiki@78f0277
1. Yes, that was the main reason for me to install the TSDZ2-ESP32. It has an extra GPIO for the temp. sensor. This way, you can have both the throttle and the engine temp sensor.
2. Nevertheless, try use the 2.1.12 app version. The bluetooth icon should be green (even if you haven't attached the LCD and controller yet)

Another tip (maybe for later): I use this kit for better engine cooling/heat dissipation (did not order the extra cooling fins). The shop is from Poland and it is not that expensive (except for the cooling fins, but i think you don't need them):

This is what i ordered and what i installed (it works really well):

I only used the thermal glue for attaching the temp sensor to the engine housing. For all other parts i use the artic 4 thermal paste, because i still want to be able to take the tsdz2 apart easily when it needs maintenance.
 
Last edited:
1. Yes, that was the main reason for me to install the TSDZ2-ESP32. It has an extra GPIO for the temp. sensor. This way, you can have both the throttle and the engine temp sensor.
2. Nevertheless, try use the 2.1.12 app version. The bluetooth icon should be green (even if you haven't attached the LCD and controller yet)

Another tip (maybe for later): I use this kit for better engine cooling/heat dissipation (did not order the extra cooling fins). The shop is from Poland and it is not that expensive (except for the cooling fins, but i think you don't need them):

This is what i ordered and what i installed (it works really well):

I only used the thermal glue for attaching the temp sensor to the engine housing. For all other parts i use the artic 4 thermal paste, because i still want to be able to take the tsdz2 apart easily when it needs maintenance.
I am planning to do some thermal mods as well. I did finally find and install the 2.1.12 version and the BT icon is green and the other menu items are available. Thanks.
 
Last edited:
Tried to install the bluetooth board today but no success. The board connects to the phone and I can see the temperature sensor is working. When I try to install the firmware to the bike, it does not finish. I have selected Bike firmware update, select file, TSDZ2-V16.hex.. The app shows "waiting upload" then after a while, "Rebooting" but never finishes. There is a red triangle at the top of the app that says "Error Controller Communication error."
Any suggestions as to what to try?
 
Tried to install the bluetooth board today but no success. The board connects to the phone and I can see the temperature sensor is working. When I try to install the firmware to the bike, it does not finish. I have selected Bike firmware update, select file, TSDZ2-V16.hex.. The app shows "waiting upload" then after a while, "Rebooting" but never finishes. There is a red triangle at the top of the app that says "Error Controller Communication error."
Any suggestions as to what to try?
What firmware is on your TSDZ2? Did you already flash the ESP version? And did you enable the bootloader? You can only update the firmware with your phone. You have to take this steps first:
TSDZ Controller Flash
 
What firmware is on your TSDZ2? Did you already flash the ESP version? And did you enable the bootloader? You can only update the firmware with your phone. You have to take this steps first:
TSDZ Controller Flash
I have been running a different version of OSF, flashed with STLinkV2. I have enabled the bootloader. I am trying to flash the ESP version from the phone app without success. It seems that I am not communicating with the controller. I will open it all up again tomorrow and test the wiring.
 
I am ready to give up on this project. It is a great idea and I appreciate all who have designed and contributed to it, but I have not been able to make it work. I have tested all of the wiring from the 8 pin connector back to the PC board and from there to the controller. I guess I will uninstall the board and hope that I can get the bike to work again. If anyone is interested in a board, let me know. I have no idea if they will work.
 
I am ready to give up on this project. It is a great idea and I appreciate all who have designed and contributed to it, but I have not been able to make it work. I have tested all of the wiring from the 8 pin connector back to the PC board and from there to the controller. I guess I will uninstall the board and hope that I can get the bike to work again. If anyone is interested in a board, let me know. I have no idea if they will work.
What firmware is flashed to the controller?

Do you have the RX and TX lines the right way around?
 
The controller was flashed with emmebrusa firmware V20.1C.2. I was unable to update it through the app. The RX an TX connections were wired as in this image:
 

Attachments

  • 1680123589709.png
    1680123589709.png
    167.5 KB · Views: 6
Back
Top