I'm a beginner with Raspi and I would appreciate your advice and input on a project I'm working on.
Hardware: Raspi 3B+ with latest Rasbian, Arduino MKR 1000
I have a bunch of sensors attached to the Raspi(Ultrasonic and IMU) and I want to pass data from the Raspi to the MKR1000 with Raspi acting like server and Arduino like a client. They will be connected to the same network through Wi-Fi. I want to know if this is possible and what is the most easiest way to do this? Also, I was advised that writing a socket would be helpful with the problem but I have no clue how to write a socket for Arduino that can interact with the Pi, I already have a socket server program that I use for Pi(Code below), would this program be capable of sending strings to the Arduino? Any resources, videos, sample code would be appreciated. Thank you for your time.
import socket import sys HOST = '192.168.130.206' #Ip the server is run on PORT = 50007 # Arbitrary non-privileged port s = None for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE): af, socktype, proto, canonname, sa = res try: s = socket.socket(af, socktype, proto) except OSError as msg: s = None continue try: s.bind(sa) s.listen(1) except OSError as msg: s.close() s = None continue break if s is None: print('could not open socket') sys.exit(1) conn, addr = s.accept() with conn: print('Connected by', addr) while True: data = conn.recv(1024) if not data: break conn.send(data) enter code here