I have boxes of SBC and MCU units bought with the best intentions but not used. However, another should be arriving in the post soon (Pitaya Go) and I’m hoping I’ll be able to get my finger out and figure out how to whip up a device to read from my fitness kit and then output to MQTT.

In our house all the automation devices talk to the MQTT broker and just about anything can be done, usually with NodeRed.

My intention is to control the fan speed from heart rate. Yes, I know there are other options and projects for doing this but that’s just the first possibility. As my pain cave is on the far side of the house and upstairs away from other humans and I’m overweight and unfit I will probably set it to flash all the lights in the house, turn off the telly and announce on all the Alexa units “heart attack in progress” if my HR drops to zero or goes above 200 with the bike speed/cadence at zero.

I could also log all data to a database as well as ambient temperature, humidity and so on.

Good idea?

Or just turn on the fan and select some easier workouts. Less time building the Enterprise, more time getting used to training indoors. :ok_hand:t3:

1 Like

I have workouts of the correct intensity set in my training plan and I’ve been using TrainerRoad pretty much since its inception.

Thanks for the advice but I was rather hoping for some technical contribution.

I’m not aware of any way. I think ANT dongles get dedicated to a piece of software so you’d need a second. Not sure about bluetooth. I’ve resorted to having 2 fans controlled by Sonoff devices. The chip in them is very common and you can flash them with loads of different firmwares. You can then connect to MQTT. This facilitated timers and being able to turn on using your phone.

An easy option would also be attaching a temperature sensor to a bottom bracket or trainer and using threshold(s) to turn on the fans.

If you attached a Sonoff TH1 with a temperature sensor to the trainer you could use it to start the Sonoff Basic controlled fans without any messing about with firmware by creating a ‘scene’ in their app. That might be easiest.

Seems like a cool project if you have the time.

What’s your plan for driving the fan at variable speed?

I like to geek as much as the next guy but i suspect your thinking is flawed.

Unless you’ve built a wind tunnel you should be giving yourself maximum cooling from the outset, your heart rate will rise from effort anyway , why confuse that by factoring in the increased effort and heart rate from insufficient cooling and then reactively increase the cooling?

It sounds detrimental to the principle of getting faster


I don’t understand where the wind tunnel comes in but an increase in heart rate is not just about getting blood to the lungs and muscles but also about getting blood to the skin for cooling. On my workouts my HR is low during the warm-up and at it’s highest on the last interval and I usually knock the fan speed up from minimum to maximum over the workout. I haven’t analysed the reasoning that’s just what works for me. However, that whole discussion is an aside because you can link the fan speed to any metric you want! Speed, power, HR average over a period. Is the Wahoo wind or whatever linked to speed?

Someone, who is way more capable than I, already has a fan specific device in development.

In fact, the concept of what I’m looking is even more general and needn’t even involve the fan.

It’s more about getting ANT+ or BTLE to MQTT. If nothing else, you could have a database record of all activity in your gym and the ability to report off that.

A really simple example. Put a WiFi device on the socket to your smart trainer (Shelly/Sonoff circa £10) and then have it power up whenever you put on your HR strap and then power down 5 minutes after you take off the HR strap. Have the lights in your pain cave turn off 10 minutes after all ANT+ signals stop.

@DaveWh time…that’s the main hurdle. However, I can see some real world usage for me so hopefully that’ll provide some motivation.

No idea on controlling the fan speed. I think this guy ( ) does his on the mains input side. That would seem to allow it to work with many, if not all, fans.

@eerke - Yep. I’m looking at a MCU that has ANT+. WiFi, BTLE, Zigbee all on the board. I’m thinking small box which you connect to USB for power.

Your Sonoff devices use the ESP8266 so yes, this is the sort of device (as well as the Shelly) I have in my house.

Now…if someone could hack a Withings temperature sensor and have that aimed at you while you workout and broadcast body temperature as ANT+ ! :slight_smile:

The geek in me gets what you after but struggling to see any down side in just having the fan on full from the start.


Who has the fan on full blast during the first 5 minute warmup or so of a workout? I don’t but if you do that’s your choice. I really wasn’t looking to discuss fan speed and usage.

Forget about the fan. Pretend I didn’t even mention the fan.

The thread was supposed to be about the viability and usefulness of an ANT+/BTLE to MQTT (or HTTPS) gateway and with any luck, it’s implementation.

For Ant+:
One simple option is probably a Raspberry Pi, Ant+ USB stick and this python library and example:

