Reputation: 11
I have managed to connect and pair my Neurosky Mindwave Mobile 2 to my Raspberry Pi 4. But when I try and stream data from the headset to my Raspberry Pi, my code says "No data received".
Here's my code:
import serial
# Define the port and settings for Mindwave
port = '/dev/rfcomm0'
baud_rate = 57600 # Mindwave typically uses 57600 bps
timeout_duration = 2 # Timeout in seconds
try:
# Open the serial connection
with serial.Serial(port, baud_rate, timeout=timeout_duration) as headset:
print("Connected to Mindwave on Raspberry Pi via /dev/rfcomm0")
# Continuously read data
while True:
data = headset.read(1) # Read one byte at a time
if data:
print("Data received:", data.hex()) # Print the data in hexadecimal format
else:
print("No data received. Waiting...")
except serial.SerialException as e:
print("Error connecting to headset:", e)
except Exception as e:
print("An unexpected error occurred:", e)
What am I missing?
I tried using headset.write(b'\xC0') to see if the headset needed to be told to start streaming data but my python program stopped printing after "Connected to Mindwave Mobile". I expected data but got nothing. It wouldn't even print "No data received. Waiting..."
Upvotes: 1
Views: 59