Chris Lloyd

MAS.863/4.140/6.943
How To Make (almost) Anything
2019

Week 13: interface and application programming

This week, I wanted to plot my heart rate on an interface. I got my heart rate off my wrist monitor via BLE through my ESP32 microcontroller in networking week. This week, I will attempt to read and plot the data through the serial port.

I experimented with a few different languages, but chose to use Processing, which is kind of like Arduino for UI design. It was established to connect art and stem. Like arduino language is close to C, the Processing language appears to be close to javascript.

I started using this example code and the graphica library to create my plot, but had to modify the code a lot to track my heartrate. I didn't need to tokenize the data because my arduino code only was printing the heart rate number. Here is an example of my first try reading the serial port data.

I realized there were a few problems with my code. First of all, I set the x axis and y axis as opposite as I ended. I set the x axis to be time: each loop was x = x + 1; and the y axis was my heart rate: y = myPort.read();. I also realized I was picking up the data the wrong processing speed. So I had to reference my arduino code and found that it needed to be changed to 115200, which reduced a lot of the noise.

I still have some signal noise, which I'm not sure why because when I look at it on the serial monitor I only see the heartbeat number, but I was able to get it see my heart rate (the changing line on the top of the graph).

Here is my code in case you are interested. I highly recommend Processing for newbies like me.