Concept
For my Phillips Hue controller I wanted to take a page out of Bianca’s book and use the Arduino Nano 33 IoT’s on-board IMU to control the light strip attributes. I had never used an accelerometer to determine orientation before. I also had this tiny six-sided candy tin sitting around my house and really wanted to use it as an enclosure for my light controller. As well as having one orientation turn on the light and another to turn it off, I wanted placing the tin on its different sides to change the hue of the light.
Arduino Code
First, I got used to using the Hue’s Debug Clip Interface. To use that interface you need to generate a unique username to connect to the Hue bridge, the IP address of the bridge, and the number of the light you want to control. The image on the right shows what that site looks like and how you can use API calls to get or send certain info to the Hue bridge and change the state of the light.
Once I felt comfortable using that tool I switched to working with the Arduino. I started with this example and got it working pretty easily, blinking the Hue strip using my Arduino. Next, I found this article about the Arduino’s accelerometer. The board has a LSM6DS3 module which includes both an accelerometer (linear acceleration) and gyroscope (angular velocity). It was super easy to get sensor readings using Arduino’s LSM6DS3 library.
Great! I did not know what these readings meant or what to do with them!
This may be review for the smarty-pants reading this but I eventually learned that the accelerometer data is showing the acceleration of gravity. So, if the Arduino+sensor is pointing straight up the measurement is +1 on the z-axis and if the Arduino is pointing straight down the measurement is -1 on the z-axis. This info helped me build out the different states of my code.
I wrote some really dumb code to control the light strip. Basically, if the z-axis reading is within a certain threshold, send a request to turn the light on or off.
The request follows the same syntax that was used in the web tool, so the “sendRequest()” function just pieces together the API call string and sends it over HTTP.
I used a whole bunch of other if-statements to check for different orientations of the controller tin and Arduino. Below is an image of my thought-process while working out the accelerometer math and a video of the Arduino updating the strip light on the floor based on the sensor readings.
Fabrication Process
Working with this tin proved to be really difficult. It is really small so it was hard to fit the Arduino and battery inside. I soldered a custom connector to get the circuit to be as minimal as possible. It was also a real pain to paint the smooth surface of the tin. Or maybe I have some really cheap paints … which I do. I had this plan for a really illustrative and cute enclosure for my controller, but I did not quite get all the way there. I also never figured out how to mount the Arduino within the tin to keep it straight and from moving.
Final Product
Ok! This did not work! At all! I basically built a faraday cage, what was I thinking?!
Once I tried testing my controller inside of its enclosure it wasn’t working like it was before. I guess I thought this tin would work as an enclosure because I used one for my networked controller. I might be able to get this enclosure to work if I cut an opening on one of the sides of the tin or somehow use the enclosure as the antenna itself, but I have no idea how to do that.
Final Project
I’ve thought of a final project idea that I think could satisfy this final and my final for my soft robotics class. I’ve outlined my initial idea and sketch on the second half of this blog post and some of the preliminary steps to get started.
Resources
https://tigoe.github.io/hue-control/
https://github.com/tigoe/hue-control
https://biancagan.com/2023/03/06/wk-6-more-dashboard-fun/
https://www.youtube.com/watch?v=wN1tGdNkUXY
https://github.com/makin-stuff/ITP/tree/main/Connected_Devices/Hue_Control