ProjectTeachingCase
This article is going to demonstrate my SIT210 project for teaching purpose.
Purpose
This project is focused on helping these people solve this problem of the impact of light on plants. When the light intensity is too strong, there are some ways to provide early warning.
Hardwarerequirement
Wires, resistors, photo transistor, LED, breadboard
Softwarerequirement
IFTTT, Particle web IDE, Thingspeak
SetupDevice
As the figures shown above, connect LED on the bread- boa. The long lead (anode) connects to pin D6 using the jummper wire and the short lead (cathode) connects to a 220-ohm resistor that connects it to ground. Next connect the photo transistor onto the breadboard. The short lead of the photo transistor connects to 3V3. In the picture, that's the right lead, using the red wire. The long lead of the photo transistor connects to a 220-ohm (red-red- brown-gold) resistor. The other side of the resistor con- nects to ground. The left lead of the photo transistor (con- nected to the resistor) also connects to pin A0 using the jummper wire.
Coding
int led = D6; //initialise the variable to have port value
int photosensor = A0; //initialise the variable to have port value
bool moveoutwarning = false; //to avoid redundant warning pre-set up bool
bool moveinwarning = false; //to avoid redundant warning
String plant = "flower"; //set up a string for plant type
int maxlightlevel = 200; //initialise the light level for type flowerFirst is instance all variables. Those two Boolean variable is going to handle the redundant warning for my system.
void setup() {
pinMode(led, OUTPUT); //set up led for output
pinMode(photosensor, INPUT); //set up photo transistor for input
}
void loop() {
// assume we are feed a flower that require max sun light strenth within 200
int LightData = analogRead (photosensor); //read the data from photo transistor
Particle.publish("LIGHT", String(LightData)); //publish light data onto thingspeak
if(plant == "flower") //check is the type matches
{
if(LightData > maxlightlevel){
if(!moveoutwarning)
{
.
.
.
moveoutwarning = true; //set move out warning to true
Particle.publish("SUN_LIGHT_ON", "Move plant out from the sun light asap, sun light srength is too high could kill plant"); //send ifttt trigger event to make email warning
moveinwarning = false; //set move in warning to false
}
else{
if(!moveinwarning)
{
moveinwarning = true; //set move in warning to true
moveoutwarning = false; //set move out warning to false
Particle.publish("SUN_LIGHT_OFF", "Sun light strength is good for plant now, try move them to a place that can receive sunlight"); //send ifttt trigger event to make email warning
}
}
delay(30000);
}Logically first we check if the plant type matches our sample plant. If yes then we check if light strength is over a level. Then we check if this warning has been sent 30 secs before. If a warning has been sent before and the situation of sun light strength is not changing, then we will only warning once. Because after the first time warning the Boolean variable moveoutwarning will be set to true. And next iteration will drop from the if statement. So it will not do anything, unless sun light strength returned to normal. When the light strength return to normal we should send email warning to user, and set the move in warning to true to handle the redundant warning in same logic as when light strength over the limit. But here we need also to set the move out warning to false again to handle the case that if the light strength goes up again. Same logic for moveinwarning = false. And because when the light strength return to normal, in this situation, it will not kill the plant. It is not as energy as when light strength over the limit. So we don't need to do blink feedback(sound feedback if you use a buzzer) here. And the system should check the light strength every 30 secs and upload those data on thingspeak for further analysis. Through the analysis we might can find a pattern for the best sun light strength period.
Conclusion
This report introduces information about our project, including how to use it and how to conduct experimental tests. This project uses a series of interactive applications of particle device to complete a function to help inexperienced plant growers. You may want to use buzzer to replace led for making sound feedback as flashing LED lights might not attract users' attention in the first place. Also in the same logic, you can add up a soil moisture sensor to help inexperienced plant growers to water the plant.


Comments