Questions tagged [python]

Python is a programming language. Use this tag for questions regarding how to use Python with your Arduino, or on using of pySerial or such software. Also consider using [programming] and other specific tags.

44 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
21 views

Initial setup print getting cut off from printing

I am writing a program in Python (using PySerial) that needs to read data from the Arduino quickly. For this reason I have set the serial timeout to 0.01 seconds. (Baud rate is 115k) If I don't set ...
2
votes
0answers
43 views

Two LED Patterns Task Controlled by GUI

I am very new to Arduino and coding/programing. I set a task for myself to make a simple circuit of 5 LEDs controlled by pins 2, 4, 8, 11, 12. I want to be able to make two different pattern for the ...
2
votes
0answers
415 views

Reading JSON from Arduino over serial in python and writing to a JSON file on computer

I'm fairly new to Arduino so I used a sample code before integrating this into my main code. I'm printing my value in a JSON format over serial. My Arduino outputs this and the python receives this ...
2
votes
0answers
4k views

Run Servo when detect object on OpenCV Python

I want to connect OpenCV (Python) with arduino Uno when it detects a tennis ball. OpenCV code: import numpy as np import cv2 import serial face_cascade = cv2.CascadeClassifier('tennisballdetect.xml')...
2
votes
0answers
994 views

Robust communication between Xbee and Python

I am using Xbee API library for Python to process the data received by the Xbee module. I am wondering how to construct the robust protocol for sending and receiving data. What I would like to build ...
2
votes
1answer
1k views

Read/write data from 2 Arduinos simultaneously with Python

So for my project I have one Arduino Mega hooked up with a quadrature rotary encoder which is connected to the computer. An Arduino Uno is connected to a circuit I built, which in turn is connected to ...
1
vote
0answers
20 views

Pyfirmata util.Iterator causes serial communications issues with more than one Arduino

I'm using two Arduino Megas in a project to read data from a bunch of analog sensors and then output PWMs on digital pins according to their value. These analog signals are also being plotted on a ...
1
vote
0answers
39 views

communication between python and arduino

I have a python program that calculates an integer based on some parameters. I am not including the full code here because because it has a lot of deep learning stuff , but the relevant block is: #...
1
vote
1answer
44 views

Arduino , python , pyfirmata , standard firmata

Is there a way to change arduino analog reference to EXTERNAL IN PYTHON using pyfirmata or any other library ? Necessary Links : https://www.arduino.cc/reference/en/language/functions/analog-io/...
1
vote
0answers
31 views

Can you use python to control an RGB matrix with Arduino Mega?

I want to use python to control a RGB Matrix with an Arduino Mega, is it possible? How do I use Adafruit library with python? My plan is to create IOS app to control the matrix via Bluetooth.
1
vote
0answers
27 views

Computer freezes while collecting serial data from Arduino Uno

I am an arduino noob. I have been searching for some interesting arduino projects recently and making a game controller using Arduino UNO seemed interesting. So I hooked up two dual-axis joystick ...
1
vote
0answers
22 views

My servo wont follow my cam

