rrrlasse / powerino

Arduino based bicycle power meter
GNU General Public License v3.0
44 stars 9 forks source link

Connecting to a bike GPS computer #2

Open orsic opened 5 years ago

orsic commented 5 years ago

Is it possible to connect to a Garmin/Polar/etc computer via Bluetooth? If not, what should be done to implement this? Thanks

rrrlasse commented 5 years ago

I'm not sure if modern bicycle computers support the old Bluetooth 2 that HC-05 offers. If they only support Bluetooth BLE, then you would need a HM-10 module instead, or maybe even an ANT+ module.

The protocol itself should be pretty simple, though. I don't have any experience in it myself, but there is a specification on the common Bluetooth GATT protocol here https://www.bluetooth.com/specifications/gatt/services

Another user contacted me some time ago and he wrote this code, which successfully sent the power part to his Garmin + Strava (the code is for a ESP32 with Bluetooth BLE): https://github.com/rrrlasse/powerino/blob/master/Arduino/power_and_display.ino

I don't have much experience in all this myself, so I'm not able to help much, though.

jura38 commented 5 years ago

hm 10 bt

Power: In sleep mode 400uA~1.5mA, Active mode 8.5mA.

hc 6 or hc 5 cc50ma

spoutnik12 commented 4 years ago

@rrrlasse Thank you very much for the amazing work put into this powermeter project! Even though your app seems to be working great I would like to be able to use apps like Strava or Zwift. For this, I suppose I will need BLE module. Do you think that the HM-10 module is directly swappable with the HC-05 (i.e. just using an HM-10 instead or HC-05 will work without code modification)? And do you think the third party app will be able to recognize it as a power meter and read correct watt values?

And do you know why the guy connecting the powermeter to his Garmin unit chose to use an ESP32?

Thanks and have a great day!

duffel90 commented 3 years ago

Many thanks for this interesting project. The manual is very good and detailed. Unfortunately the Android app does not work for me. According to the Serial Bluetooth Terminal the system is accessible. But when starting the calibration I get the error: Not connected to Bluetooth. Also sending c in the Serial Bluetooth Terminal does not give any feedback. I would also be interested in a solution for ANT+. A library has already been developed for this purpose https://github.com/cujomalainey/antplus-arduino.

rrrlasse commented 3 years ago

@duffel90 Just some steps:

1) Is the voltage at least 3.6 V? Else various components may not work and it collects no data. 2) Does the Arduino flash its LED 8 times every time you put power on it? If not, then uploading the program had failed. 3) In the Serial Bluetooth Terminal, try and send "er 0 10" (without quotes) - does it reply anything?

rrrlasse commented 3 years ago

@spoutnik12 Sorry for the very late reply. Strava and Swift use a different data format, so even if you replace the HC-05 with BLE, the apps won't recognize the Powerino.

I don't know why he used ESP32. But it needs less soldering (has Bluetooth built in) and is thus also smaller.

HosszuDaniel commented 3 years ago

Hello guys! I was the one who developed the ESP32 code! :) My goal was to reach the lowest current consumption because the ESP32 has built-in BLE transmitter. Unfortunately at that time when I was developing the code the low power bluetooth was not fully implemented by Espresso, therefore the ESP had a fairly high current. As far as I know they have already done some improvements, but I did not update my application.

For Strava or Zwift you have to implement the Bluetooth GATT profile communication, there must be some example code for Arduino somewhere, it is not that tricky.

Just for @rrrlasse : My next plan is to design a battery powered circuit with really low current consumption and BLE. Actually I have been postponing this project for 2 years, but now finally I started the PCB design. Hardware is going to be a Cypress MCU + MCP3553 ADC + LSM6DS gyro. Goal would be to implement over-the-air firmware update and make it waterproof.

duffel90 commented 3 years ago

@rrrlasse thanks for your answer

After some debugging I found the error. I have to set the bool comand_mode to true. Now the communication with the App works. On tuesday I will calibrate my system.

rrrlasse commented 3 years ago

@duffel90 Great, I didn't think of that. I have updated the wiki with a note on it.

@HosszuDaniel Please send me a link to your project when you're done, it sounds really cool! I learnt that making things water tight is actually really hard. I have a theory that temperature changes increase and decrease air pressure inside the device, which slowly over time drags water into it regardless how good you think you have sealed it. Keep up the good work! :)

duffel90 commented 3 years ago

:D so. Today i calibrate my powermeter. For the right communication between app and powermeter in the powermeter.h file this configurations works for me: bool debug = false; bool command_mode = false;

rrrlasse commented 3 years ago

@duffel90 Cool! I have updated the wiki text with a note on the problem and how you solved it.

I won't put the fix in the source code, because it sometimes gives other problems, like a big initial data queue that takes a long time to get transmitted, and other weird things too. But I hope it works for you :)

kudmich commented 3 years ago

Anyone have an idea where the problem may be?

124002469_383163492925263_2888379607047597379_n

rrrlasse commented 3 years ago

Are you sure the HC-05 is configured to 9600 baud? If not, that would make send garbage.

It must match the btrate setting in the power meter.ino file

rrrlasse commented 3 years ago

Maybe it could also be the Charset of the Terminal app. windows-1258 works

kudmich commented 3 years ago

@rrrlasse

I checked the baud rate of the HC-05 module with the AT command, everything is standard (9600). Uploading the program checking this module is exemplary.

Bluetooth terminal - all charsets checked, unchanged.

I will probably risk buying a new module, because I have no idea what the problem may be.

rrrlasse commented 3 years ago

@kudmich what if you upload a really simple program that just sends "Hello World" in a loop, like https://forum.arduino.cc/index.php?topic=21295.0 ? The program in that link also uses "Serial" (and not SoftwareSerial) just like my wiki, so the wires must still go to RXI/TXO.

If such a simple program also fails, then at least it would be easier to get help on real Arduino forums with more experienced people.

kudmich commented 3 years ago

@rrrlasse Thanks for the suggestions, I was able to fix the problem. I uploaded the program to arduino with the baud rate set to 9600, connected to the serial monitor with a cable and changed the values one by one. With the value of 19,200, the correct data from the sensors began to be revealed.

The next step was to scale the HC-05 module to receive data at 19200 baud and everything started to work properly.

An interesting fact is that uploading a program with "n" baud rate also increases the value by "n + 1" in the HC-05 module.

{A: 9600> H05: 19200} {A: 19200> H05: 38400} {A: 38400> H05: 57600}

I don't know why arduino reacts this way, possibly because of my Chinese version of the arduino clone.