I just got a new esp32 and installed esp32-idf3-20210202-v1.14.bin in it. Unlike my wemos D1 with esp8266, the fresh installation did not create a wifi AP, so I tried importing webrepl_setup via cable using uPyCraft, but again no AP. When I create an ap manually via uPyCraft I can find a network, but named esp32-YYYY instead of micropython-XXXX and webrepl finally works. Tried installing esp32-idf4-20210202-v1.14.bin instead, but the same happens. Any suggestions? Creating a do_connect() setting a specific ip also does not seem to let me access webrepl and no error has been reported while erasing or writing flash.
PS: I have never used an esp32 before.
Fresh install creates no wifi
Re: Fresh install creates no wifi
I've never used webrepl. Being old school I'm using ampy and picocom. Ampy to upload python code and picocom to run it (by typing a ctl-d).
main.py:
wifi_connect.py:
passwd_fetch.py:
The mqtt stuff is from micropython-lib on github. I upload these files with "ampy put" for each one, then connect to the esp32 with picocom, then do a ctl-d and I get the output of all of the print statements.
main.py:
Code: Select all
from wifi_connect import WifiConnect
from umqtt.simple import MQTTClient
from passwd_fetch import Password
# Test reception e.g. with:
# mosquitto_sub -t foo_topic
def main(server = "192.168.1.7"):
password_fetch = Password()
passwd = password_fetch.fetch()
print("password:", passwd)
wificonnect = WifiConnect("TPI 2.4g", passwd);
wificonnect.connect()
c = MQTTClient("umqtt_client", server, port = 1883, user = "tiny", password = passwd)
c.connect()
c.publish(b"foo_topic", b"hello")
c.disconnect()
if __name__ == "__main__":
main()
Code: Select all
import network
class WifiConnect:
def __init__(self, essid, password):
self.essid = essid
self.password = password
def connect(self):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect(self.essid, self.password)
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
Code: Select all
class Password:
def __init__(self, file = "passwd.txt"):
self.file = file
def fetch(self):
with open(self.file, 'r') as reader:
input = reader.readline(-1)
passwd = input.rstrip('\n')
return passwd