This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define SENSOR 0 | |
| void setup() { | |
| pinMode(SENSOR ,INPUT); | |
| } | |
| int iSen =analogRead(SENSOR); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define RELAY_PIN 5 | |
| void setup() { | |
| pinMode(RELAY_PIN ,OUTPUT); | |
| } | |
| //on | |
| digitalWrite(RELAY_PIN , HIGH); | |
| //off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (Ethernet.begin(mac) == 0) { | |
| Serial.println("Failed to configure Ethernet using DHCP"); | |
| Ethernet.begin(mac, ip); | |
| } | |
| if (client.connect(server, 80)) { | |
| Serial.println("connected"); | |
| String sReq= "GET /api-123.php?param=123"; | |
| sReq.concat(" HTTP/1.1"); | |
| client.println(sReq); | |
| client.println("Host: www.google.com"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void loop() | |
| { | |
| if (client.available()) { | |
| char c = client.read(); | |
| Serial.print(c); | |
| } | |
| if (!client.connected()) { | |
| Serial.println(); | |
| Serial.println("disconnecting."); | |
| client.stop(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if(isset($_GET["param1"])){ | |
| //do something... | |
| $param_1 = $_GET["param1"]; | |
| $sHEAD ="web-response1="; | |
| $res = "1"; //stat | |
| $res . = "1" // param-1 | |
| $res . = "2" // param-2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int iSen =0; | |
| int iSen2=0; | |
| int iSen3=0; | |
| int iSen4=0; | |
| iSen=analogRead(SENSOR); | |
| iSen2 =analogRead(SENSOR_1); | |
| iSen3 =analogRead(SENSOR_2); | |
| iSen4 =analogRead(SENSOR_3); | |
| String sSen = String(iSen); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(Serial.available() > 0){ | |
| char c = Serial.read(); | |
| mResponse3.concat(c); | |
| }else{ | |
| if(mResponse3.length() > 31){ | |
| Serial.print("==== response ==== \n"); | |
| String sRes4 = mResponse3.substring( 8 ); | |
| Serial.println("res=" + sRes4); | |
| Serial.print("==== response.END ==== \n"); | |
| struct stParam param; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String sCt = String(mCtOpen); | |
| Serial.println("proc_valve=" + sCt); | |
| if(mCtOpen >= mValveGet){ | |
| digitalWrite(RELAY_PIN , LOW); | |
| digitalWrite(RELAY_PIN_2 , LOW); | |
| digitalWrite(RELAY_PIN_3 , LOW); | |
| digitalWrite(RELAY_PIN_4 , LOW); | |
| mResponse3=""; | |
| mSTAT = mSTAT_CONECT; | |
| mCtOpen=0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def Is_addSensor(self, mc_id, nSec): | |
| ret=False | |
| iCt=0 | |
| clsConst = com_appConst.appConstClass() | |
| connection = MySQLdb.connect(host=clsConst.mHost, db=clsConst.mDB_NAME, user=clsConst.mUser, passwd=clsConst.mPass, charset="utf8") | |
| cursor = connection.cursor() | |
| dic = {"id": 0L, "creat_dt" : ""} | |
| sSql="select id, DATE_FORMAT(created,'%Y-%m-%d %H:%i:%s') as creat_dt" | |
| sSql=sSql+" from t_sensors where mc_id ="+mc_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def saveSensor(self, getDat, datMc): | |
| ret=False | |
| clsConst = com_appConst.appConstClass() | |
| connection = MySQLdb.connect(host=clsConst.mHost, db=clsConst.mDB_NAME, user=clsConst.mUser, passwd=clsConst.mPass, charset="utf8") | |
| if(datMc["vnum_1"]==1): | |
| cursor = connection.cursor() | |
| sSql=u"INSERT INTO t_sensors (mc_id" | |
| sSql=sSql+",vnum" | |
| sSql=sSql+",snum" |