Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include <DHT.h>
- #include <ThingSpeak.h>
- #define dht_pin 2
- #define dht_type DHT11
- DHT dht(dht_pin, dht_type);
- WiFiClient client;
- //char ssid[] = "Anindya_Net 2.5";
- //char pwd[] = "07022001";
- char ssid[] = "NindoFi";
- char pwd[] = "AnindyaKbiswas";
- long channelID = 2132478;
- char writeAPIKey[] = "74XAOPKNHQOZYX74";
- bool alt = true;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- WiFi.begin(ssid, pwd);
- while(WiFi.status() != WL_CONNECTED)
- {
- delay(200);
- Serial.println("..");
- }
- Serial.print("Connected to -> ");
- Serial.println(ssid);
- Serial.println(WiFi.localIP());
- dht.begin();
- ThingSpeak.begin(client);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- float tempC = dht.readTemperature();
- float humidity = dht.readHumidity();
- Serial.print("Temperature : ");
- Serial.print(tempC);
- Serial.print(" ");
- Serial.print("Humidity : ");
- Serial.print(humidity);
- Serial.println();
- ThingSpeak.setField(1, tempC);
- ThingSpeak.setField(2, humidity);
- int x = ThingSpeak.writeFields(channelID, writeAPIKey);
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement