1042 views|3 replies

247

Posts

4

Resources
The OP
 

[Digi-Key Follow me Issue 1] Network configuration and NTP network time synchronization via WeChat applet [Copy link]

 

1. Project description (about 800 words, pay attention to neat format)

The Raspberry Pi Pico W development board used in this event has wireless network function. In MicroPython, you can easily connect to the wireless hotspot through the network module by setting the SSID name and password to be connected.

During the development and debugging phase, you can simply write the ssid and password into the code.

However, in actual use, different wireless networks may be involved. If we need to modify the code every time to implement it, then our program will not be universal.

Wireless network configuration for embedded devices, common ones include SmartConfig, AirKiss, etc., and there are also solutions for transmitting connection information through UDP services.

After understanding, someone has realized the WeChat applet network configuration function on ESP8266/ESP32, which can be seen:

链接已隐藏,如需查看请登录或者注册
.

After reading the network distribution function in detail, we transplanted and improved it according to the actual situation of the Pico W development board, and finally formed this project.

This project uses the WeChat applet to configure the network for the Pico W development board, thereby achieving quick and convenient wireless connection information settings.

The main process of network distribution is as follows:

1. After the Pico W development board is started, first check whether there is any connection information of the last successful configuration

2. If yes, use the last connection information to connect to the wireless hotspot; if the connection fails, start a new round of network configuration process

3. If not, start a new round of network configuration process

4. After the wireless hotspot is successfully connected, NTP synchronization will be automatically started to calibrate the time

The network configuration process is as follows:

1. Set the wireless network card of PCIO W to AP mode and provide a hotspot to the outside world

2. After turning on AP mode, start the UDP service, wait for the mobile phone to connect and send connection information

3. Scan the QR code on your mobile phone to enter the network configuration interface

2. Main code snippets and descriptions corresponding to each function

2.1 Network initialization code:

This part of the code mainly initializes the network configuration instance class and the configuration file.

Connection information, saved in the mpyconnect/config.json file

2.2 Configuration reading and writing of connection information:

Connection information, saved in json format

2.3 Creating a wireless hotspot

This section creates a wireless hotspot for mobile phones to connect to.

2.4 Creation of UDP service and reception of information:

The original udp service is in blocking mode, which is changed to asyncio mode here

2.5 Connect the development board to the wireless router

This section is about connecting to the hotspot of the wireless router and how to handle disconnection.

2.6 NTP time synchronization

NTP time synchronization processing, where UTC_OFFSET = 8 * 60 * 60, indicating GMT+8 time zone

2.7 Main process of wireless network configuration:

This section is the main process of wireless network configuration. If the connection is successful, the information will be saved for use after the next restart. Otherwise, the network configuration process will be entered.

3. Function display and description (with pictures and text)

3.1 Pico W runs the network configuration program

3.2. Scan the QR code with your mobile phone to enter the network configuration interface of the WeChat applet:

image

3.3 Connect your phone to MpyConnect

3.4 On the wireless network configuration interface, click Start configuration:

3.5 Pico W receives the configuration information and starts the network configuration process:

3.6 After the configuration is successful, you can restart the device and run it again. The last configuration will be automatically used.

4. Your experience of this activity (including opinions or suggestions)

Thanks to the power of Pico W and the perfection of micropython, all functions were successfully completed.

In the future, we can consider dividing the tasks into simple and challenging ones to make everyone more motivated.

5. Complete code

one-key-connect-wifi.zip (3.43 KB, downloads: 2)
This post is from DigiKey Technology Zone

Latest reply

Not bad, not bad.   Details Published on 2023-7-1 20:12
 
 

6818

Posts

11

Resources
2
 

I need to learn the tutorial on how to adapt WeChat Xiaocheng to the development board!

This post is from DigiKey Technology Zone
 
 
 

150

Posts

0

Resources
3
 

Not bad, not bad.

This post is from DigiKey Technology Zone
 
 
 

247

Posts

4

Resources
4
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
C language uses binary tree to parse polynomials and evaluate

It mainly realizes the analysis of polynomial data calculation. If there is a need to make a simple calculator based on ...

STM8S001J3 uses HalfDuplex mode and uses IO mapping and cannot receive data.

The first time I used STM8S001J3, I mainly used UART and EEPROM. At that time, I saw that UART_TX conflicted with SWIM, ...

The disappearing boundary between MCU and MPU

There was a time when microprocessors (MPUs) and microcontrollers (MCUs) were two completely different devices. Microcon ...

Relationship between PN conduction voltage drop and current and temperature

*) , the E junction is affected by temperature, and the change in on-state voltage drop is related to Is and Ic The cond ...

Free Review - Topmicro Intelligent Display Module (5) Touch Screen

This post was last edited by wenyangzeng on 2021-11-1 16:36 Free Review - Topmicro Intelligent Display Module (5) Touch ...

View circuit - load switch

In many circuits, one power supply may correspond to multiple loads. Sometimes the power supply of the load needs to be ...

[Flower carving DIY] Interesting and fun music visualization series project (24) - infinite LED mirror light

I suddenly had the urge to do a series of topics on music visualization. This topic is a bit difficult and covers a wide ...

Common Problems in RF Circuit Design

666836 Common problems in RF circuit design 1. Interference between digital circuit modules and analog circuit modules ...

M4N-Dock basic usage environment configuration

# M4N-Dock basic usage environment configuration## Login system The default system is Debian system. Plug in the network ...

The price came out and I looked at it for more than an hour.

21.59 Did you guess it right?

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list