I've tried to get in the habit of counting steps (collected via my Bip and written into InfluxDB).
However, a few months back, I bought and "under desk bike" - basically a set of pedals attached to a resistance wheel.
This has a fidget-spinner like quality and I'm quite often pedalling to some extent.
However, it bugs me that this activity isn't tracked at all.
The bike has a little cycle computer built in, so can display calories burnt, RPM "distance" etc, but it only exists on that device.
In theory it should be linked up to a reed switch and magnet, with the computer applying a small voltage and counting pulses.
What I'd like to do with this project is
Ultimately, I'd like to use a Raspberry Pi Zero for this (it doesn't make sense to use a full-sized Pi), but it probably makes sense to start with a Pi that I've got knocking around.
Activity
31-Aug-24 10:31
assigned to @btasker
31-Aug-24 10:37
31-Aug-24 10:42
31-Aug-24 10:55
OK, so I've plugged my test pi (camille) into the network. Has come up with IP
192.168.3.175
(username isben
)31-Aug-24 12:45
31-Aug-24 12:47
I'm using GPIO pins 1 (3.3v) and 7 (GPIO 4).
I've not used a pull-down resistor - my intention is to enable pull-down mode in the code and use the Pi's built in resistor.
There are 2 blips per cycle
I think what happens is the switch closes as the magnet approaches, opens when it's directly alongside and then closes again as it goes out the other side, ultimately opening once it's back out of range.
31-Aug-24 13:17
One of the things we need to know is what each blip (or pair of blips) is worth.
I've connected it's display back up and will slowly turn the peddles to see how things increase.
One thing I noticed: the counter counts both blips, so it's actually reporting double. It looks like double blips only happen when moving very very slowly.
7 turns per calorie.
It doesn't do a distance
31-Aug-24 13:21
mentioned in commit 5b5255d35fbc011787f61a456103e65af27da2f4
Message
feat: commit initial PoC script (misc/wifi-cycle-counter#1)
31-Aug-24 14:26
With a bit of fiddling about and swearing, I've been able to work out that the radius of the wheel inside is about 5.6cm.
We can use that if we wanted to calculate distance + speed.
In practice, they're fairly meaningless numbers (all it really tells us is how far the magnet has travelled) but might be interesting as a general indicator
31-Aug-24 14:43
mentioned in commit bbfaa67bce98d4369cc155b51ebd49017b3b96dd
Message
feat: only emit stats periodically (misc/wifi-cycle-counter#1)
31-Aug-24 14:43
mentioned in commit 2121940bb6ebc96646543c304a30ccfeb01aa6fd
Message
feat: add option to calculate speed and distance (misc/wifi-cycle-counter#1)
31-Aug-24 15:31
Decided this should be a telegraf
execd
plugin rather than a standalone script.Installing telegraf:
The first attempt at running via Telegraf failed with
Fixed by doing
and then restarting Telegraf
31-Aug-24 15:37
mentioned in commit f405716a7ce495fece68a7b55ba6df37eebea196
Message
feat: add example telegraf configs (misc/wifi-cycle-counter#1)
31-Aug-24 16:37
So, it turns out that Grafana doesn't support centimetres as a unit...
So, in my dashboard I've had to multiple values by 10 to get millimetres (which they do support)
05-Oct-24 10:11
There's a writeup of the project: Building a Raspberry Pi Cycling Computer