Back to blog

ESP32 WiFi communication in MicroPython part 1

Welcome to mini-series of blogs about WiFi communication using ESP32 microprocessors in micropython. In this series, I will try to explain how to use WiFi built-in ESP32 MCU. The first blog in the series will introduce you to basic concepts of WiFi and configuration them on your ESP32 MCU.

A basic introduction to WiFi communication on ESP32

WiFi is one of the most popular wireless networking technology. The most common way of using it in daily life is connecting your mobile phone or computer to gain access to the internet by a router. In this case, connected devices are configured as a station (STA) and a router is configured as an access point (AP).

When connecting to a WiFi you need the name of a network you want to connect to, which is also known as SSIDย  (service set identifier).

One of the biggest advantages of ESP32 MCUs is the built-in WiFi controller. This allows you to create an IoT device without additional communication peripherals. ESP32 WiFi modules allow you to configure it as a station or access point. You can configure ESP32 WiFi as STA and AP at the same time. This topic may seem complicated at first glance, but in reality, it is quite simple.

Configuration of ESP32 WiFi

Now when you know basic terminology required to work with WiFi devices we can start coding. All functions required to communicate via WiFi are located in a module network.

Configuration as an access point:

The configuration of the access point is pretty simple. To configure a device as an access point you need to perform 2 steps. The first step is to enable the access point interface, the second part is to configure. Code example:

After running this code on your device you will be able to see your ESP32 access point device as available WiFi you can connect to. In my case, I could detect my device called Wizzdev AP. In the next post on our blog, I will try to explain how to use an access point configuration to create a web server.

Configuration as a station:

The configuration of the station (STA) is even simpler. Similar to the configuration of an access point first step is to activate the STA interface. Additionally, you can list all available networks by calling scan functions on your STA handler.

You can check if your connection was successful by checking repl output. Instruction how to configure it can be found here:

https://docs.micropython.org/en/latest/esp8266/tutorial/repl.html

Conclusion

As you can see it is pretty easy to configure ESP32 WiFi using micropython. In the next blog from this series, I will try to explain how to create a web server on your ESP device. You can find examples of the code in our GitHub repository: https://github.com/wizzdev-pl/ (repository coming soon)

Recent entries

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.