{"id":84495,"date":"2019-04-25T12:32:58","date_gmt":"2019-04-25T12:32:58","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=84495"},"modified":"2024-03-06T14:11:08","modified_gmt":"2024-03-06T14:11:08","slug":"micropython-esp32-esp8266-dht11-dht22-web-server","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/micropython-esp32-esp8266-dht11-dht22-web-server\/","title":{"rendered":"MicroPython: ESP32\/ESP8266 with DHT11\/DHT22 Web Server (Weather Station)"},"content":{"rendered":"\n<p>In this tutorial, you\u2019re going to learn how to create a simple web server with the ESP32 or ESP8266 to display readings from the DHT11 or DHT22 temperature and humidity sensors.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32_esp8266_dht_web_server_micropython.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"MicroPython ESP32 ESP8266 with DHT11 DHT22 Web Server Temperature and humidity\" class=\"wp-image-84497\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32_esp8266_dht_web_server_micropython.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32_esp8266_dht_web_server_micropython.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32_esp8266_dht_web_server_micropython.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32_esp8266_dht_web_server_micropython.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>For an introduction to the DHT11\/DHT22 temperature and humidity sensors with MicroPython, read the following guide:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-dht11-dht22-micropython-temperature-humidity-sensor\/\">MicroPython: ESP32\/ESP8266 with DHT11\/DHT22 Temperature and Humidity Sensor<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites &#8211; Flashing MicroPython<\/h2>\n\n\n\n<p>To follow this tutorial you need MicroPython firmware installed in your ESP32 or ESP8266 boards. You also need an IDE to write and upload the code to your board. We suggest using Thonny IDE or uPyCraft IDE:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Thonny IDE:\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-thonny-micropython-python-ide-esp32-esp8266\/\">Installing and getting started with Thonny IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/flashing-micropython-firmware-esptool-py-esp32-esp8266\/\">Flashing MicroPython Firmware with esptool.py<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>uPyCraft IDE:\n<ul class=\"wp-block-list\">\n<li>Install uPyCraft IDE (<a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-windows-pc-instructions\/\">Windows<\/a>,&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-mac-os-x-instructions\/\">Mac OS X<\/a>,&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-linux-ubuntu-instructions\/\">Linux<\/a>)<\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/flash-upload-micropython-firmware-esp32-esp8266\/\">Flash\/Upload MicroPython Firmware to ESP32 and ESP8266<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>To follow this tutorial you need to wire the DHT11 or DHT22  sensor to the ESP32 or ESP8266. You need to use a 10k Ohm pull-up resistor.<\/p>\n\n\n\n<p>Here&#8217;s a list of parts you need to build the circuit:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\">ESP32<\/a> or <a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\">ESP8266 <\/a>(read <a href=\"https:\/\/makeradvisor.com\/esp32-vs-esp8266\/\">ESP32 vs ESP8266<\/a>)<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/dht11-temperature-humidity-sensor\/\" target=\"_blank\">DHT11 <\/a>or <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/dht22-temperature-humidity-sensor\/\" target=\"_blank\">DHT22 <\/a>temperature and humidity sensor<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\">10k Ohm resistor<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\">Breadboard<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\">Jumper wires<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Schematic: ESP32 with DHT11\/DHT22 <\/h2>\n\n\n\n<p>Wire the DHT22 or DHT11 sensor to the ESP32 development board as shown in the following schematic diagram.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"728\" height=\"910\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht_esp32_bb-1.png?resize=728%2C910&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"MicroPython ESP32 with DHT11 DHT22 Web Server Temperature and humidity Circuit Schematic wiring\" class=\"wp-image-84481\" style=\"width:546px;height:683px\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht_esp32_bb-1.png?w=728&amp;quality=100&amp;strip=all&amp;ssl=1 728w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht_esp32_bb-1.png?resize=240%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 240w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/figure><\/div>\n\n\n<p>In this example, we&#8217;re connecting the DHT data pin to <span class=\"rnthl rntcblue\">GPIO 14<\/span>. However, you can use any other suitable digital pin. <\/p>\n\n\n\n<p>Learn how to use the ESP32 GPIOs with our guide:  <a href=\"https:\/\/randomnerdtutorials.com\/esp32-pinout-reference-gpios\/\">ESP32 Pinout Reference: Which GPIO pins should you use?<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mce_31\">Schematic: ESP8266 with DHT11\/DHT22 <\/h2>\n\n\n\n<p>Follow the next tutorial if you&#8217;re using an ESP8266 board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"572\" height=\"898\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht_esp8266_bb.png?resize=572%2C898&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"MicroPython ESP8266 with DHT11 DHT22 Web Server Temperature and humidity Circuit Schematic wiring\" class=\"wp-image-84482\" style=\"width:429px;height:674px\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht_esp8266_bb.png?w=572&amp;quality=100&amp;strip=all&amp;ssl=1 572w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht_esp8266_bb.png?resize=191%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 191w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Code <\/h2>\n\n\n\n<p>For this project you\u2019ll need a&nbsp;<em>boot.py<\/em> file and a<em>main.py<\/em>&nbsp;file.&nbsp;The&nbsp;<em>boot.py<\/em> file contains the code that only needs to run once on boot. This includes importing libraries, network credentials, instantiating pins, connecting to your network, and other configurations.<\/p>\n\n\n\n<p>The&nbsp;<em>main.py<\/em> file contains the code that runs the web server to serve files and perform tasks based on the requests received by the client.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">boot.py<\/h3>\n\n\n\n<p>Create a new file in your MicroPython IDE. Copy the following code to your <em>boot.py<\/em> file.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Complete project details at https:\/\/RandomNerdTutorials.com\n\ntry:\n  import usocket as socket\nexcept:\n  import socket\n\nimport network\nfrom machine import Pin\nimport dht\n\nimport esp\nesp.osdebug(None)\n\nimport gc\ngc.collect()\n\nssid = 'REPLACE_WITH_YOUR_SSID'\npassword = 'REPLACE_WITH_YOUR_PASSWORD'\n\nstation = network.WLAN(network.STA_IF)\n\nstation.active(True)\nstation.connect(ssid, password)\n\nwhile station.isconnected() == False:\n  pass\n\nprint('Connection successful')\nprint(station.ifconfig())\n\nsensor = dht.DHT22(Pin(14))\n#sensor = dht.DHT11(Pin(14))\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP-MicroPython\/esp_dht_web_server_boot.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>We&#8217;ve covered in great detail the web server code <a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">in a previous tutorial<\/a>. So, we&#8217;ll just take a look at the relevant parts for this example.<\/p>\n\n\n\n<p>Import the necessary libraries to create a web server.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>try:\n  import usocket as socket\nexcept:\n  import socket\n\nimport network<\/code><\/pre>\n\n\n\n<p>Import the <span class=\"rnthl rntliteral\">Pin<\/span> class from the <span class=\"rnthl rntliteral\">machine<\/span> module and the <span class=\"rnthl rntliteral\">dht<\/span> module to read from the DHT sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>from machine import Pin\nimport dht<\/code><\/pre>\n\n\n\n<p>You also need to initialize the sensor by creating a <span class=\"rnthl rntliteral\">dht<\/span> instance on <span class=\"rnthl rntcblue\">GPIO 14<\/span> as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>sensor = dht.DHT22(Pin(14))<\/code><\/pre>\n\n\n\n<p>If you\u2019re using a DHT11 sensor, uncomment the next line, and comment the previous one:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>sensor = dht.DHT11(Pin(14))<\/code><\/pre>\n\n\n\n<p>Don\u2019t forget to add your network credentials on the following lines:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>ssid = 'REPLACE_WITH_YOUR_SSID'\npassword = 'REPLACE_WITH_YOUR_PASSWORD'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">main.py<\/h3>\n\n\n\n<p>Copy the following code to your <em>main.py<\/em> file. <\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Complete project details at https:\/\/RandomNerdTutorials.com\n\ndef read_sensor():\n  global temp, hum\n  temp = hum = 0\n  try:\n    sensor.measure()\n    temp = sensor.temperature()\n    hum = sensor.humidity()\n    if (isinstance(temp, float) and isinstance(hum, float)) or (isinstance(temp, int) and isinstance(hum, int)):\n      msg = (b'{0:3.1f},{1:3.1f}'.format(temp, hum))\n\n      # uncomment for Fahrenheit\n      #temp = temp * (9\/5) + 32.0\n\n      hum = round(hum, 2)\n      return(msg)\n    else:\n      return('Invalid sensor readings.')\n  except OSError as e:\n    return('Failed to read sensor.')\n\ndef web_page():\n  html = &quot;&quot;&quot;&lt;!DOCTYPE HTML&gt;&lt;html&gt;\n&lt;head&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\n  &lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/use.fontawesome.com\/releases\/v5.7.2\/css\/all.css&quot; integrity=&quot;sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr&quot; crossorigin=&quot;anonymous&quot;&gt;\n  &lt;style&gt;\n    html {\n     font-family: Arial;\n     display: inline-block;\n     margin: 0px auto;\n     text-align: center;\n    }\n    h2 { font-size: 3.0rem; }\n    p { font-size: 3.0rem; }\n    .units { font-size: 1.2rem; }\n    .dht-labels{\n      font-size: 1.5rem;\n      vertical-align:middle;\n      padding-bottom: 15px;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;h2&gt;ESP DHT Server&lt;\/h2&gt;\n  &lt;p&gt;\n    &lt;i class=&quot;fas fa-thermometer-half&quot; style=&quot;color:#059e8a;&quot;&gt;&lt;\/i&gt; \n    &lt;span class=&quot;dht-labels&quot;&gt;Temperature&lt;\/span&gt; \n    &lt;span&gt;&quot;&quot;&quot;+str(temp)+&quot;&quot;&quot;&lt;\/span&gt;\n    &lt;sup class=&quot;units&quot;&gt;&amp;deg;C&lt;\/sup&gt;\n  &lt;\/p&gt;\n  &lt;p&gt;\n    &lt;i class=&quot;fas fa-tint&quot; style=&quot;color:#00add6;&quot;&gt;&lt;\/i&gt; \n    &lt;span class=&quot;dht-labels&quot;&gt;Humidity&lt;\/span&gt;\n    &lt;span&gt;&quot;&quot;&quot;+str(hum)+&quot;&quot;&quot;&lt;\/span&gt;\n    &lt;sup class=&quot;units&quot;&gt;%&lt;\/sup&gt;\n  &lt;\/p&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;&quot;&quot;&quot;\n  return html\n\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.bind(('', 80))\ns.listen(5)\n\nwhile True:\n  conn, addr = s.accept()\n  print('Got a connection from %s' % str(addr))\n  request = conn.recv(1024)\n  print('Content = %s' % str(request))\n  sensor_readings = read_sensor()\n  print(sensor_readings)\n  response = web_page()\n  conn.send('HTTP\/1.1 200 OK\\n')\n  conn.send('Content-Type: text\/html\\n')\n  conn.send('Connection: close\\n\\n')\n  conn.sendall(response)\n  conn.close()\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP-MicroPython\/esp_dht_web_server_main.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Reading the DHT sensor<\/h4>\n\n\n\n<p>First, create a function called <span class=\"rnthl rntliteral\">read_sensor()<\/span> that reads temperature and humidity. You can use that function in any other projects in which you need to take sensor readings from DHT sensors.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def read_sensor():<\/code><\/pre>\n\n\n\n<p>The function starts by creating two global variables, so we can use them in all parts of the script (they are initilazed as 0).<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>global temp, hum\ntemp = hum = 0<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">temp<\/span> variable holds the temperature read from the sensor and the <span class=\"rnthl rntliteral\">hum<\/span> holds the humidity read from the sensor.<\/p>\n\n\n\n<p>Next, use <span class=\"rnthl rntliteral\">try<\/span> and <span class=\"rnthl rntliteral\">except<\/span> statements. Inside the <span class=\"rnthl rntliteral\">try<\/span> statement we try to get the temperature and humidity values.<\/p>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> try and except allows us to continue the execution of the program when an exception happens. For example, when an error occurs, a try block code execution is stopped and transferred to the except block. In our example, the exception is especially useful to prevent the web server from crashing when we are not able to read from the sensor.<\/p>\n\n\n\n<p>We measure the sensor by using the <span class=\"rnthl rntliteral\">measure()<\/span> method on the <span class=\"rnthl rntliteral\">sensor<\/span> object.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>try:\n sensor.measure()<\/code><\/pre>\n\n\n\n<p>Then, read the temperature with <span class=\"rnthl rntliteral\">sensor.temperature()<\/span> and the humidity with <span class=\"rnthl rntliteral\">sensor.humidity()<\/span>. Save those readings on the <span class=\"rnthl rntliteral\">temp<\/span> and <span class=\"rnthl rntliteral\">hum<\/span> variables.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>temp = sensor.temperature()\nhum = sensor.humidity()<\/code><\/pre>\n\n\n\n<p>Valid temperature and humidity readings should be of type float (if you\u2019re using a DHT22 sensor) or type int (if you\u2019re using a DHT11) sensor. So, we check if we have valid readings by using the <span class=\"rnthl rntliteral\">isinstance()<\/span> function before proceeding.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>if (isinstance(temp, float) and isinstance(hum, float)) or (isinstance(temp, int) and isinstance(hum,int)):<\/code><\/pre>\n\n\n\n<p><strong>Note: <\/strong> the <span class=\"rnthl rntliteral\">isinstance()<\/span> function accepts as arguments the variable and the data type: <span class=\"rnthl rntliteral\">isinstance(variable, data type).<\/span> It returns <span class=\"rnthl rntliteral\">True<\/span> if the variable corresponds to the inserted data type and <span class=\"rnthl rntliteral\">False<\/span> if it doesn\u2019t.<\/p>\n\n\n\n<p>If the readings are valid, prepare a message to be printed on the Shell that includes the temperature and humidity readings:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>msg = (b'{0:3.1f},{1:3.1f}'.format(temp, hum))<\/code><\/pre>\n\n\n\n<p>If you want to display temperature in Fahrenheit, uncomment the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>#temp = temp * (9\/5) + 32.0<\/code><\/pre>\n\n\n\n<p>Round the humidity reading to two decimal points. This will be printed later on the web server page.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>hum = round(hum, 2)<\/code><\/pre>\n\n\n\n<p>Finally, return the message with the temperature and humidity:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>return(msg)<\/code><\/pre>\n\n\n\n<p>In case we don\u2019t get valid sensor readings (not float type), we return <span class=\"rnthl rntliteral\">Invalid sensor readings.<\/span> message.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>else:\n    return('Invalid sensor readings.')<\/code><\/pre>\n\n\n\n<p>In case we\u2019re not able to read from the sensor (for example, in case it disconnects), return an error message.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>except OSError as e:\n  return('Failed to read sensor.')<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Web Page<\/h4>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">web_page()<\/span> function returns the HTML page. We&#8217;ll go through each line of the HTML and see what it does.<\/p>\n\n\n\n<p>The following <span style=\"color: #333399;\">&lt;meta&gt;<\/span> tag makes your web page responsive in any browser.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;<\/code><\/pre>\n\n\n\n<p>The <span style=\"color: #333399;\">&lt;link&gt;<\/span> tag is needed to load the icons used in the webpage from the fontawesome website.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/6.5.1\/css\/all.min.css\"><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Styles<\/h4>\n\n\n\n<p>Between the <span style=\"color: #333399;\">&lt;style&gt;&lt;\/style&gt;<\/span> tags, we add some CSS to style the web page.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;style&gt;\n html {\n   font-family: Arial;\n   display: inline-block;\n   margin: 0px auto;\n   text-align: center;\n  }\n  h2 { font-size: 3.0rem; }\n  p { font-size: 3.0rem; }\n  .units { font-size: 1.2rem; }\n  .dht-labels{\n    font-size: 1.5rem;\n    vertical-align:middle;\n    padding-bottom: 15px;\n  }\n&lt;\/style&gt;<\/code><\/pre>\n\n\n\n<p>Basically, we&#8217;re setting the HTML page to display the text with Arial font in block without margin, and aligned at the center.<\/p>\n\n\n\n<pre class=\"wp-block-code language-css\"><code>html {\n  font-family: Arial;\n  display: inline-block;\n  margin: 0px auto;\n  text-align: center;\n }<\/code><\/pre>\n\n\n\n<p>We set the font size for the heading (<span class=\"rnthl rntliteral\">h2<\/span>), paragraph (<span class=\"rnthl rntliteral\">p<\/span>) and the units(<span class=\"rnthl rntliteral\">.units<\/span>) of the readings.<\/p>\n\n\n\n<pre class=\"wp-block-code language-css\"><code>h2 { font-size: 3.0rem; }\np { font-size: 3.0rem; }\n.units { font-size: 1.2rem; }<\/code><\/pre>\n\n\n\n<p>The labels for the readings are styled as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code language-css\"><code>dht-labels {\n  font-size: 1.5rem;\n  vertical-align:middle;\n  padding-bottom: 15px;\n}<\/code><\/pre>\n\n\n\n<p>All of the previous tags should go between the <span style=\"color: #333399;\">&lt;head&gt;<\/span> and <span style=\"color: #333399;\">&lt;\/head&gt;<\/span> tags. These tags are used to include content that is not directly visible to the user, like the <span style=\"color: #333399;\">&lt;meta&gt;<\/span> , the <span style=\"color: #333399;\">&lt;link&gt;<\/span> tags, and the styles.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">HTML Body<\/h4>\n\n\n\n<p>Inside the <span style=\"color: #333399;\">&lt;body&gt;&lt;\/body&gt;<\/span> tags is where we add the web page content.<br><\/p>\n\n\n\n<p>The <span style=\"color: #333399;\">&lt;h2&gt;&lt;\/h2&gt;<\/span> tags add a heading to the web page. In this case, the \u201cESP DHT server\u201d text, but you can add any other text.<br><\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;h2&gt;ESP DHT Server&lt;\/h2&gt;<\/code><\/pre>\n\n\n\n<p>Then, there are two paragraphs. One to display the temperature and the other to display the humidity. The paragraphs are delimited by the <span style=\"color: #333399;\">&lt;p&gt;<\/span> and <span style=\"color: #333399;\">&lt;\/p&gt;<\/span> tags. The paragraph for the temperature is the following:<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;p&gt;\n  &lt;i class=\"fas fa-thermometer-half\" style=\"color:#059e8a;\"&gt;&lt;\/i&gt; \n  &lt;span class=\"dht-labels\"&gt;Temperature&lt;\/span&gt; \n  &lt;span&gt;\"\"\"+str(temp)+\"\"\"&lt;\/span&gt;\n  &lt;sup class=\"units\"&gt;\u00b0C&lt;\/sup&gt;\n&lt;\/p&gt;<\/code><\/pre>\n\n\n\n<p>And the paragraph for the humidity is on the following snipet:<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;p&gt;\n  &lt;i class=\"fas fa-tint\" style=\"color:#00add6;\"&gt;&lt;\/i&gt; \n  &lt;span class=\"dht-labels\"&gt;Humidity&lt;\/span&gt;\n  &lt;span&gt;\"\"\"+str(hum)+\"\"\"&lt;\/span&gt;\n  &lt;sup class=\"units\"&gt;%&lt;\/sup&gt;\n&lt;\/p&gt;<\/code><\/pre>\n\n\n\n<p>The <span style=\"color: #333399;\">&lt;i&gt;<\/span> tags display the fontawesome icons. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">How to display icons<\/h4>\n\n\n\n<p>To chose the icons, go to the <a href=\"https:\/\/fontawesome.com\/icons?d=gallery\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Font Awesome Icons website<\/a>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"476\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesomepage.png?resize=750%2C476&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32\/ESP8266 Web Server HTML page icons\" class=\"wp-image-83530\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesomepage.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesomepage.png?resize=300%2C190&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Search the icon you&#8217;re looking for. For example, &#8220;thermometer&#8221;.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"476\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesome-thermometer.png?resize=750%2C476&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32\/ESP8266 Web Server HTML page icons\" class=\"wp-image-83531\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesome-thermometer.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesome-thermometer.png?resize=300%2C190&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Click the desired icon. Then, you just need to copy the HTML text provided.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;i class=\"fas fa-thermometer-half\"&gt;<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"476\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesome-thermometer-html.png?resize=750%2C476&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32\/ESP8266 Web Server HTML page icons\" class=\"wp-image-83532\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesome-thermometer-html.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/03\/fontawesome-thermometer-html.png?resize=300%2C190&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>To chose the color, you just need to pass the <span class=\"rnthl rntliteral\">style<\/span> parameter with the color in hexadecimal, as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;i class=\"fas fa-tint\" style=\"color:#00add6;\"&gt;&lt;\/i&gt; <\/code><\/pre>\n\n\n\n<p>Proceeding with the HTML text&#8230;<\/p>\n\n\n\n<p>The next line writes the word &#8220;Temperature&#8221; into the web page. <\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;span class=\"dht-labels\"&gt;Temperature&lt;\/span&gt;<\/code><\/pre>\n\n\n\n<p>After that, we add the actual temperature value to the HTML page by concatenating the <span class=\"rnthl rntliteral\">temp<\/span> variable as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;span&gt;\"\"\"+str(temp)+\"\"\"&lt;\/span&gt;<\/code><\/pre>\n\n\n\n<p>Finally, we add the degree symbol.<br><\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;sup class=\"units\"&gt;\u00b0C&lt;\/sup&gt;<\/code><\/pre>\n\n\n\n<p>The <span style=\"color: #333399;\">&lt;sup&gt;&lt;<\/span><span style=\"color: #333399;\">\/sup&gt;<\/span> tags make the text superscript. <\/p>\n\n\n\n<p class=\"language-c\">We use the same approach for the humidity paragraph.<br><\/p>\n\n\n\n<pre class=\"wp-block-code language-html\"><code>&lt;p&gt;\n  &lt;i class=\"fas fa-tint\" style=\"color:#00add6;\"&gt;&lt;\/i&gt; \n  &lt;span class=\"dht-labels\"&gt;Humidity&lt;\/span&gt;\n  &lt;span&gt;\"\"\"+str(hum)+\"\"\"&lt;\/span&gt;\n  &lt;sup class=\"units\"&gt;%&lt;\/sup&gt;\n&lt;\/p&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Creating the web server<\/h4>\n\n\n\n<p>After that, make the usual procedures to create a socket server.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.bind(('', 80))\ns.listen(5)\n\nwhile True:\n  conn, addr = s.accept()\n  print('Got a connection from %s' % str(addr))\n  request = conn.recv(1024)\n  print('Content = %s' % str(request))\n  sensor_readings = read_sensor()\n  print(sensor_readings)\n  response = web_page()\n  conn.send('HTTP\/1.1 200 OK\\n')\n  conn.send('Content-Type: text\/html\\n')\n  conn.send('Connection: close\\n\\n')\n  conn.sendall(response)\n  conn.close()<\/code><\/pre>\n\n\n\n<p>For an in-depth explanation of this procedure, <a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">refer to this tutorial<\/a>. <\/p>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">while<\/span> loop, when we call the <span class=\"rnthl rntliteral\">read_sensor()<\/span> function to print the sensor readings and to update the global variables <span class=\"rnthl rntliteral\">temp<\/span> and <span class=\"rnthl rntliteral\">hum<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>sensor_readings = read_sensor()\nprint(sensor_readings)<\/code><\/pre>\n\n\n\n<p>So, the <span class=\"rnthl rntliteral\">web_page()<\/span> function generates HTML text with the latest sensor readings.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>response = web_page()<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Uploading the Code<\/h2>\n\n\n\n<p>After copying the code and making any necessary changes, you can upload the code to your ESP32 or ESP8266. <\/p>\n\n\n\n<p>First, upload the <em>boot.py<\/em>, and then the <em>main.py<\/em> file to your ESP32 or ESP8266.<\/p>\n\n\n\n<p>If you\u2019re using Thonny IDE, you just need to go to&nbsp;<strong>Device<\/strong>&nbsp;&gt;&nbsp;<strong>Upload current script as boot script<\/strong> or <strong>Upload current script as main script<\/strong>. After uploading the code, press the ESP on-board RESET button.<\/p>\n\n\n\n<p>The ESP32 or ESP8266 IP address should be printed on the MicroPython Shell.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"855\" height=\"312\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32-esp8266-dht11-dht22-temperature-humidity-web-server-ip-address.png?resize=855%2C312&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32\/ESP8266 DHT11 DHT22 Web Server IP Address MicroPython\" class=\"wp-image-84536\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32-esp8266-dht11-dht22-temperature-humidity-web-server-ip-address.png?w=855&amp;quality=100&amp;strip=all&amp;ssl=1 855w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32-esp8266-dht11-dht22-temperature-humidity-web-server-ip-address.png?resize=300%2C109&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32-esp8266-dht11-dht22-temperature-humidity-web-server-ip-address.png?resize=768%2C280&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 855px) 100vw, 855px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclblue\">If you\u2019re using uPyCraft IDE and you\u2019re having trouble uploading the code, go to the following tutorial and scroll down to the \u201cRunning Your First Script\u201d section: <a href=\"https:\/\/randomnerdtutorials.com\/getting-started-micropython-esp32-esp8266\/\">Getting Started with MicroPython on ESP32 and ESP8266<\/a>. <\/p>\n\n\n\n<p>Trouble uploading code with Thonny IDE? <a href=\"https:\/\/randomnerdtutorials.com\/getting-started-thonny-micropython-python-ide-esp32-esp8266\/\">Go to this tutorial<\/a> and scroll all the way down to the <strong>Troubleshooting Tips for Thonny IDE<\/strong> section.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>Open your browser and type the ESP IP address. You should access the web page with the latest sensor readings:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht-web-server-demo.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32\/ESP8266 DHT11 DHT22 Web Server MicroPython Demonstration\" class=\"wp-image-84533\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht-web-server-demo.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/dht-web-server-demo.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>At the same time, you can see on the MicroPython Shell, what&#8217;s going on in the background.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"855\" height=\"617\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-ESP8266-MicroPython-DHT11-DHT22-Web-Server.png?resize=855%2C617&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32\/ESP8266 DHT11 DHT22 Web Server MicroPython Demonstration\" class=\"wp-image-84534\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-ESP8266-MicroPython-DHT11-DHT22-Web-Server.png?w=855&amp;quality=100&amp;strip=all&amp;ssl=1 855w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-ESP8266-MicroPython-DHT11-DHT22-Web-Server.png?resize=300%2C216&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-ESP8266-MicroPython-DHT11-DHT22-Web-Server.png?resize=768%2C554&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 855px) 100vw, 855px\" \/><\/figure><\/div>\n\n\n<p>To get the latest sensor readings, you just need to refresh the web page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Troubleshooting<\/h3>\n\n\n\n<p>If your DHT sensor fails to get the readings, read our&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/solved-dht11-dht22-failed-to-read-from-dht-sensor\/\"><strong>DHT Troubleshooting Guide<\/strong><\/a>&nbsp;to help you fix the issue.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>To create a web server to display the temperature and humidity readings, you just need to concatenate the variables that hold the sensor readings with the HTML text. Make sure you get the sensor readings before displaying the web page, so that you always have the updated temperature and humidity.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful. If you want to learn more about MicroPython with the ESP32 and ESP8266, take a look at our eBook: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\"><strong>MicroPython Programming with ESP32 and ESP8266 eBook<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<p>You may also like the following tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-gpios-esp32-esp8266\/\">ESP32\/ESP8266 GPIOs Explained with MicroPython<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-analog-readings-micropython\/\">ESP32\/ESP8266 Analog Readings with MicroPython<\/a><br><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-pwm-micropython\/\">ESP32\/ESP8266 PWM with MicroPython \u2013 Dim LED<\/a><br><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">ESP32\/ESP8266 MicroPython Web Server \u2013 Control Outputs<\/a> <\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you\u2019re going to learn how to create a simple web server with the ESP32 or ESP8266 to display readings from the DHT11 or DHT22 temperature and humidity &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"MicroPython: ESP32\/ESP8266 with DHT11\/DHT22 Web Server (Weather Station)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/micropython-esp32-esp8266-dht11-dht22-web-server\/#more-84495\" aria-label=\"Read more about MicroPython: ESP32\/ESP8266 with DHT11\/DHT22 Web Server (Weather Station)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":84497,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,265,310,309,264],"tags":[],"class_list":["post-84495","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-esp8266-project","category-micropython","category-0-esp32-micropython","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/esp32_esp8266_dht_web_server_micropython.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/84495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=84495"}],"version-history":[{"count":1,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/84495\/revisions"}],"predecessor-version":[{"id":149823,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/84495\/revisions\/149823"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/84497"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=84495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=84495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=84495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}