finish water C++

master
hhCandy 5 years ago
parent 716a8888ab
commit b2164dcf62
  1. 2
      server/water.php
  2. 8
      server/waterData.js
  3. 3
      waterSnsr/waterSnsr.ino
  4. 2
      waterSys/waterSys.ino

@ -3,7 +3,7 @@ header('Access-Control-Allow-Origin:*');
include './functions.php'; include './functions.php';
$waterAdd=$_REQUEST['waterAdd']; $waterAdd=$_REQUEST['waterAdd'];
$waterFlow1=$_REQUEST['waterFlow']; $waterFlow1=$_REQUEST['waterFlow1'];
$waterFlow2=$_REQUEST['waterFlow2']; $waterFlow2=$_REQUEST['waterFlow2'];
$conn=db__connect(); $conn=db__connect();

@ -27,17 +27,17 @@ var change1_time=0;
function rec_w1(obj) function rec_w1(obj)
{ {
w1CtlObj=obj; w1CtlObj=obj;
wF1=obj.waterFlow; wF1=obj.waterFlow1;
//console.log('Client received a message',w1CtlObj); //console.log('Client received a message',w1CtlObj);
let fd = fs.openSync('waterFlow1.txt','w'); let fd = fs.openSync('waterFlow1.txt','w');
change1=wF1-fw1Obj.waterFlow; change1=wF1-fw1Obj.waterFlow1;
change1_time=Date.parse(new Date()); change1_time=Date.parse(new Date());
fs.writeFileSync(fd, wF1); fs.writeFileSync(fd, wF1);
fs.closeSync(fd); fs.closeSync(fd);
console.log('w1 '+obj.waterFlow); console.log('w1 '+obj.waterFlow1);
w1Obj=obj; w1Obj=obj;
//$.post("http://127.0.0.1/water.php",obj,function(msg){console.log(msg)}); //$.post("http://127.0.0.1/water.php",obj,function(msg){console.log(msg)});
cnt_recv_w1++; cnt_recv_w1++;
@ -48,7 +48,7 @@ socket_open_w1();
socket_w1.onmessage = function(event) { socket_w1.onmessage = function(event) {
var obj = eval('(' + event.data + ')'); var obj = eval('(' + event.data + ')');
if(obj.wIoT == 1) { if(obj.wIoT == 1) {
if(obj.waterFlow<10) {obj.waterFlow=wF1;socket_w1.send('{"wIoT":'+wF1+'}');} if(obj.waterFlow1<10) {obj.waterFlow1=wF1;socket_w1.send('{"wIoT":'+wF1+'}');}
rec_w1(obj); rec_w1(obj);
fw1Obj=obj; fw1Obj=obj;
} }

@ -38,6 +38,7 @@ void heartbeat(const String & state)
Blinker.print("wIoT",1); Blinker.print("wIoT",1);
if(waterFlow<10) waterFlow=atof(state.c_str()); if(waterFlow<10) waterFlow=atof(state.c_str());
Blinker.print("waterFlow2",waterFlow); Blinker.print("waterFlow2",waterFlow);
digitalWrite(D5, HIGH);
} }
@ -47,6 +48,8 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
pinMode(D5, OUTPUT);
digitalWrite(D5, LOW);
Blinker.begin(auth, ssid, pswd); Blinker.begin(auth, ssid, pswd);
// Blinker attached Functions // Blinker attached Functions

@ -16,7 +16,7 @@ this is the code for the control part of automatic home solar-powered water heat
//declear overall variable::user, password, identify key //declear overall variable::user, password, identify key
char auth[] = "91431a5e4043"; char auth[] = "91431a5e4043";
char ssid[] = "yimian-iot"; char ssid[] = "yimian-iot-s";
char pswd[] = "1234567890."; char pswd[] = "1234567890.";
//declear Button with certain keyname //declear Button with certain keyname

Loading…
Cancel
Save