Greetings. I’ve been beating my head on this for too long now. I am setting up a suite of sensors running off an Arduino Rev3 and WifiShield (v1.1.0) and I want to send the data in real-time over our wifi to a PC, where a Python program will receive/log the data.
For now I just want to set up the network connection, send a message from the arduino, and have the python program receive it… which is where I’m stuck.
On the Arduino side, I’m simply using using the WiFiChatServer example. The wifi shield connects to our wifi just fine.
On the python side, I’m using a socket and trying to connect to the wifi shield ip and port 23. But the connection fails and I get the error: errno 10060: connected party failed to respond.
import socket TCP_IP = '126.96.36.199' #Arduino WiFi IP TCP_PORT = 23 #Arudino WiFi Port BUFFER_SIZE = 1024 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP,TCP_PORT)) s.listen(1) (conn,addr) = s.accept() print 'Connection address: ',addr while True: data = conn.recv(BUFFER_SIZE) if not data: break print 'received data: ',data conn.send('ECHO') conn.close() s.close()
I suspect I’m confused about the ports. I would be very grateful for some assistance.