UDP problems

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
chromecat
Posts: 4
Joined: Thu Jul 19, 2018 5:11 pm

UDP problems

Post by chromecat » Tue Apr 07, 2020 12:05 pm

Hello, i try to figure out how to send UDP messages from a D1 mini with Wifi.
From normal Python in the same Network -> no problem

My code:

Code: Select all

import network
import usocket as socket

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('Test', 'test')

udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

addr = ("192.168.101.4", 11152)
data = "hello"

while True:
    udp.sendto(data, addr)
The sendto command results in a '5' so i guess it was send.

The d1 connects to the wifi (ifconfig() giving an IP adress)

When sending UDP with my Ipad to ("192.168.101.4", 11152) the message can be received.

Any thoughts? do i have any mistake in understanding?

Thanks

Post Reply