ANT+/BTLE to MQTT

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:

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

2 Likes

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. https://maelstrom.me/

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 ( https://maelstrom.me/ ) 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.

2 Likes

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 https://www.thisisant.com/ 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.

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.