You can also use this board with MicroPython and it's quite a nice experience

This page has information and download for the most recent release of MicroPython for ESP32-C3 - just make sure you select 'USB' type since we are taking advantage of the USB port built into the C3!

You'll need esptool 3.1 or later to program the C3. Enter the ROM bootloader by holding down the BOOT button while clicking RESET button. Then upload to the serial port or COM port created.

We used a command like this to upload successfully

esptool --chip esp32c3 --port COM3 --baud 115200 --before default_reset --after hard_reset --no-stub  write_flash --flash_mode dio --flash_freq 80m 0x0 firmware.bin

To manage and run code, we used Thonny - setup to be a MicroPython (ESP32) board, then pick the matching serial port.

Install the urequests library via the Package Manager

Download the following code and save it to your ESP32-C3 as main.py

Don't forget to change MY_SSID and MY_PASSWORD to your WiFi access point

import time
import network
import urequests
station = network.WLAN(network.STA_IF)
station.active(True)

# Network settings
wifi_ssid = "MY_SSID"
wifi_password = "MY_PASSWORD"
url = "http://wifitest.adafruit.com/testwifi/index.html"

print("Scanning for WiFi networks, please wait...")
authmodes = ['Open', 'WEP', 'WPA-PSK' 'WPA2-PSK4', 'WPA/WPA2-PSK']
for (ssid, bssid, channel, RSSI, authmode, hidden) in station.scan():
  print("* {:s}".format(ssid))
  print("   - Channel: {}".format(channel))
  print("   - RSSI: {}".format(RSSI))
  print("   - BSSID: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}".format(*bssid))
  print()

# Continually try to connect to WiFi access point
while not station.isconnected():
    # Try to connect to WiFi access point
    print("Connecting...")
    station.connect(wifi_ssid, wifi_password)
    time.sleep(10)

# Display connection details
print("Connected!")
print("My IP Address:", station.ifconfig()[0])

# Perform HTTP GET request on a non-SSL web
response = urequests.get(url)

# Display the contents of the page
print(response.text)

Now click Stop and Run to load the main.py and run it, you should get the following indicating it could connect to WiFI and read the data from our webserver

This guide was first published on Mar 14, 2022. It was last updated on 2022-03-18 11:30:42 -0400.

This page (MicroPython Setup) was last updated on May 24, 2022.

Text editor powered by tinymce.