Sensordescription-
Hardware connection's-In this project PIR sensor is connected to NodeMCU board in such a way that -
- vcc pin to 3.3v of NodeMCU
- gnd pin to gnd of NodeMCU
- output pin to digital pin of NodeMCU D8 or you can connect in any digital pin..up to you.
Arduino unocode-
int pirpin = 8;
int ledpin = 12;
void setup() {
// put your setup code here, to run once:
pinMode(pirpin,INPUT);
pinMode(ledpin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(pirpin) == HIGH)
digitalWrite(ledpin,HIGH);
else
digitalWrite(ledpin,LOW);
}
thingsio.ai process-
1) google thingsio.ai
2) register yourself (or) make an account
3) click on new project button on top menu
4) go to sample code option's --> nodemcu -->LM35 --> copy
5) paste it on arduino ide
6)declare variable that you want to send to server
int t; //comment the line "int t,t1,t2,t3;"
7) give your SSID and PASSWORD
if(!wifiManager.autoConnect("abcd","*****"))
//wifiManager.autoConnect("AP-NAME", "AP-PASSWORD"); (OR) wifiManager.autoConnect("AP-NAME"); only ID no password (OR) wifiManager.autoConnect(); this will
generate a ID by itself
{ Serial.println("failed to connect and hit timeout"); //control comes here after long time of creating Access point "NodeMCU" by NodeMCU and still it has not connected //reset and try again, or maybe put it to deep sleep ESP.reset(); delay(1000); }
//here in place of abcd give your ssid and in place of ******* give your password
8)in calculation part
t=digitalRead(D8);//t1=(analogValue/1024.0) * 5000; // Serial.print("temp: "); comment line's Serial.println(t); //t2=(t1/10); //Serial.print("celc: "); // Serial.println(t2); // t3=((t2 * 9)/5 + 32); //Serial.print("fhrn: "); //Serial.println(t3);
9) change celc to your parameter name(ALERT) and t2 to t, delete others
String PostValue = "{\"device_id\": 61121695818, \"slave_id\": 2"; PostValue = PostValue + ",\"dts\":" +timestamp; PostValue = PostValue +",\"data\":{\"celc\":" + t2 +",\"fahr\":" + t3 +"}"+"}";//+",\"fahr\":" + t3 <----- delete this part from above line
10) that's all we need to do now upload it to nodemcu board.
open your serial monitor and see whether http status is 200 or not if yes that means the data is successfully getting uploaded to the cloud and then check on cloud and analyse it.
Comments
Please log in or sign up to comment.