本项目首要制造一款植物监测仪,工能是:水分传感器提示LED闪耀,并在植物需求用水时运用IFTTT向手机发送相关信息。
该项目需求运用的东西:
硬件
光子(Particle Photon)物联网开发板(http://www.dfrobot.com.cn/goods-1158.html)
Particle Electron
电容式土壤湿度传感器(http://www.dfrobot.com.cn/goods-1215.html)
软件
IFTTT Maker服务
ThingSpeak女人体油画应用程序界面
故事
大部分人的房子里边都有一种或多种盆栽植物需求定时进行洒水。问题是,除非您是开专业花店的,不然您并不知道每棵植物何时需求洒水。为了处理这个问题,咱们开发了一个体系,当您的植物需求水分时,体系会经过手机向您发送告诉。
品乐谦
修罗武神八一中文网
首要,水分传感器衔接Photon并放置在盆栽植物中。然后,当传感器读取湿度值低于20时,Photon会经过编程方法发布一个名为“moisturePercent黄志忠老婆age”的事情。一起,Electron会订阅和发布该事情,以及发布自己的事情,两个事情被称为“plantStatus”和“handshake”;到时夫军耍流氓它将会把名为thirsty的变量的值从true更改为false。IFTTT将订阅“plantStatus”并向用户的IFTTT应用程序发送相关告诉,而Photon将订阅“handshake”事情并在听到它时中止发布“moisturePercentage”。在electron的代码中,某个while循环将导致其LED开端闪耀,并对变量进行赋值thirsty = true。这为用户供应了另一种告诉方法,避免用户未带手机的状况。当植物淹泡在水中时,水分含量将升至45以上,这导致Photon发布另一个名为“plantWatered”的事情,Electron会订阅该事情。这使得植物缺水的变量设置为false,避免电子LED闪耀。经过一段时间后,这些水分将被植物所吸收,而且整个进程将重新开端。
咱们决议调查植物吸收水分时,水分含量怎么改变,这个进程将十分风趣。因而,每次Photon对其进行记载时,咱们都会经过一些事物对水含量进行记载。咱们发现咱们所选的血根草植物可以很快吸收咱们供应的水,而且有必要每隔一天至少浇一次水。
原理图
Particle Photon的代码:
int boardLed = D7; //LED D7 for testing purposes
int moisture_pin = A1; //connection point for moisture sensor
bool messageSent = false; //variable for checking if notification has been sent to phone
String plantWatered = "Your plant has been watered日本污漫画大全 and is moist";
void setup() {
pinMode(boardLed,OUTPUT); //output to turn on LED for setup
pinMode(moisture_pin,INPUT); //Input from moisture sensor
//Flashes LED to indicate th外籍男模at flash is successful.
digitalWrite(boardLed,HIGH);
delay(2000);
digitalWrite(boardLed,LOW);
delay(2000);
digitalWrite(boardLed,HIGH);
del闽jay(2000);
digitalWrite(boardLed,LOW);
delay(2000);
}
void loop() {师父,极速影院-安博电竞进口_anggame安博电竞_安博网站
//digitalWrite(boardLed,HIGH);
// Now we'll take some readings...
int moisture_analog = analogRead(moisture_pin); // read capacitive sensor
float moisture_percentage = (100 - ((moisture_analog/4095.00) * 100 )师父,极速影院-安博电竞进口_anggame安博电竞_安博网站);
Particle.subscribe("handshake", handShake, "34002f000a47373336373936"); //Subscribe command to listen to other device
i锤子大乱斗f (moisture_percentage <= 22 && messageSent == false){ //Checks if moisture percentage is超级淫欲体系 below threshold and also checks if the water message has been sent
师父,极速影院-安博电竞进口_anggame安博电竞_安博网站
Particle.publish("moist金优他美urePercentag蒋蕙筠e", String(moisture_percentage),60,PUBLIC); //Publishes for message to be sent
}
if (moisture_percentage > 40 && messageSent == true){ //Checks if moisture levels have gone back up and also checks if message has been sent
Particle.publish("plantWatered", plantWatered, 60, PUBLIC);
messageSent = false; //If message sent, and plant watered, it resets the program so that the function above will run
}
Particle.publish("plantStatus_percentage", String(moisture_percentage),60,PUBLIC); //Publish command for logging data and sending it to thingspeak
//digital师父,极速影院-安博电竞进口_anggame安博电竞_安博网站Write(boardLed,LOW);
delay(15000);
}陆昊是陆定一的儿子
void handS冷志宏hake( const char *event, const char *data){ //If the message has been sent, it sets messageSent to true
messageSent = true;
}
Particle Electron 的代码:
int led=D7;//led that indicates the plant needs water
bool sent=f师父,极速影院-安博电竞进口_anggame安博电竞_安博网站alse;// has the notification to water the plant been se师父,极速影院-安博电竞进口_anggame安博电竞_安博网站nt
bool thirsty=false;//whether or not the plant needs water
void setup()
{
pinMode(led,OUTPUT);
}
void loop()
{
Particle.subscribe("moisturePercentage",waterPlant,"3c0026001747373335333438");
while(thirsty==true)
{//while the plant needs water the LED flashes and the electron listens for when the water level goes up
deyeyeigitalWrite(led,HIGH);
delay(500);
digitalWrite(led,LOW);
delay(500);
Particle.subscribe("pla分手by千十九ntWatered",breakloop,"3c0026001747373335333438");// checks for when the plant has been waterd.
}
delay(5000);// this loop every five minutes
}
void waterPlant( const char *event, const char*data)
{
Particle.publish("plantStatus","thirsty",60,PUBLIC);//sends a message to IFTTT to notify me to water my plants.
sent=true;
Particle.publish("handshake","sent",60,PUBLIC)海尔hnm体系;// notifies the photon that the message has been sent
thirsty=true;
}
void breakloop( const char *event, const char*data)// changes thirsty to false to break the while loop and stop the led from flashing
{
thirsty=false;
sent=false;
}
转载自:http://mc.dfrobot.com.cn/thread-280233-1-1.html
声明:该文观念仅代表作者自己,搜狐号系信息发布渠道,搜狐仅供应信息存储空间服务。
师父,极速影院-安博电竞进口_anggame安博电竞_安博网站