Hur man gör en Mini IOT väderstation (7 / 8 steg)
Steg 7: Setup mottagaren UNO
Hämta Blynk biblioteket från här
Hämta VirtualWire bibliotek från här
Hämta koden från här
eller Visa koden nedan
#include < SPI.h >
#include < Ethernet.h >
#include < BlynkSimpleEthernet.h >
#include < VirtualWire.h >
#include < Wire.h >
int härda;
int tempurature;
int luftfuktighet;
char auth [] = "9bb52b5cfa6b4c4bbcde617a64886ed5";
void setup()
{
Serial.BEGIN(9600);
vw_set_rx_pin(2);
vw_setup(2000);
vw_rx_start();
Blynk.BEGIN(auth);
}
void loop()
{
Blynk.Run();
uint8_t buf [VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
om (vw_get_message (buf, och buflen)) / / icke-blockerande
{
int i;
char c;
Sträng ingång;
för (jag = 0; jag < buflen; i ++)
{
c = ((char)buf[i]);
ingående += ((char)buf[i]);
Serial.Print((Char)BUF[i]);
}
om (c == "p") {
Serial.Print ("TEMPURATURE CHECK");
TEMP = sant;
}
om (c == "i") {
Serial.Print ("fuktighet CHECK");
TEMP = false;
}
om (c! = 'p' & & c! = "i") {
om (TEMP == true) {
tempurature = input.toInt();
om (tempurature! = fuktighet) {
Blynk.virtualWrite (V12, tempurature);
}
Serial.Print(tempurature);
}
annat {
fukt = input.toInt();
om (tempurature! = fuktighet) {
Blynk.virtualWrite (V13, fuktighet);
}
Serial.Print(humidity);
/ * dubbel celsius = (tempurature - 32) * 5/9.
dubbel en = 17.271;
dubbel b = 237.7;
dubbel temp2 = (en * celsius) / (b + c) + log(humidity*0.01);
dubbel Td = (b * temp2) / (a - temp2);
TD = ((Td*9) / 5) + 32;
Blynk.virtualWrite (V14, Td);
*/
}
}
Serial.println();
}
}