Open MortenVinding opened 1 year ago
I haven't tested this functionality, so it wouldn't surprise me if there were a bug in it. How does your bike's sensor signal look? Is it a nice square wave?
Wow quick response 😊
That’s a very fair question. The input is from a dedicated heart sensor circuit on the bike, but I have only measured it with a multimeter. I have a simple DSO120 scope, I can hook up later today.
The small circuit with the bloop IC is the heart circuit:
added:
Serial.print("heartRate: ");
Serial.println(heartRate);
Serial.print("lastHeartRateTime: ");
Serial.println(lastHeartRateTime);
right here:
#ifdef HEART_PIN
static uint32_t lastHeartRateUpdate = 0;
if (millis() >= lastHeartRateUpdate + 1000 && lastHeartBeatDuration > 0 && millis() <= prevHeartBeat + 4000) {
uint16_t heartRate = (10000 + lastHeartBeatDuration/2) / lastHeartBeatDuration;
lastHeartRate = heartRate;
lastHeartRateTime = prevHeartBeat;
Serial.print("heartRate: ");
Serial.println(heartRate);
Serial.print("lastHeartRateTime: ");
Serial.println(lastHeartRateTime);
But the heartRate is exactly the same as reported in Zwift.
Do you have any suggestions to where I might add some more debug output?
Try changing the 10000 to 60000.
Try changing the 10000 to 60000.
Guess you looked in my fork, because there I have already raised it from 1000 to 10000 😉 I now have tried to change it to 60000. I looks to be close, but now maybe a bit to high. But the heart measurement seems to anyway be a bit unreliable, also for the build in computer. So maybe it's just that.
I would say it's good enough now. Next step for me is implementing resistance control. That might be a bit more involved, but I hope I can steal some code from this: https://github.com/doudar/SmartSpin2k
All though my requirements are different, since my bike already have electrically controlled resistance using a small motor and a feedback potentiometer.
Once again, thank you so much for your help. Really appreciated.
In time I might make som pull requests, if you would like the OTA update feature etc.
I have build for heart sensor on pin 19. It's connected to the existing heart sensor circuit in my exercise bike to pin 19, but it is counting very low. Not even 1/10 og the actual heart rate, maybe 1/80 - 1/100. I can't really figure out the calculation, so hope you can help med figure out what is wrong.
/Morten