Getting analog data from and arduino to appear in python

I have achieved success with similar programs in the past but I am having some issues this time around. I am using a sensor with an arduino in A0. In Arduino the program runs as expected. When I attempt to get this data to appear in my python program it will pen the program but nothing appears.

Arudnio Code:
void setup() {
void loop() {

int sensorValue0 = analogRead(A0);

Serial.print(" ");


import serial

arduinoData = serial.Serial(‘com5’, 9600)

while True:
while (arduinoData.inWaiting() ==0):
arduinoBytes = arduinoData.readline()[:-2]
arduinoString = arduinoBytes.decode(‘UTF-8’)#could use ‘ASCII’ or default()

dataArray = arduinoString
sensor1 = int(dataArray[0])


Any suggestions would be appreciated. Thank you


Unfortunately, given the problem involves serial communication between your Arduino and your machine, its very difficult for anyone here to provide much useful help without having an Ardiuino to test on, running the code on both ends and introspecting the result. It could be anything from the wiring, to OS-level issues, to something with your C program, to the settings for your serial devices, to something in your Python code. Furthermore, you aren’t likely to find too many people familiar with your specific setup here.

As such, I’d suggest posting this on an Arduino help forum instead, as you are much more likely to get a useful answer there. All I can suggest on the Python end is injecting print statements to see where things are going wrong, trying your earlier programs that did work and seeing if they work, and trying another program to see if you’re able to receive data over serial, and if it matches the format you expect.

Best of luck!