This past week and 2 days I worked on fixing the app’s squat mode and altering the knee sleeve’s Bluetooth code. I didn’t make as much progress as I would have liked to as I ran into a lot of issues trying to get my Arduino code to run after my Flora v1 boards stopped working on Monday. However, I was eventually able to fix the issues and make some improvements to my bend sensor code and the app’s squat mode.
I started this week off by trying to figure out why my Flora was unable to send the entire workout string “workoutToSend” without breaking it up and sending just 20 characters at a time. I looked into the issue quite a bit and found that Arduinos have a data buffer that sets a limit of 64 bytes that they can transmit at a time. I then learned that you could modify the core code for an Arduino to increase the data buffer from 64 bytes to 256 bytes.
Although I was just having a problem sending more than 20 characters (20 bytes) at a time, I figured that I would still need to increase the size of this data buffer to a little bit over 100 so that in the future an instructor would be able to assign a 100 rep workout and the Arduino would be able to send back 103 characters (103 bytes) whenever it updated the app. I tried following these instructions for increasing the amount of data an Arduino Uno can send at once, but then found those instructions did not apply when trying to increase the amount of data that an Adafruit Flora could send at once. I then tried following these instructions so that I could manually install a custom Adafruit Flora board, but I was unable to test if my manually installed Flora board worked because it was at about this time that my last Flora v1 board burnt out and stopped working. I told Katie about this and she gave me a couple of Flora v2s to work with and a micro USB cable as the Flora v2s require a micro USB cable instead of a mini USB cable.
I tried working with the new Floras and the boards’ green power lights would turn on but I was unable to get the serial port to open up so I couldn’t upload any code. I asked Ben if he could help me with this as I knew he had recently been having problems with the Arduino IDE’s serial port not opening up. He advised that I first try unplugging the board and plugging it back in, resetting the board, restarting the IDE, restarting my laptop and if all of that failed then try uninstalling and re-installing the IDE and drivers. I tried all of these things, but none of them ended up working. In fact, my Mac was not even recognizing that anything was connected to it. After spending a lot of time trying to fix the Flora that day I decided to just post on the Adafruit forum to ask for help and to try working with a LilyPad Simblee BLE board that I had borrowed from Sam and Olivia. When I tried working with the board its power light would not turn on when plugged in and the board was getting very hot so I suspected that I had burnt this board out too. I talked to Katie about my issues the next morning before the Girl Scout camp and she said that it was possible that my laptop’s USB port might have burned out and that might be why the Simblee board wasn’t getting power and why my Mac wasn’t recognizing the Flora was connected to it. I looked into this possibility and tried resetting my Mac’s USB ports with an SMC reset but still had no luck with either the Flora v2 or the Simblee. I then tried un-installing and re-installing the IDE and drivers again and asked Ben for help again. He suggested that I try using a Windows machine instead of a Mac as he’d heard that a lot of people were recently having problems with the IDE on the Mac and he suspected that it might have been a Mac update that was the problem. I then tried uploading code on my Windows laptop but still had no luck unfortunately. I kept looking through forums for help but didn’t find much help until someone responded to my forum post and suggested that it might be the micro USB cable that I was working with. The responder told me that some micro USB cables are charge only and don’t carry any data back from the Arduino so you can’t upload any code with them. I then went out and bought a new micro USB cable and found that the cable was my problem all along.
After resolving my issue with uploading code to the Flora I got back to the issue of sending more than 20 bytes at a time from the Arduino to the app. I ended up finding that the main issue was the not with the Flora board but rather with the Bluefruit BLE that we are using to send data from the knee sleeve to the app as BLE in incapable of sending any more than 20 bytes at a time. This meant that I would have to modify my Arduino code and app so that the app could work when only receiving 20 bytes of data or less.
Fixing the Arduino Code and Squat Mode
These past couple of days I’ve worked on editing my app code and Arduino code so that the app could function properly while receiving less than 20 bytes of data. I did this by changing the Arduino code so that it would send multiple strings of 14 characters/bytes with information about if the start and target positions have been set, what color the background of the squat mode should be, how many times strings have already been sent to the app (starting from 0), and the status of 10 or fewer reps in the workout. Additionally I needed to change the app’s updateTable function (found on athleteTableTwo.js) and to change what happens every time that data is received via Bluetooth. After testing my changes the squat mode worked as it was supposed to but I did have to include a delay of 200 ms between each BLE send to prevent the app from reading the 2nd sent string as part of the first. Next week I’ll try to figure out a way to send to reduce the number of sends to the app so that the Arduino only sends the reps that have been updated.
In addition to making the changes I mentioned above, I’ve also figured out why the bend sensor code was counting rising up after setting the target position as a rep. I had set the boolean “squatEnded” to true in the setup part of the code so that after setting a target position then the while loop in the squatReset function would be entered and require a squatter to return to below the “restartingValue” before the Arduino counted any reps. For some reason, even after setting the value to equal true in the setup part of the code, the value of squatEnded was still false and so the squatReset function’s while loop was never being entered after setting the target position. I eventually got this resolved though after working with Katie and went on edit the Arduino code so that the Flora V2’s on-board NeoPixel would flash green after setting the start and target position and light up red, yellow, green, or purple depending on what stage of the squat the athlete is in.
Plans for the Rest of This Week
I’m planning to replace the bend sensor that I’ve been using with a longer bend sensor, as I believe that the soldering on the one that I’ve been using might have caused my Flora v1 boards to burn out. After I test the new bend sensor I’m planning to fasten it onto the knee sleeve and completely build one knee sleeve. Additionally, I’ll be presenting in the REU poster session on the 29th so I’ll need to work on creating my poster and making my app a little bit more presentable by fixing the CSS. I’m also hoping to figure out how to set the number of sets and reps in a workout from the PhoneGap app and work on the database.