The library is a bit of a mess from what I remember, but it did work for the most part. The example is a bit cryptic unless you are familiar with Ant+ specs. If you want to delve deep into ant+ world, all the specs can be found from you just have to register and accept a bunch of slightly disturbing license agreements.

For BLE:
A new Raspberry Pi with BLE support and implementing something using the bluez stack might work? I haven’t tried it but there are some examples like this behind google:

For truly embedded Ant+/BLE development I’ve personally done some fun projects using NRF52832 chips. Plenty of examples for connecting to and pretending to be various BLE/Ant+ HR devices. The chip doesn’t have wifi/ethernet though so it doesn’t suit your needs of being able to push stuff to MQTT.

1 Like

Thanks for that @tny

I had considered the Pi and those libraries. My own preference is for ANT+ due to the one-to-many connection ability.

The board I have coming is the Pitaya Go which at 34€ has an NrF82840 Soc as well as an ultra low power WiFi controller as well as USB-C and LiPo connector.

Looking forward to it.

Maybe it exists now but when I last looked there was a lot of work.

The Sonoff devices usually have one free input and the chip can be programmed from within the Arduino IDE. I think I’d add ANT that way if I could be bothered. Bluetooth is encrypted and many devices only allow one to one pairing. Sniffing the ANT signal would be easier.

1 Like

I’ve been thinking and tinkering along similar lines - been fairly time constrained of late.

My thought was having a set of neo pixels in the garage that change colour depending on how hard I’m working :-). I was initially thinking of driving them with an Arduino via ANT+ (for the same reasons as previously mentioned, I can piggy back off the existing sensors).

Couldn’t find any Arduino based ANT+ info, so I switched to Raspberry Pi for the sensor reading (I’ve already got a Raspberry Pi in the garage running a touch screen in the garage).

I’ve got it as far as reading HRM data via some Node (Python lib’s seemed pretty horrible and wouldn’t work reliably for me) - I was thinking of connecting the Pi to the Arduino via BLE, but then realised I was massively overthinking it and I’ll probably hook it up to the NeoPixels via a FadeCandy (mostly because I have one kicking around and it’s just a USB connection to the Pi and fairly simple to control from Node as well).

Time is my main problem - work has been pretty busy of late and I’ve not had the brain capacity to sit and code on a weekend !

If I make any progress I’ll update here.

1 Like

Sounds interesting.

I do like the idea of two strips on neopixels either side of the trainer moving from green through to red linked to power output and chasing front to back at a rate linked to speed.

Might be getting carried away here.

I’ve got a working prototype :slight_smile:

Been around the houses with reading the ANT+ as I said in my previous post, I couldn’t initially get the Python libs to work, so switched to Node - couldn’t really get on with Node so thought I might give a C++ driver a whirl, couldn’t get that to compile on the PI so I went back to python and found some more on-line stuff and hey presto I can read reliably from ANT+.

Currently it’s configured to just read any HRM that is close enough, I’ve got a Wahoo TICKR, and use an Amazon fire tablet for Trainer Road which basically means it’s using both BLE and ANT+ at the same time. Messages getting dropped onto the MQTT queue (I’m running Mosquito on another Pi).

I diverted from the fade candy, just because the cabling was going to get silly (the LED’s are in the garage roof), I could have put a Pi Zero up there, but I want to be able to turn it on and off simply (and pulling the power on Pi is not always safe), so back to the Arduino idea to see if I could get a Wifi enabled one, and if there are libraries for reading MQTT.

Of course there are :slight_smile:

Bit more coding later, and I’ve got a basic setup using an Adafruit M0 Wifi Feather, with the PXL8 FeatherWing to drive the Neopixels. I’m using a library called FastLED to do the LED patterns.

Its’ nice and easy to test because I can drop a message on the queue to switch the LED patterns.

At the moment it’s all HRM based, but if I’m understanding the ANT+ library correctly it’s fairly easy to target other device types and then relay the data out.

I’ll try and write it up a bit better in the next few days, with some videos of the LED’s reacting to changes, but I’ve achieved what I wanted to - something simple that I can just turn on at the mains from the LED side of things, and not have to run any commands on a pi to start it up.


Write up here (with a small video that shows the different patterns):

If there’s anything specific folks want to know feel free to ask (and I can update the blog accordingly).

1 Like

@Linsey do you have youre code somewhere available? I am looking into this topic right now and would be happy to get a jump start :grinning:

I’ve DM’ed you about how to get you the code :slight_smile: