Home IOT Project Wifi Temp Sensor
Post
Cancel

IOT Project Wifi Temp Sensor

IOT Project

Instructions to connect Wemos_D1_mini(esp8266)

When on the same Network

  • Create a hotspot from your phone/desktop, rename your hotspot as “QMEL_LAB” and set the password of your hotspot qmel@123.
  • Wait for few minutes when a device named “ESP-EAE289” get connected from the hotspot
  • Go to setting of your hotspot and copy the connected device ip (192.168.xx.xx) and paste it in your browser
  • Now you would be able to see the reading of the sensor.

image

When NOT on the same Network

image

  • Open the link Example: 2baa-xxx-110-242-14.in.ngrok.io.( ! This link suppose to change. )

image

=======================================================================

Step wise guide to make wifi temperature sensor

  • Components required:

Generic Wemos D1 Mini V2.2.0 Wifi Internet Development Board Based Esp8266 4Mb Flash Esp-12S Chip

image

Connections:

image

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <ESP8266WiFi.h>	
	#include <math.h>
	

	//  http://arduino.esp8266.com/stable/package_esp8266com_index.json
	

	unsigned int Rs = 150000;
	double Vcc = 3.3;
	

	// WiFi parameters
	const char* ssid = "wifi name";
	const char* password = "password";
	

	WiFiServer server(80);
	void setup() {
	Serial.begin(115200);
	delay(10);
	Serial.println();
	// Connect to WiFi network
	WiFi.mode(WIFI_STA);
	Serial.println();
	Serial.println();
	Serial.print("Connecting to ");
	Serial.println(ssid);
	

	WiFi.begin(ssid, password);
	

	while (WiFi.status() != WL_CONNECTED) {
	delay(500);
	Serial.print(".");
	}
	Serial.println("");
	Serial.println("WiFi connected");
	

	// Start the server
	server.begin();
	Serial.println("Server started");
	

	// Print the IP address
	Serial.println(WiFi.localIP());
	}
	

	void loop() {
	

	 delay(1000);
	

	 Serial.println(Thermister(AnalogRead()));
	 float temp = Thermister(AnalogRead());
	
	WiFiClient client = server.available();
	client.println("HTTP/1.1 200 OK");
	client.println("Content-Type: text/html");
	client.println("Connection: close");  // the connection will be closed after completion of the response
	client.println("Refresh: 3");  // refresh the page automatically every 5 sec
	client.println();
	client.println("<!DOCTYPE html>");
	client.println("<html xmlns='http://www.w3.org/1999/xhtml'>");
	client.println("<head>\n<meta charset='UTF-8'>");
	client.println("<title>WifiTempSensor</title>");
	client.println("<link href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' rel='stylesheet'>");
	client.println("</head>\n<body>");
	client.println("<div class='container'>");
	client.println("<div class='panel panel-default' margin:15px>");
	client.println("<div class='panel-heading'>");
	client.println("<H2>Wifi Temp Sensor</H2>");
	client.println("<div class='panel-body' style='background-color: powdergreen'>");
	client.println("<pre>");
	client.print("Temperature (°C)  : ");
	client.println(temp, 2);
	client.println("</pre>");
	client.println("</div>");
	client.println("</div>");
	client.println("</div>");
	client.print("</body>\n</html>");
	}
	

	int AnalogRead() {
	 int val = 0;
	 for(int i = 0; i < 20; i++) {

  • Use Arduino IDE to upload the code in esp8266
This post is licensed under CC BY 4.0 by the author.
Contents