My project is an automatic window-opening and closing device. It reads the current temperature and decides whether to open or close the window using a servo. More particularly, if the temperature rises above a certain defined threshold, it opens the window to let some cold air in. Then, once the temperature falls below the threshold again, it will close the window.
MotivationI decided to do this project because I often found myself opening and closing the window all the time when it would get too hot and then too cold. While it's not a hard thing to do, it's tedious, and it would be nice if the window could somehow open and close itself when needed. So, I devised this project to allow me to do that.
* Wire and operate the temperature sensor to get temperature readings.
* Power and operate a powerful enough servo to move my window.
* Mechanically attach the servo to my window to open and close it.
* Write code to see temperature changes and react accordingly.
LogicEvery 100 ms, read the temperature from thermistor
If temperature is greater than the threshold and the window is closed
Open the window
Wait for some time
else If temperature is less than the threshold and the window is open
Close the Window
Wait for some time
The Process1. I began this project by trying to get the temperature sensing part working with my Photon 2 device. I initially chose to use the DHT11 temperature sensor as it could also provide me with humidity values. However, after trying to use this sensor for some time, it turned out that DHT temperature sensors are mostly incompatible with Photon 2 devices. This led me to replace my project's DHT11 temperature sensor with an NTC Thermistor.
2. I spent some time figuring out how to use the thermistor, which included changing my circuit to include a 10k ohm resistor and configuring values in the code to get good data. After a while, I managed to get the thermistor working and giving fairly accurate data.
3. I wired in a micro-servo as a temporary stand-in for the real servo I would use to move the window so I could test the code logic.
4. Once I verified that the logic of my code was correct, I moved on to replacing the micro-servo with the servo I would actually use. My initial plans were to use the LX-224 20kg Serial Bus Servo from Hiwonder. It turns out you also need the Serial Bus Servo Controller, the Debugging Board, and a power supply to run the servo. After getting those components, I wired them together and connected my Photon 2 to the Servo Controller, then I began looking for documentation on how to use the servo. I found a nice GitHub repository that has information on how to use these components which is what I used to program my servo.
The servo works through serial, which is why you connect D8 and D9 to the Servo Controller which are TX and RX respectively (D8 goes to RX on the controller, D9 goes to TX on the controller).
If you wire the Servo Bus Controller and it starts making a very loud beeping sound, that is the low voltage warning and you likely need to provide something like 7-8V for it to stop.
4. (SKIPPABLE STEP) At this point I was having trouble with programming the LX-224 servo on my Photon 2 so I decided I might have an easier time if I tried using a different microcontroller instead since I had already experienced issues with other components and didn't know if this was one of those issues. The only other microcontroller I had was the Adafruit Circuit Playground Express. Additionally, it was already connected to the Adafruit CRICKIT which is a board that helps you connect various components like servos, motors, LEDs, etc. I decided I would try it to see if the issues I was having were just because of the Photon 2.
I tried connecting the LX-224 to the servo connectors on the Cricket board, but I still didn't get it working. I'm pretty sure the main problem was that the Cricket board didn't provide enough voltage since the servo needs 6-8.4V. After a while I decided I would just go back to the Photon 2 since I didn't think it was a Photon problem anymore.
5. After a while I was able to get the LX-224 Servo working from my Photon 2. However, I was still worried that the servo might be too weak to open and close the window and it was also hard to attach large things to it. So I decided to switch to an even bigger servo, the ASMC-04B, which is an 180kg servo (woah). It's kind of overpowered, but it ended up working really well and has a lot of torque (I would exercise caution when working with this servo because it is VERY easy to throw stuff around with it).
It's wired to 24V on the power supply (my power supply is in 120V mode which is configured with the switch on the side) and for the microcontroller you can just use the built-in Servo library.
This is what the circuit looks like when it is functioning. In this example, you can see when the thermistor heats up above the threshold by placing my fingers on it, the servo starts spinning. Then, after a pre-defined delay the Photon will begin checking the temperature again. Once the temperature drops back below the threshold, it will spin the servo back.
6. I began looking for ways to actually mechanically attach the servo to my window. The mechanism I settled on is different from the original one I proposed and it involves a lever attached to the servo with another piece hinged onto it and then attached to a bottom piece of the window.
7. I attached the mechanism to the new servo and set it up on my window. So far it works but I need something to hold the servo in place because right now I just hold it.
Relatively speaking, it's a very simple project. I will note that while temperature sensing sounds like a very basic part of any automation project, it was quite difficult for me to get the temperature sensing working properly on my Photon 2 (using the more user-friendly Circuit Playground Express was easier for temperature sensing).
Particle published some nice documentation for working with thermistors using a community library. Using the library and putting in the correct values should yield passable results regarding temperature sensing. I had to play with the "thermistorNominal"
and "sampleDelay" values until I could get good results.
Also, I found that when you wire other components into your circuit while using a thermistor, and those components start drawing current, your thermistor will start giving bad data. I believe this is an issue with how thermistors work as they're based on resistance, so my solution was simply only to read data from the thermistor when I'm certain nothing else is drawing current (i.e., the servo isn't moving).
Early on I also tested the servo using a servo tester device that just sends instructions to the servo, similar to any microcontroller. It helped with debugging.
* Researching electronics specifications and documentation
* Working with temperature sensing electronics
* Serial communications protocols
* I also learned a lot about certain mechanical systems, particularly because I tried a lot of different designs to open the window with my servo. I tried a wheel and some grip tape, which didn't really work because I didn't have the right attachments to attach the wheel to the servo. I thought about using gears and rails/belts, but that would be a lot more moving parts and would need to be done very well to work at all.
Comments