So i am trying to make the servo follow my face which will end up my camera following my face But the servo isnt doing anything please look at this (Also im only using Horizontal because I would like ...
1
vote
0answers
37 views

Connect and detect multiple arduinos using firmata

i am trying to connect several arduinos to usb ports and have the abillity to define between them. i added Firmata.attach function on the arduino board. how do i call it from my python script? thank ...
1
vote
0answers
57 views

Arduino code equivalent for python code binascii.unhexlify command

I want to convert a hexadecimal string or an array of bytes to binary data. For example, if i have a string like '424D368403' my output should be like b'BM6\x84\x03' The python code binascii.unhexlify(...
1
vote
0answers
102 views

Change arduino output from input

I'm trying to change values such that the arduino uno outputs comes from what is input, with the code, int PinOutput = 11; int PinInput = A0; int inph; int inpl; int input; void setup() { // put ...
1
vote
1answer
247 views

Can not receive data from Python code

I want to send 4 float numbers from Python code to an Arduino; I was trying to send it via serial and I have some problems. here is my Python code: import time import serial import struct data = ...
1
vote
0answers
82 views

serial problem with python to arduino

when i execute the python script, the arduino response but the code between the if(Serial.available()) not responding. python script import time, serial arduino = serial.Serial('COM7', 9600) ...
1
vote
0answers
548 views

How to parse data most efficiently coming through mqtt with ESP8266

I am writing a program that is currently set up like so: Python script running on my computer. Raspberry pi is the broker for the mqtt data transmission An ESP8266 is programmed to listen to/...
1
vote
0answers
1k views

Data logging from ESP32 through UDP socket to PC

The idea is to send raw sensor data from ESP32 to PC through WIFI UDP socket and store it into CSV file using Python. As you can see from the code I am chopping 8 bytes of data into single bytes and ...
1
vote
0answers
45 views

Multiple arduino connections problem

I have 2 Arduino Mega 2560 connected via USB to my Ubuntu 18.04 machine. When I boot, one connects to /dev/ttyACM0 and the other connects to /dev/ttyACM1. Communication works perfectly. However, ...
1
vote
0answers
155 views

Sending a union from Arduino via serial communication and parsing it in python

I want to send a union from Arduino to a python script running on a pc, and I want to parse the received union. I have read lots of topics online but I am stuck on how to do it in the most efficient ...
1
vote
0answers
190 views

Arduino Sensor Values to Raspberry Pi using NRF24

Im trying to send temperature sensor data through NRF24L01 to Raspberry Pi and read it in Raspberry Pi using python. But the temperature sensor data comes to the Raspberry Pi as letters, which I found ...
1
vote
0answers
288 views

MPU6050 Acc and Gyro readings swapped

I have been trying to figure out this MPU6050 for a bit but the RAW readings are confusing me. It seems to me that the accelerometer readings and the gyro readings are getting swapped... and I don't ...
1
vote
0answers
105 views

Serial communication problem NodeMCU

this is my first post here. Before I ask you my problem, I'm sorry if I'm wrong to write but my English is bad. So, my problem is this: I'm developing a "client-server" system with serial ...
1
vote
0answers
1k views

Arduino Modbus - Rtu slave with Raspberry pi using MAX-485

I am trying to use Arduino as Modbus- RTU slave and Raspberry Pi as a Modbus master I have interfaced Max485 (RS485 to TTL converter) with Arduino and Rs485 to USB converter in Raspberry Pi, Initially,...
1
vote
0answers
100 views

How do I free up space on arduino Yun shield?

I recently bought arduino Yun shield, and I didnt had any external USB storage connected, I downloaded get-pip.py on Yun using wget and ran python get-pip.py which resulted in 5mb storage on yun now ...
1
vote
0answers
11k views

Send Newline / Carriage return with python

With the Serial Monitor I have the Newline option: How can I send the same using python? I tried: 30\r\n 30\r 30\n import serial ser = serial.Serial('COM3', 115200) while True: numIn = input(&...
0
votes
0answers
42 views

Read Arduino Serial from python for ulterasonic real time

I have a problem with Arduino serial and Python. I want to read data from my Arduino via Python and plot it out in real time but I'm getting delayed results. This is the code running on my Arduino: ...
0
votes
0answers
67 views

drifting serial readings

I have a python script that continuously reads the serial port for digital thermometer reading. After a period of time, the serial reading will drift by 10+ degrees in some cases. I let it run, I ...
0
votes
0answers
133 views

python spidev receive data from Arduino

I am trying to communicate between Arduino and raspberry pi over SPI. I am using spidev in python and sending data to Arduino using xfer2. But I do not have an idea of how to receive bytes from ...
0
votes
0answers
54 views

Ultrasonic sensors not working

The target of this is for the system to print "Done" when distance, measured by 2 ultrasonic sensor, is between 6-17 cm. This is my python code: import serial arduinoSerialData = serial....
0
votes
0answers
109 views

Control Servo motor via Python GUI (PyQt) component “QDial”

I want to control a servomotor via a Python Gui (PyQt) component "QDial". Hopefully the servomotor should rotate "simultaneously" with the Dial in GUI. Below is the related code: ...
0
votes
1answer
4k views

Serial communication between python and arduino

I am working on object tracking robot. I am using python and OpenCV to detect the object and send the proper data to the arduino that controls two servo motors. The data which should be sent to the ...
0
votes
0answers
637 views

Receive data on esp 01

I have um esp 01 on port 2 and 3 from my Arduino, I can send several characters, but I cannot to receive many characters, my code is this: #include <SoftwareSerial.h> //TX RX SoftwareSerial ...
0
votes
0answers
103 views

Arduino receiving values over serial, but not responding

Now this is gonna make me cry. Yesterday night, my python script was working perfectly fine, while sending values over serial comm to my Arduino UNO. I have added the 10 microFarad capacitor between ...
0
votes
0answers
628 views

Servo position initiaition using PySerial unexpected results

Hi I'm using Brian Wendt's code for setting up my Arduino Nano with 4 servos using PySerial which works perfectly. So my next step was to get a nice GUI with sliders to position the servos, again no ...
0
votes
0answers
183 views

i2C and lost connections with IO errors

Having issues troubleshooting IO errors using i2C . Running a Python script on a raspberry Pi as master talking to an Arduino slave. The problem is that when making any change in my code that results ...
0
votes
1answer
452 views

Process Sensor Data from Arduino Yun with Python

I'm currently working on a small project with my Arduino Yún. I want to process the sensor data in python and send them in a message queue. I need to use Python3. I cannot find a way to get the ...
0
votes
1answer
62 views

Unusual behaviour over serial communication

I am sending data over serial connection from a python script to my Arduino UNO. Now initially whenever I tried to send data to the arduino, it would reset. The fix was to put a 10 microFarad ...
0
votes
1answer
244 views

Sending to Arduino UNO multiple values from Python code

I'm starting to learn how to work with Arduino, particularly communication between a Python code running on a PC and an Arduino Uno. So I decided to start with what I thought to be a easy task. ...
-1
votes
1answer
31 views

Run servo when image is capture

I am trying to create a program when the camera capture the servo will rotate in 90 degrees continously, but my code will stop in print output 2 any idea to run the servo continously? Here's the Code ...
-1
votes
1answer
1k views

Advanced Line Follower robot

I know about line follower mainly the grid solving robots i know the basics actually. Actually they have to trace the path of the grid in an arena and then reach back to starting point in a shortest ...
-1
votes
1answer
4k views

pySerial and serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)

I'm having some trouble getting my arduino uno to communicate with a simple python script through pyserial. Lets start with my arduino sketch: void setup() { Serial.begin(9600); } byte i = 0; ...
-1
votes
1answer
647 views

Pyserial and Arduino

I am trying to send an integer value from Python to Arduino. The integer value is a position given by a webcam, which will determine how many turns a stepper motor moves. Arduino: #include <...