lefty01 / ESP32_TTGO_FTMS

ESP32 based treadmill speed and incline sensor and BLE Server exposed as FTMS Service
MIT License
41 stars 7 forks source link

Building the Project - slight problems #14

Closed Joeee83 closed 2 years ago

Joeee83 commented 2 years ago

Hi there, i just ordered a threadmill, but it is without bluetooth support. So i searched the internet and found this great project. All the eletronic parts are here, so I started out by following your beginners guide. In addition to that I added a profile for my threadmill. (Without the real diameter for the roll) So far its just the TTGO ESP32 running the website, connecting to my mqtt server. All working fine. The next thing I tried was to connect it to my smartphone (S10+) via BLE. In the Bluetooth settings i can connect the android os to the module. But I can't find the threadmill in an app. (zwift nor kinomap) What am i doing wrong? Do sensors have to be connected befor connecting to the software? Any help is apreciated. TIA

Joe

lefty01 commented 2 years ago

Hi, nope the BLE server part should work regardless of any sensors. That's how I started just adjusting the speed and incline manually ( cumbersome but works). So that said it's hard to predict what might be wrong. Are you running zwift on the android? It will tell you to turn on location server I guess you did that? What I used in the beginning was the nrf connect app: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en_US&gl=US you can try this first and see if it connects to the ESP32 (shoud advertise as FTMS something) if you can connect via this app you should be able to read speed for example as shown here:

Capture+_2021-03-08-09-15-29

if that does not work ... it's hard to predict ... I would then try to add some debug with this function: void initBLE() { ... tft.println("initBLE"); ... and see if there's any error in setting up bluetooth.

are you using the (now default) NimbleBLE ... you would unless you undefined it in the source.

Joeee83 commented 2 years ago

Wow what a reaction time. Thanks for the tips. Especially for the bluetooth app. Didn't know this exists. On my phone the bluetooth app finds the same UUID but it doesn't show values. I didn't uncomment NimbleBLE.

I can now start zwift and see as well as connect to the project. The thing that made it work is: I didn't connect the android to the device first. doh If i choose connect in the bluetooth setting then it won't be found by the running app.

So the next step for me is to open up my threadmill and find out how the pulse for the rotation is generated. Then to attach the sensors and see how to integrate it into my machine.

BTW I found my machine to also show up on as a ble device, but with different und unknown services.

lefty01 commented 2 years ago

cool. also interesting you can see your treadmill as BT device, which model is it btw?

as for the "rotation" sensor ... usually you should be able to open the motor "room" of your treadmill ... also required to clean up the dust in there once in a while. most likely you will see the motor that drives the front belt wheel via some strap. within that belt wheel there's usually one or even two magnets ... then there is the reed switch with some cable going to the control unit. that is the thing detecting each wheel turn. I can see two options here a) use the existing sensor and use wires in parallel or b) what I did buy extra reed sensor and mount it next to the existing one ( I used some hot glue) I have some 10k pull-up resistor that connects one wire of the sensor to the gpio pin. hint: google image search treadmill speed sensor

before that I used the two IR-Sensors and had marked the belt (same concept as the RunN sensor) that should work as well ... but it's a more "shaky" then the reed sensor readings.

let me know how things are going. so maybe we can close this issue? just open new one for anything that pops up.

zingo commented 2 years ago

On my treadmill a Northtrack 12.2 Si, but this will probably be true for all MC2100ELS based models (a popular motor control board) the "rotation" sensor data is going up to the "CPU/Computer" in the console as one of the cables in the harnest as a 5V signal. In my case I just did a Y split of the cable and used a levelshifter from 5v to 3.3V and then connected it to the ESP32.

Joeee83 commented 2 years ago

Hi, yesterday i did some diggin. The threadmill is a Hometrack HT5000 sold and branded by Miweba in Germany. I first opend the Motor compartment. As expected from a chinese product wire handling looks a bit wild west, but is surely practical. (A few connectors needed a push to sit right were they belong.) The controller PCB is a JFDZ_PBJ_XKYSCOMST V 1,17 and can also be bough as a spare from ali. Only the inclination seems to have a closed loop design. For the drive motor i can't see any feedback to the pcb. But the DC labeled motor has dual shafts. On one side there is a poly-V-belt and on the other side ther is a slotted disc. I can also see 2xM4 in the motors die cast housing for attaching a light barrier to it. This would be a managable job for me, as i can design and print 3d FDM parts. But doing so would give a much higher frequency of interrupts to the ESP. As i didn't find a bluetooth chip in there i had a look at the user interface PCB in the top of the machine. It is build like a configurable motherboard for different modules with the display on its back. On the PCB there is: A Chip for determining the pulse of the user(SH601), a 32k Flash (HC16LC16) , a RAM Mapping 48x8 LCD Controller (HT1623) some audio and level shifting stuff as well as a BLE SoC CMT4502 from HOPERF. Its connector is labeld as GND, RX, TX, VCC. The foiled buttons seem to be connected in a 5x4 matrix style to the PCB. The controller PCB is connected by 5 wires. From here I have to decide what to do: I could try to sniff the serial line to the bluetooth module. This would surely be the most elegant way for a ble retrofit. It questionable if there is communcation when the app doesn't connect to it. The thing is - when I scan the QR code on the machine it forwards me to an app in the play store. I installed it but didn't allow permissions for the local files. So this doesn't work atm. It questionable if there is communcation when the app doesn't connect to it. Unless i find an older of my phones with ble but without my private files. Goind the factory RXTX way has the risk of not understanding the communication but also doesn't seem to give me the real speed.

i think this could be closed as my connection problem to the project is solved. I could post updates on my attemp here if you like it. You can decide.

lefty01 commented 2 years ago

Hey ... thanks a lot for sharing this info! so if this project by any chance will further mature it's good to know more about different treadmill types. from reading the treadmill description of this model it could very well be that the designed BT interface is kind of unidirectional such that the training app sends speed and incline to the treadmill only. but would be kind of surprising if there's no return signal to get "real" incline/speed back to the app. at one point this sounds pretty cool as it could open up a whole bunch of new possibilities (eg. grab incline from zwift and forward to treadmill) without further wiring .... BUT maybe reversing the protocol isn't straight forward.

So is your thinking that you might see speed and incline values on the Tx pin? so eg. read serial line via an ESP32 and than transmit as fitness machine data?

lefty01 commented 2 years ago

... btw maybe we can use the wiki to document different treadmill models.

zingo commented 2 years ago

Was thinking about the wiki also, it would be good for each new person to find the different findings and ideas to fix them.

Joeee83 commented 2 years ago

The advertisment states: "Mit ihr werden Werte wie die Laufgeschwindigkeit via Smartphone an Ihr individuelles Trainingsziel angepasst." With the app values as running speed are adjusted to your individual training goal via Smartphone. I also took pictures of the inner parts.

zingo commented 2 years ago

Nice I see you have already started :) Do you want us to edit wiki's in out fork or directly here, if so we need permission :) Im not sure the wiki parts can be merged easy to/from forks but if it is I don't mind using the fork, whatever you think is best/easiest for you.

lefty01 commented 2 years ago

I would think it's easier to edit the wiki directly instead of forking it and add pull-requests. as collaborator you should have been able to edit it already ;) I now removed the wiki access restriction so anyone with an github account should be able to edit/add pages. ... hoping there won't be offensive or otherwise inappropriate content being added.

zingo commented 2 years ago

I didn't have any edit button before but it poped up now, thanks. ... hoping there won't be offensive or otherwise inappropriate content being added. If that starts to happen we can always close it then.

lefty01 commented 2 years ago

closing ... as discussed