mirror of https://github.com/IoTcat/wIoT.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.3 KiB
69 lines
1.3 KiB
/* ***************************************************************** |
|
* |
|
this is the code for the sensor part of automatic home solar-powered water heated system. |
|
* |
|
* *****************************************************************/ |
|
|
|
//announce connection moudle |
|
#define BLINKER_PRINT Serial |
|
#define BLINKER_WIFI |
|
|
|
|
|
//include function set |
|
#include <Blinker.h> |
|
|
|
//declear overall variable::user, password, identify key |
|
char auth[] = "03a477a71ffb"; |
|
char ssid[] = "yimian-iot-s"; |
|
char pswd[] = "1234567890."; |
|
|
|
// load module |
|
BlinkerButton wIoT("wIoT"); |
|
|
|
//define vairable |
|
volatile double waterFlow; |
|
float i=0; |
|
|
|
/***waterFlow functions ***/ |
|
void pulse() //measure the quantity of square wave |
|
{ |
|
waterFlow += 1.0 / 450.0; |
|
} |
|
|
|
|
|
|
|
// Heartbeat for wIoT |
|
void heartbeat(const String & state) |
|
{ |
|
Blinker.print("wIoT",1); |
|
if(waterFlow<10) waterFlow=atof(state.c_str()); |
|
Blinker.print("waterFlow2",waterFlow); |
|
digitalWrite(D5, HIGH); |
|
|
|
} |
|
|
|
|
|
//setup function |
|
void setup() |
|
{ |
|
Serial.begin(115200); |
|
|
|
pinMode(D5, OUTPUT); |
|
digitalWrite(D5, LOW); |
|
|
|
Blinker.begin(auth, ssid, pswd); |
|
// Blinker attached Functions |
|
wIoT.attach(heartbeat); |
|
|
|
waterFlow = 0; |
|
attachInterrupt(0, pulse, RISING); //DIGITAL Pin 2: Interrupt 0 |
|
} |
|
|
|
//main loop function |
|
void loop() |
|
{ |
|
Blinker.run(); |
|
|
|
|
|
} |
|
|
|
|