Python Forum
Not receiving serial data from arduino
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not receiving serial data from arduino
#1
Hi guys. So, I am trying to receive serial data from my Arduino Uno.
The Arduino sends the heading from a magnetometer over serial, but the Python code does not receive it.
This is my Python code:
import serial

Arduino = serial.Serial("COM3", baudrate = 9600) # serial device
angle = 0
Compass() #This function draws the compass 

while (True):
    
    try:
        flushInput()
        angle = Arduino.readline()
        angle = angle.strip()
        angle = int(angle)
        compasspointer.settiltangle(-angle+90)  #update heading
        print(angle)
    except:
        pass
My Arduino code:

void setup()
{
Serial.begin(9600);
}

int heading=105;//just a value
void loop()
{
Serial.println(heading);
thanks for your help!
Reply


Messages In This Thread
Not receiving serial data from arduino - by dinoel_cool - Aug-26-2018, 02:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 4,442 Aug-24-2023, 07:56 AM
Last Post: gowb0w
  Receiving this error in my "response" and causes script to return wrong status cubangt 18 2,135 Aug-13-2023, 12:16 AM
Last Post: cubangt
Star Pyserial not reading serial.readline fast enough while using AccelStepper on Arduino MartyTinker 4 4,178 Mar-13-2023, 04:02 PM
Last Post: deanhystad
  Trying to Get Arduino sensor data over to excel using Python. eh5713 1 1,753 Dec-01-2022, 01:52 PM
Last Post: deanhystad
  SMA (simple moving avg) Not receiving Data (stock prices). gdbengo 2 1,482 Jul-31-2022, 08:20 PM
Last Post: paulyan
  Receiving snmp traps with more than one Community String ilknurg 0 2,265 Jan-19-2022, 09:02 AM
Last Post: ilknurg
  Help reading data from serial RS485 korenron 8 14,131 Nov-14-2021, 06:49 AM
Last Post: korenron
  serial connection to Arduino Jack9 4 2,509 Oct-22-2021, 10:18 AM
Last Post: Jack9
  Reading Serial data Moris526 6 5,452 Dec-26-2020, 04:04 PM
Last Post: Moris526
  Serial loopback with Arduino doesn't work ThomasS 3 2,811 Sep-19-2020, 12:47 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020