I'm in the process of learning how to use the Arduino with the eventual goal of building an automated greenhouse for plants (watering, humidity control etc). I know what components I'd like to use (have bought them) and have a general schematic of the entire setup I'm aiming for. In short, there will be an automated watering component {soil moisture sensor, water pump} and a humidity/temperature control component {fan, AC humidifier} ). I only have very basic programming knowledge unfortunately but am willing to learn (over time - for practical reasons).
Relevant equipment at hand
Arduino UNO
Breadboard
220v AC Relay (4block) board
220v Fan
DHT11 Temp/Humidity sensor
Various relevant connectors/cables
Question
Although I can't code in the Arduino language as yet, I have done a lot of research online and have managed to get the following working in practice using modification of sample code and looking at examples:
working DHT11 sensor giving correct readings through the Serial Monitor
working relay switch to turn a desk fan on and off (using a variant of the blink program)
For this stage of my project, I would like to know how to get the following result:
Since I have two working pieces of code (sketches), one to gather temp/moisture data and another to activate a relay, how does one combine the two sketches to monitor the serial output?
The current require end result is (eg), if the temperature from the sensor is above 22c, run the relay code (turns fan on), if under 22c, skip the relay code (turns fan off).
The end result would be the fan cools when temp is over a certain threshold.
I'm trying to learn how to code through analizing working code and fiddling with the variables - I understand this isn't ideal, but for the short term it is allowing me to learn a lot in a short space of time, until I can dedicate some "research" time for a proper A-Z tutorial
Thanks for any help!
(I will supply the sample code if required - I didn't want to spam on my first post)
Since I have two working pieces of code (sketches), one to gather temp/moisture data and another to activate a relay, how does one combine the two sketches to monitor the serial output?
I fail to see how a sketch that gets temperature and moisture data and a sketch that activates a relay can be combined to create a sketch that monitors something that happens on another computer.
You need to start with realistic expectations. Like, maybe activating a relay when the temperature gets to x degrees.
Since I have two working pieces of code (sketches), one to gather temp/moisture data and another to activate a relay, how does one combine the two sketches to monitor the serial output?
I fail to see how a sketch that gets temperature and moisture data and a sketch that activates a relay can be combined to create a sketch that monitors something that happens on another computer.
You need to start with realistic expectations. Like, maybe activating a relay when the temperature gets to x degrees.
Apologies PaulS, I suspect my terminology is incorrect. What I mean to say is, I have figured out how to gather temp data through one example sketch and how to activate a relay through another. The end result (having the fan turn on and off dependent on temperature) seems to require both sketches functionality in one piece of code. I'm trying to figure out how I would create one piece of code by using what I have managed to get to work in those two separate sketches.
I suspect Wildbill's suggestion will get me some headway. Thanks for that.