DIY Bicycle Power Meter – Part 1
Having used a power meter on my bike for a few years now, and having numerous issues with my Generation 1 Stages power meter in particular got me thinking ‘How hard would it be to make my own power meter?’. I knew from the start that it would be non trivial, and that it would never be to the quality of even the most unreliable Stages, however it was going to be a challenge that was not only interesting, but forced me to learn a whole heap of new things, and would keep me entertained whenever I had an hour of free time.
The below video is a quick overview of what the last few weeks of prototyping has resulted in, and after it I’ll go into more detail about some of the issues I experienced, how they were resolved, and what the next part of the project will entail.
So as the video showed, the power output that was reported was rather horrendous. I had assumed that due to the sample rate and the (lack of) signal processing that I had implemented, that the values would vary greatly, however always be above zero. This assumption was incorrect as whenever the right pedal was being pushed down, the weight from my left leg was pushing back on the left pedal and creating a (small) negative power/torque reading. Taking multiple data samples per revolution and averaging them should help stabilise the readings, and this in combination with a rolling average of the previous few seconds should help smooth out the values reported from the power meter.
I hear you asking ‘Well Josh, why didn’t you implement that signal processing into the power meter then?’ and the main reason is that all I wanted to get from the power meter at this stage of the project was a go / no go that the idea was feasible. This was because I plan to move away from the ESP8266 to a SoC which is capable of ANT+ communication, such as the Nordic Semiconductor nRF52832, so that I can report the power data to one of the many head units on the market. As this change would require all of the code to be (re)written in C, I didn’t want to spend any extra time tuning the prototype as it will never be used.
Another issue I encountered was with frequent crashing of the ESP8266. I spent many hours battling with random watch dog resets, using the trusty Serial.println() call to debug in an attempt to determine what line of code was causing it to crash intermittently. After dissembling all the components and building it up with fresh parts to rule out a hardware fault, I finally determined that it was the HX711 library that was causing the watch dog timer to trigger. This was found to be the cause as I spent a bit of time in the HX711.cpp file commenting out lines and changing yield() commands to delay(1), before it finally would work reliably without triggering the watch dog. This was another reason the data processing wasn’t implemented, as my ability to stare at a screen and get error message after error message without going crazy isn’t as long as I would like. The code used for the power meter can be found on GitHub, along with the modified HX711.cpp file which ended up solving the crash issues. The code is light on accompanying documentation / schematics as I can’t suggest to anyone that they should actually use it, however feel free to contact me if there is anything I can help clarify.
I also spent a large amount of time attempting change the range on the MPU-6050 gyro, due to yours truly not reading that the register which needed to be set had reserved bits, and as such I was setting the right values in the wrong bits (i.e. the wrong values) which resulted in no change to the range of measurement. When I found my error it was safe to say that I was rather disappointed in the oversight,
The next step for the project is to duplicate what I have here but on the nRF52832, and to implement some signal processing to hopefully smooth out the power readings. Once I get to that stage, I’ll attempt to get the ANT communication working smoothly, and assuming I make it that far I’ll get a PCB fabbed up, solder all the parts on, and 3d print an enclosure so it looks a bit better than the current mess of spaghetti that are my wires.
Anyway, thanks for spending the time read about my struggles, and if you want to keep up to date on what is going on I’d suggest following me on Instagram, as I post significantly more about what is going on there than on this site, which is dedicated to larger updates.