如何使用Internet读取Arduino数据输出



我使用uno和以太网屏蔽的arduino项目。我不是要在Python中打印Arduino数据输出。我已经尝试使用Pyserial Python并成功尝试了这种情况。然后,我不想尝试我的python可以通过互联网而不是串行python读取Arduino数据输出。

拓扑:Arduino与Eth。盾牌---> switch< ---笔记本电脑

*注意:交换机具有我的路由器的Internet连接。

你能帮我吗,伙计们?

您在这里使用的IP应该是" Localhost",因为只有Arduino需要计算机的地址而不是相反。您的Python脚本只是在听任何人连接的人。尝试以下操作:

import socket
UDP_IP = "localhost" # this computer
UDP_PORT = 3939 # the port that the arduino should connect to
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP, UDP_PORT))
while True:
    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
    print "received message:", data

最新更新