A servo motor controller for my dorm room's thermostat, connected to the Internet of Things through the Particle Cloud.
How it Works
I've connected a small analog servo motor to a Particle Photon board, and duct taped it to the thermostat so the gear on the servo spins the temperature dial's gear. The code running on the Photon uses the lovely Particle API to set the angle of the servo:
int controlValue = percentToAngle(newAngle); this->servo->write(controlValue);
A set of functions is made available to be called using the Particle REST API, like so:
Particle.function("setPercent", &Thermometer::_setAngleAsync, this); Particle.function("sysDelay", &Thermometer::_sysDelay, this); Particle.function("getAngle", &Thermometer::_getAngle, this); ...
Then, I created a simple IFTTT applet triggered by my Google Assistant that calls the appropriate function through the Particle Cloud, and sets the temperature remotely.
- Particle CLI or Particle Desktop IDE or Particle Workbench
Make sure you have the correct Particle device target selected and run
particle compile <platform>.
This program is intended to be run on the Particle Photon device, so the build and flash commands would be:
particle compile photon --saveTo Thermometer.bin particle flash <device-name> Thermometer.bin
To get your device name, connect via USB and run
particle serial list
Or go to the Particle Console.
Pull requests are welcome.
- Add a persistant "Favorite temperature" setting
- Create an Android/iOS mobile app to interface with the device
- Create a nice web interface
- 3D print a proper way to attach it to the thermostat
- User authentication for the API
This code is available under the MIT License.