Spinning Bike Made My Head Spin
This story was originally published by Tan Ding Hao on SIOT’s Medium blog
I have spent the first half of 2021 interning at the SmartGym team, under Sensors and IoT (SIoT) Division of GovTech. As you may have guessed from the title, I am responsible for the spinning bike’s development. Kudos to Keith (a fellow intern) for coming up with this ingenious title!
This article is organized into the following sections:
What is SmartGym?
SmartGym is a proof-of-concept (POC) by GovTech to help citizens exercise smarter through the use of technology. The SmartGym team is responsible for the end-to-end (E2E) development of the project, from the development of the sensors (data collection) to developing a mobile application as a user interface.
The Development
Spinning bike is SmartGym’s second POC product. My responsibility was to bring the bad boy to production. Below is the simplified breakdown of the E2E development of the IoT pipeline.
Fig.2 Simplified data flow for the spinning bike.
Sensor Firmware
The sensor node has an off-the-shelf power meter and a Base Module (BM). The BM allows communication between the power meter and gateway that links back to the DECADA IoT platform. Workout metrics from the power meter are received via Bluetooth Low Energy (BLE) and decoded before sending to the gateway for further computation.
This was one of the hardest parts of the development which best sums up in one meme 😂.
BM uses C++ which was a new language to me. It took me a while to get used to the syntax and understanding object-oriented programming (OOP). Next, I had to enable a secure MQTT connection with the gateway.
There were multiple issues that I had to resolve along the way, but the main one was that the BM was also experiencing timeout which made it unstable. Suspecting it was a memory leak, I conducted an extensive memory trace to detect and rectify the leaks. After multiple iterations and disappointments, I can still remember the euphoria when I finally got the BM into a functional and reliable state. “Eureka” indeed!
Algorithms in the Gateway
Gateway is a centralised point for the sensors in a particular location. It handles heavier weight data processing which the sensors could not. For the spinning bike, two types of data processing are needed: workout metrics computation and throttling. Data throttling reduces the latency of the whole pipeline. After numerous tests on different use cases, the gateway portion of the IoT data pipeline is finally completed!
Frontend and Backend
Frontend development was fun as I got to try something different. Learning about widgets and business logic (BLoC) which the latter tends to get a bit convoluted.
Backend development was daunting because there are many things going on. However, after the experience, I better understand and appreciate the entire development process.
Bikes Deployment!
Yesss! It was finally the day for deployment. I was so excited to finally see the fruits of my labour go live in production!
The product was first deployed in the office gym (aka research laboratory) for a month of observation before public deployment.
Unfortunately, I realised that I did not have any photos of myself with the bikes as I was too engrossed with the setup. With the gyms closed due to COVID-19 restrictions, it was difficult to get a picture with them. Nevertheless, I found this photo and decided to have some fun with it 😏.
Takeaways
No, not those that we dabao because of no-dine-in restrictions.
Jokes aside, the first takeaway will be doing cool things that I usually do not get to experience in schools such as 3D printing, laser-cutting and PCB designing. I love doing hands-on tasks.
The second takeaway is growth. While developing on the spinning bike, I unknowingly gained some personal development. My programming skill expanded with the guidance from the team and the various hands-on experience. I grew to be more resilient and resourceful in problem-solving from those “sian” moments of product failures during the development phase. I am grateful to have experienced this enriching internship!
The last takeaway is knowing the awesome people in the SmartGym team! They made the entire process enjoyable! The team culture is welcoming, making every member feel valued. Special thanks to my mentors, Chin Hiong and Joaquin, for their guidance and patience!
Conclusion
The internship was very rewarding and I could not have spent my time better. Hopefully, through this article, I get to share my joy of development with you guys! To thank you for reading up till this point, here is a meme to end the article. Cheers!
Find more about GovTech’s technical products and solutions on Singapore Government Developer Portal.