Another installment from Central New Mexico Community College's Internet of Things bootcamp. This workforce development course is a 10-week intensive training preparing students for careers in IoT.
The last few weeks of the course, students are exposed to using BLE. They learn to communicate between the Particle Argon and Adafruit's Bluefruit Connect app. The app has some nice features, including the ability to pixelate an image and transfer it via BLE.
Each of our students selects a rubber duck at the beginning of the course. In addition to being a companion during the more intense portions of the course, the ducks also serve as sounding boards to share coding problems. The below duck (Instructor Duck) volunteered to be the model of this project.
As mentioned, the Bluefruit Connect app has the capability of taking an image, pixelating, and sending a data stream of the pixelated image over BLE. In this project, a 16x16 neopixel matrix is being used. And, the color of each pixel is decoded from a 24-bit hex color (a byte each for red, green, and blue).
With a 16x16 image, the total image payload is 775 bytes. There are 3 bytes for each of the 256 (16x16) pixels (768 total bytes), plus a 7 byte header. As BLE sends payloads in a maximum of 244 bytes, the image above was transferred in 4 payloads (244, 244, 244, 43 bytes in size). The code below stiches together the 4 payloads into one larger data stream and then decodes the color of each pixel.
Comments