So it’s Christmas! I am targeting a fun Christmas project every year. This year I got an idea from 2015, who remembers Netflix socks? This project are on my stack of projects “to be done” and this year I decided to run my Christmas version of Netflix socks.
My socks have LEDs that blink in response to the movement of my legs, and if I shake my leg hard the socks will pause what I’m watching on TV😱. Another feature, which is the main functionality of the original Netflix socks, is that after the socks does not detect activity on my legs for a long time the socks turns off the TV🤯.
Material
For the project I used the following material:
- Football Socks (with Christmas Colors);
- ESP8266 NodeMCU;
- LEDs;
- Jumpers;
- Sewing material (threads, needles or sewing machine);
- Vibration sensor SW-240;
- Lithium-ion battery;
Circuit
The circuit is very simple, we will use a digital port for the LEDs, which will be connected in series, and a digital port for the sensor.
Assembly
In the socks the first thing is to “connect” the LEDs. First I soldered the jumpers and LEDs. Then I glued them to the sock using hot glue:
I bought a pair of extra socks, of another color, just to make cutouts. So I can hide the threads and the hot glue mess with a stylized cutout and sew that cutout on top. The best to do this assembly would be with conductive line (I didn’t have here 😔). So you can sew the connections to the LED and the socks will look much better.
I also made a kind of “bag” with the cutouts of the other sock. In this bag I put the rest of the circuit, the NodeMCU, the sensor and the battery:
In the bag I also sewed a velcro, so I can put it on my leg and just fit the velcro.
Software
For the software I used the Espruino firmware on NodeMCU. So I can write all the logic of my sock, make HTTP requests using JavaScript. Very cool.
Software logic is the following:
When booting, NodeMCU will instantiate the objects needed for the sensor and TV processes. Before starting the tasks, the program waits for an internet connection. As soon as NodeMCU connects to the wifi network the program then begins to monitor the vibration sensor signals. The class that monitors the sensor initializes some interval timers:
- Sensor Start/Stop Interval
- The sensor detects vibrations, even in very slow movements the sensor triggers its signal. This interval sets a timer to verify that the sensor has stopped to send signals. So instead of handling all sensor state changes we can only handle two events. “Start” event, the sensor has changed from “no vibration” to “vibrating” state. And the “stop” event where the sensor went from “vibrating” to “no vibration”.
- Shake Sensor Interval
- When the sensor detects stronger shaking, faster swing, it then triggers more signals in less time. This interval sets a timer to check whether a large number of signals have been triggered within a short time, which characterizes the shake event. So we can handle this event to perform actions within the program when the user shakes the sock fast.
- Nap Interval
- This interval defines a maximum time when the sensor has not detected any vibration or movement. Thus we can infer that the user is taking a nap and system trigger the “sleep” event.
With the defined intervals we can then perform the actions on each event:
- OnStart
- Em estado de movimento. Liga os LEDs;
- On movement state, turn on LEDs;
- OnStop
- Sem movimento. Desliga os LEDs;
- No movement, turn off LEDs;
- OnShake
- Sudden movements, pause/play TV;
- OnSleep
- No movement for a long time, turn off TV;
To control the TV, Netflix socks article uses reverse engineering with the controller, capturing infrared signals to clone the controller commands. In my project I didn’t need this because my Smart TV has a REST API. So I can perform HTTP requests to execute the control commands, very cool. That’s where the IoT of our project comes in. Our socks and TV are Internet-connected things, that perform tasks cooperatively.
Github repo: https://github.com/microhobby/EspruinoProjects
Conclusion
With a simple vibration sensor, I found this sensor very sensitive every simple movement it starts to trigger signals, and a software logic can characterize events and perform actions within those events.
It’s really nice to have access to a REST API to control the TV. Too bad the TV vendor does not document this API. We have to use reverse engineering for this.
For the assembly the best would be to use conductive line. I still leave here my thanks to my sister Mariana Castello and my wife Thamara Castello who helped me with sewing the socks cuts.
I hope you enjoyed this year’s project. MERRY CHRISTMAS 🎄