Analog pin data wireless to computer with python

I need to read live data off of both an Arduino's analog pins and a separate bluetooth device on a computer. I'm currently using a python script on the computer to connect to the bluetooth device and read from the serial of the Arduino connected via a cable to the computer, but I'd like to make the Arduino data reading also wireless.

I'm looking at the Arduino Uno R4 WiFi or the MKR WiFi 1010 but can't seem to actually find any clear tutorials for either on how to read the analog pin data from a computer wirelessly, only a phone. I'm not sure if I even need a wireless Arduino or some sort of hat/attachment for this. I will need to have a separate bluetooth connection open at the same time as well, so I'm concerned I will not be able to read from the Arduino via bluetooth if that is the only option. Are there any resources on how to read the Arduino data wirelessly on a computer with python? I'm a little confused since I can't seem to find any clear information.

Look for wireless serial adapters for PCs, some use Bluetooth.

Probably looking for the wrong things. First is to look for a way to read the data on the Arduino. Second is to look for ways to send data to the PC. You only combine them when each works individually.

By "also wireless", did you mean WiFi? If yes, in Python, the topic is "socket" (it needs to be decided who between Arduino and the PC will be the client and who will be the server). Communication can take place via UDP/IP (connectionless, like sending a postcard) or TCP/IP (connection and disconnection, like a phone call). Using IP, the sensor unit can be located literally anywhere in the world.

Minimal UDP example (tested):

# PC receiver
import socket
import select
import time

LOCAL_IP = '192.168.1.2'
LOCAL_PORT = 5005
BUFFER_SIZE = 1024

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((LOCAL_IP, LOCAL_PORT))
sock.setblocking(0) 

while True:
    readable, _, _ = select.select([sock], [], [], 0)
    if sock in readable:
        data, addr = sock.recvfrom(BUFFER_SIZE)
        message = data.decode()
        print(f"Received from {addr}: {message}")
    time.sleep(0.02)
// ESP8266 transmitter (sends one string every 10 seconds)
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "YOUR_NETWORK_NAME";
const char* password = "YOUR_PASSWORD";

const char* remoteAddress = "192.168.1.2";
const int   remotePort = 5005;

WiFiUDP udp;

void setup() {
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) delay(500);
}

void loop() {
    const char* msg = "Hello ESP8266!";
    udp.beginPacket(remoteAddress, remotePort);
    udp.write(msg);
    udp.endPacket();
    delay(10000);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.