Fresh install creates no wifi

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ImTheVeloper
Posts: 1
Joined: Tue Mar 16, 2021 11:36 pm

Fresh install creates no wifi

Post by ImTheVeloper » Tue Mar 16, 2021 11:56 pm

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.

lumpynose
Posts: 1
Joined: Tue Mar 02, 2021 10:41 pm

Re: Fresh install creates no wifi

Post by lumpynose » Mon Mar 22, 2021 11:31 pm

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:

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()
wifi_connect.py:

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())
passwd_fetch.py:

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
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.

Post Reply