• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 HelloWorld Webserver scripts not running

Q&A Forum › Category: ESP32 › ESP32 HelloWorld Webserver scripts not running
0 Vote Up Vote Down
RAM KISHORE asked 6 years ago

boot.py
————————————-

try:
import usocket as socket
except:
import socket
import network
import esp
esp.osdebug(None)
import gc
gc.collect()
ssid = 'REPLACE_WITH_YOUR_SSID'
password = 'REPLACE_WITH_YOUR_PASSWORD'
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect(ssid, password)
while station.isconnected() == False:
pass
print('Connection successful')
print(station.ifconfig())

————————————–
main.py
————————————–

def web_page():
html = """<html><head><meta name="viewport"
content="width=device-width, initial-scale=1"></head>
<body><h1>Hello, World!</h1></body></html>"""
return html
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 80))
s.listen(5)
while True:
conn, addr = s.accept()
print('Got a connection from %s' % str(addr))
request = conn.recv(1024)
print('Content = %s' % str(request))
response = web_page()
conn.send('HTTP/1.1 200 OK\n')
conn.send('Content-Type: text/html\n')
conn.send('Connection: close\n\n')
conn.sendall(response)
conn.close()

—————————————

Question Tags: 153 and 154 are not running even after multiple tries., Hello, World!" Web Server scripts on boot.py & main.py as given on pages 152
4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi Ram.
Have you inserted your network credentials in the code? SSID and password?
Can you better explain what’s not working. Please provide more details.
Regards,
Sara
 

0 Vote Up Vote Down
RAM KISHORE answered 6 years ago

Hir Sara,
Hello World Web Server and ESP Web Server both are running after a modification. Actually, I didn’t replace the SSID and PASSWORD of my Wireless Router in station.connect statement in boot.py file. After replacing, it started and showed IP: 192.168.0.123. Then, after connecting my mobile to the router and placing this URL in browser, I got Hello World html page. Also I could control the led as next project. 
But the ESP32’s SSID & Password never asked in this scenario any where. Why?
Truly yours’
(RAM KISHORE)

0 Vote Up Vote Down
RAM KISHORE answered 6 years ago

Sorry. My typing mistake “Hir Sara”. Actually, I mean “Hi Sara”.
Truly yours’
(RAM KISHORE)

0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi Ram.
I’m glad it’s working now.
What do you mean by that the SSID and Password are never asked?
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.