Question

In: Electrical Engineering

can anyone give me a code for nodemcu wifi chip for displaying temperature and humidity to...

can anyone give me a code for nodemcu wifi chip for displaying temperature and humidity to app where temp and humidity data is sent to cloud and then cloud sends the data to mobile app

Solutions

Expert Solution

#include <DHT.h> // Including library for dht

#include <ESP8266WiFi.h>

String apiKey = "Your API of thingsspeak"; // Enter your Write API key from ThingSpeak

const char *ssid = "Your wifi Network name"; // replace with your wifi ssid and wpa2 key

const char *pass = "Network password";

#define DHTPIN 0 //pin where the dht11 is connected

DHT dht(DHTPIN, DHT11);

WiFiClient client;

void setup()

{

Serial.begin(115200);

delay(10);

dht.begin();

Serial.println("Connecting to ");

Serial.println(ssid);

WiFi.begin(ssid, pass);

while (WiFi.status() != WL_CONNECTED)

{

delay(500);

Serial.print(".");

}

Serial.println("");

Serial.println("WiFi connected");

}

void loop()

{

  

float h = dht.readHumidity();

float t = dht.readTemperature();

  

if (isnan(h) || isnan(t))

{

Serial.println("Failed to read from DHT sensor!");

return;

}

if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com

{  

  

String postStr = apiKey;

postStr +="&field1=";

postStr += String(t);

postStr +="&field2=";

postStr += String(h);

postStr += "\r\n\r\n";

client.print("POST /update HTTP/1.1\n");

client.print("Host: api.thingspeak.com\n");

client.print("Connection: close\n");

client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");

client.print("Content-Type: application/x-www-form-urlencoded\n");

client.print("Content-Length: ");

client.print(postStr.length());

client.print("\n\n");

client.print(postStr);

Serial.print("Temperature: ");

Serial.print(t);

Serial.print(" degrees Celcius, Humidity: ");

Serial.print(h);

Serial.println("%. Send to Thingspeak.");

}

client.stop();

Serial.println("Waiting...");

  

// thingspeak needs minimum 15 sec delay between updates, i've set it to 30 seconds

delay(10000);

}


Related Solutions

can anyone give me a code for nodemcu wifi chip for sending temperature and humidity data...
can anyone give me a code for nodemcu wifi chip for sending temperature and humidity data to cloud and then it sends the temperature and humidity data to mobile app.
can anyone give me an example of a job analysis?
can anyone give me an example of a job analysis?
Can anyone give me a summary on "Dismantling the doctrine of Discovery" ?
Can anyone give me a summary on "Dismantling the doctrine of Discovery" ?
can anyone give me information on inorganic and organic compounds in detail please
can anyone give me information on inorganic and organic compounds in detail please
We need to code an LCD with a temperature and humidity sensor for the arduino UNO...
We need to code an LCD with a temperature and humidity sensor for the arduino UNO board. The LCD should simply display the temperature and humidity reading from the DHT11 sensor. We must do this without the use of arduino or lcd libraries, and only use raw c code. For example we need to use PORTD |= (1<<5); to set the pin to 5. The LCD is connected to pins A0 and A1, and it is using I2C. The temperature...
Can anyone explain what is the difference between EARs and APRs? please give me an example....
Can anyone explain what is the difference between EARs and APRs? please give me an example. I am little confused about the quoted rate. Can anyone explain it? What is a pure discount loan please give me an example? What does it mean to amortize a loan?
can anyone summarize for me the below passage and to add for me some information that...
can anyone summarize for me the below passage and to add for me some information that u get from the below passage Thank You Theory of Reasoned Action stresses the importance of attitudes and intentions in changing a behavior. According to this theory, the most important determinant of behavior is intention.23 Very few actions that produce a healthy outcome happen without ample knowledge and full intention to practice the healthy behavior. Two cognitive processes are at work to develop healthy...
this is code to Temperature and Humidity Monitoring over ThingSpeak using Arduino UNO and ESP8266 i...
this is code to Temperature and Humidity Monitoring over ThingSpeak using Arduino UNO and ESP8266 i need someone explain the steps for me #include <stdlib.h> #include <DHT.h> #define DHTPIN 5         // DHT data pin connected to Arduino pin 5 #define DHTTYPE DHT11     // DHT11 (DHT Sensor Type ) DHT dht(DHTPIN, DHTTYPE); // Initialize the DHT sensor #define SSID "WiFi Name"     // "WiFi Name" #define PASS "WiFi Password"       // "Password" #define IP "184.106.153.149"// thingspeak.com ip String msg = "GET /update?key=Your API...
PYTHON COMPUTER CODE PROGRAMMING - DISPLAYING A PLOT OF TEMPERATURE VERSUS DEPTH WHEN GIVEN A LATITUDE....
PYTHON COMPUTER CODE PROGRAMMING - DISPLAYING A PLOT OF TEMPERATURE VERSUS DEPTH WHEN GIVEN A LATITUDE. PYTHON ASSIGNMENT. NOT SURE HOW TO PLOT THIS DATA WITH THE GIVEN INFO BELOW: Just as the atmosphere may be divided into layers characterized by how the temperature changes as altitude increases, the oceans may be divided into zones characterized by how the temperature changes as depth increases. We shall divide the oceans into three zones: the surface zone comprises the water at depths...
Can anyone tell me about the measurement of ICP-AES?
Can anyone tell me about the measurement of ICP-AES?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT