Creating an Automated Greenhouse: Part 2 of My Journey
As I mentioned in my previous video, this is part two of my automated greenhouse project. If you haven't watched part one yet, please make sure to do so before watching this part, as otherwise, you'll get confused pretty quickly. With that out of the way, let's dive into what I learned during the past two months of using my automated greenhouse and the problems I fixed.
One of the first things I noticed was that the moisture sensors were pretty useless because they never output any kind of accurate measurements. This is why I simply got rid of them. Next, I added cable lead-throughs because I actually read all of your comments and admitted to missing something. I also 3D printed some additional parts for my greenhouse, which I'll discuss later in this article.
Another issue I faced was the lack of a reliable way to control the motor that opens and closes the window. To solve this problem, I designed an H-bridge circuit using an L293D IC. This circuit allows me to change the current flow through the motor's rotor, which is necessary for controlling its movement. I found the L293D IC to be perfect for this purpose, as it can be controlled by 2.3V logic levels and includes an H-Bridge.
To test the L293D IC, I soldered a fitting IC socket to a piece of perfboard, created some solder connections, and finally hooked up the motor according to my little schematic. After inserting the IC and connecting the power lines to 5V, which is a voltage that's also available in my greenhouse, we basically got two input pins to work with. Depending on which one gets connected to 5V or later 3.3V, the motor rotates one way or the other way.
I then got myself the same Arduino LoRa board from part one of this video series and connected the input pins of the motor controller to pin 3 and 4 in addition with 300kohm pulldown resistors. However, you can just follow the finalized wiring diagram of this project if you're interested in creating something similar.
After adding the new LoRa board to the Things Network site, I adjusted the code of this test device a bit so that it always uploads the same temperature and humidity data. And after hooking an FTDI breakout board to it and uploading this new code, you can see that the Things Network gets the data successfully.
Here we can actually send data through a downlink but all the Arduino code registers is how big the received data was in bytes. So I simply edited the code in a way that it rotates the motor one way if it receives one byte and it rotates the other way if it receives two bytes. Of course, I also implemented a delay so that the motor only moves for a short time and the motor can also not rotate the same way twice in a row.
The Arduino will also send over the status of the window with 99.9 standing for being open and 00.0 for being closed. After uploading this finished test code and powering everything up, I sent over one byte which promptly let the motor spin one way and afterwards I sent over two bytes which lets it spin the other way, perfect.
It was time to head into my garden to firstly secure the motor mount with the motor and gear system next to the window and then soldering a wire to the motor which I guided into my electronics chest through the help of wire pedestals and zip ties in which I then connected the motor wires to the motor driver IC which I then obviously hooked up to the LoRa board.
After that, using adhesive tape to mount the window opener to the window, I uploaded the finalized code and as you can see the system still sends over the correct greenhouse data but now we can also remotely control the window through LoRa and the internet, brilliant. With that being said, I hope you enjoyed this video series and learned a thing or two.
If so don't forget to like, share, subscribe and hit the notification bell. Stay creative and I will see you next time.
WEBVTTKind: captionsLanguage: enHi there, in case you have not realized ityet then let me tell you that this is Part2 of my automated greenhouse project.So make sure to watch part 1 before watchingthis part because otherwise you will get confusedpretty quickly.With that out of the way let start off withme telling you what I learned in the two monthsof using my automated greenhouse and whatproblems I fixed.The first thing I noticed was that the moisturesensors are pretty useless because they neveroutput any kind of accurate measurements whichis why I simply got rid of them.Next I added cable lead-throughs because Iactually read all of your comments and admitif I missed something.I also 3D printed a new housing in white formy Temperature sensor because using a blackenclosure in direct sunlight kind of distortedthe measurements.Last but not least I added a better antennato the LoRa board which I positioned on topof the greenhouse to achieve a more stableconnection to my router.And those were basically all the changes ifI exclude that I also added a small scriptwhich translates the hex values to decimaland I have to say that I am pretty happy receivingthe temperature and humidity data withoutany problems because it lets me easily knowwhen I have to open the window or door toventilate the greenhouse.And it even seems like all my tomatoes, sugarmelons and one water melon agree with me onthat.But wouldn’t it be awesome to have an automatedmotorized window opener which like the nameimplies open and closes the window wheneverI tell it to do so through the Things Networksite.Well in this video I will show you how todo just that, so let’s not waste any moretime and let’s get started!This video is sponsored by JLCPCB!Feel free to visit their website JLCPCB.comto not only find out what awesome PCB andAssembly services they offer but also to easilyupload your Gerber files and thus order affordableand high quality PCBs.First off I have to say that my initial planwas to also incorporate an automated wateringsystem but I quickly realized that I needto visit my greenhouse almost every day andthus automating this process would have beenkind of pointless and thus I scratched it.With that out of the way let’s think aboutthe motorized window opener which consistsof a mechanical part where we have to decideon a motor type and create a suitable mechanicalsystem consisting of motor holder, gear andgear rack and an electronics part in whichwe have to figure out how to drive the motorand how to control it through LoRa and theThings Network.Let’s begin with the mechanical side bychoosing between these three motor types:a BLDC Motor, a Stepper Motor or a DC Motor.Now the biggest challenge for the motor willbe the required holding torque which is requiredto hold the window in the opened positionand not let it roll back down.That means the BLDC Motor is out because commonESCs which are necessary to power them, dousually not come with a holding torque option.Stepper Motor drivers however do come withsuch an option and therefore feature suitableholding torque.But the catch is obviously that powering thestepper motor would require quite a bit ofenergy and since we are working with solarpower and a battery we should definitely avoidthat which means that the stepper motor isout as well.And that brings us to the DC motor which atfirst sight does not come with decent holdingtorque.But if we take a DC motor whose RPM of 5000gets reduced to just 100 through a gear systemthen you can see that it suddenly featuresquite a lot of holding toque which I evencannot overcome with my hands.And due to this gear system and later poweringit with only 5V, I will not even have to alteris RPM electrically which makes it perfectfor our window opener.So next I measured all the dimensions of themotor as well as the space between the availablemounting holes next to the window and throughthis knowledge created this motor holder inwhich the motor will later fit snugly andcan be locked in place with two M3 bolts andnuts.Next it was time for the gear system for whichI used the McMaster-Car component librarywhere I chose a fitting plastic gear and gearrack.After then extending the gears mounting holea bit according to the dimensions of the motorsrotor, I also added a 3mm hole to it to laterhold it in place with a grub screw and thencontinued by shorting the gear rack a bit.As you can see those two parts can later beused to slide the rack forwards and backwardsand thus opening and closing the window butas you might already have guessed this rackcannot float in midair which is why I alsodesigned this case for it.And with that being done, all the mechanicalcomponents were pretty much done and thusI 3D printed them all with my Prusa 3D printerswhich took around 4 hours in total.As soon as that was done I assembled the gearsystem for testing purposes and as you cansee by alternatingly powering the motor, therack slides forwards and backwards withouta problem which brings me to the electricalsection.To turn the motors rotor left and right weneed to be able to change the current flowthrough it which is why we need such an HBridge circuit and at least two digital pinsof our microcontroller.If the left side is high and the right sideis low, current will flow from right to leftand if the left side is low and the rightside high, current will flow the other waywhich basically means this circuit shoulddo the trick.But while searching for suitable MOSFETs,I noticed that I didn’t have any logic levelP Channel MOSFETs lying around which are definitelymandatory when working with such a 3.3V system.But instead I found this L293D IC which actuallyincludes an H-Bridge and can be controlledby 2.3V logic levels, perfect.To test it, I soldered a fitting IC socketto a piece of perfboard, created some solderconnections and finally hooked up the motoraccording to this little schematic.After then inserting the IC and connectingthe power lines to 5V which is a voltage thatis also available in my greenhouse, we basicallygot two input pins to work with.Depending on which one gets connected to 5Vor later 3.3V, the motor rotates one way orthe other way and as you can see everythingseems to work just fine.So next I got myself the same Arduino LoRaboard from part 1 of this video series andconnected the input pins of the motor controllerto pin 3 and 4 in addition with 300kohm pulldown resistors but you can just follow thefinalized wiring diagram of this projectsif you are interested in creating somethingsimilar.After then adding this new LoRa board to thethings network site, I adjusted the code ofthis test device a bit so that it always uploadsthe same temperature and humidity data.And after hooking an FTDI breakout board upto it and uploading this new code you cansee that the things network gets the datasuccessfully and here we can actually sendover data through a downlink but all the Arduinocode registers is how big the received datawas in bytes.So I simply edited the code in a way thatit rotates the motor one way if it receivesone byte and it rotates the other way if itreceives two bytes.Of course I also implemented a delay so thatthe motor only moves for a short time andthe motor can also not rotate the same waytwice in a row and the Arduino will also fromnow on send over the status of the windowwith 99.9 standing for being open and 00.0for being closed.After uploading this finished test code andpowering everything up, I sent over 1 bytewhich promptly let the motor spin one wayand afterwards I sent over 2 bytes which letsit spin the other way, perfect.That means it was time to head into my gardento firstly secure the motor mount with motorand gear system next to the window and thensoldering a wire to the motor which I guidedinto my electronics chest through the helpof wire pedestals and zip ties in which Ithen connected the motor wires to the motordriver IC which I then obviously hooked upto the LoRa board.After then using adhesive tape to mount thewindow opener to the window, I uploaded thefinalized code and as you can see the systemstill sends over the correct greenhouse databut now we can also remotely control the windowthrough LoRa and the internet, brilliant.With that being said, I hope you enjoyed thisvideo series and learned a thing or two.If so don’t forget to like, share, subscribeand hit the notification bell.Stay creative and I will see you next time.