Blog 4 - Analog In, Analog Out | Sending Rotation Data Between Micro:bits Using IFTTT and Google Sheets

 

For this project we used a Micro:bit and IFTTT to transfer rotation data from one Micro:bit to another. The idea was to capture rotation values from a Micro:bit attached to a cloud board, log them in a Google Sheet via IFTTT, and then retrieve and display those values on a separate Micro:bit using an HTTP GET request.

This experiment allowed me to explore IoT-based automation, integrating cloud services with physical computing in a straightforward yet effective way.

Capturing and Sending Rotation Data

I started by configuring the first Micro:bit to detect its rotation values and send them to an external service.

Since Micro:bit doesn’t support direct HTTP requests, we had to use a cloud board to relay the data. The values were then sent to IFTTT, which triggered an action to log them in a Google Sheets document. This setup effectively turned Google Sheets into a temporary database.

Once the data was stored, the second Micro:bit needed to retrieve it. We set up a HTTP GET request from another device to fetch the latest values from the Google Sheet. The response was parsed, extracting only the most recent rotation values. Due to difficulties with getting the HTTP GET directly with an API approach, for requests to work we set up a flask server on a laptop to make GET requests.

These are the screenshots where we initially used IFTTT and a python script to handle automation for sending requests and we attempted to have it receive requests as well , but we found it to be too slow. The latency in executing webhooks was inconsistent, which made real-time interactions unreliable.

 

Since we couldn't get http GET requests to work on the micro:bit to retrieve the data from the google sheet, Brendan wrote a python script that would make the requests locally. There is a 3 second pause because the micro:bit could only POST roughly every second so the requests would pile up since the GET requests would be much faster.

Using the Flask server

To improve response times and have more control over the process, we switched to using a Flask server fully. With Flask, we can handle POST and GET requests directly, ensuring faster execution and better flexibility in managing requests. This setup allowed us to customize endpoints, handle data processing efficiently, and reduce the dependency on third-party services. 

 This micro:bit got the rotation angle and sends it to the flask server

The flask has an endpoint which will get the rotation data from the google sheet.

 

The values gathered were then displayed on the second Micro:bit’s LED matrix using the GET request, effectively creating a simple, cloud-based communication channel between the two devices.

 

One of the main challenges was the delay between sending and receiving data. Since IFTTT processes webhooks at its own pace, there was a noticeable lag in real-time updates. While this wasn’t a major issue for logging data, it impacted the responsiveness of the second Micro:bit. This was the main reason we decided to switch to using a flask server instead.

This project demonstrated the potential of combining Micro:bit with cloud services for basic IoT applications. While the setup had its limitations, it provided valuable insights into data logging, webhooks, external API communication and switching to a flask server in a simple but effective way.

 

Comments

Popular posts from this blog

Blog 2 - HRV Demo

Week 1: HRV Review

Blog 5 - FFT & HRV