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.

Filter by
Sorted by
Tagged with
1
vote
0answers
21 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
1answer
250 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
1answer
47 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
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
362 views

How to work with analog readings using RPi and Firmata?

For context: I'm working on a project where I need to use sensors to figure out the current state of the environment. This process is done using an Arduino UNO and a RPi. The easiest way that I found ...
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 ...
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.
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 ...
1
vote
1answer
52 views

How to use pyserial to write two separate message?

I'm using pyserial to communicate with my arduino. I set up the connection and everything works fine. Now I have these two writing commands: pyserial.write("conn".encode()) pyserial.write(&...
0
votes
0answers
43 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
1answer
28 views

How to receive commands to a running arduino program from a raspberry pi?

I have looked all over for a solution to this. I'm a noob in the arduino space and am really just getting my feet wet. It's possible that I am interpreting what I am reading wrongly. If so I apologize....
2
votes
1answer
60 views

What is the difference when an arduino has been unplugged vs when a serial port connection was closed?

Using python code for a serial port connection to an arduino, it sends a value to the arduino, which then starts printing values to serial. The python code will print the value on the first or second ...
0
votes
1answer
54 views

Why do I need to use latin-1 instead of utf-8 when using python with arduino?

When reading and writing with a python serial port connection to arduino, if I don't use latin-1 ('ISO-8859-1'), the results are not as expected. Like if I have int outP = 5; //... int outV = Serial....
0
votes
1answer
71 views

5V pin out, 8 pins and micropython/circuitpython support: does such a board exist?

For a project, I am looking for a board to connect eight different neopixel-strips to, on eight different data pins. Because of the great length between the board and the first pixels of these strips, ...
0
votes
0answers
69 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 ...
1
vote
0answers
28 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
55 views

How can I control my Arduino with my computer? [closed]

I have an eye scanner python program on my computer and I want to make a motor, that is connected to an Arduino, move if it gets a certain signal. How can I make my python program in Pycharm/visual ...
-2
votes
1answer
158 views

How to fix “expected primary-expression before '%' token” error code? [closed]

I'm trying to use this code to get temperature and humidity values from DHT11 sensor and send it to Python and I need to write the temperature and humidity values in the same line. But I keep getting ...
1
vote
0answers
27 views

Importing Arduino external data [closed]

I'm doing a project with my friends and I need to import some external data, which changes, to Arduino. I'm using python to use opencv, take photos and count the faces in that photo. And I need to use ...
1
vote
1answer
118 views

wdt reset cause:4, boot mode:(3,6)

I'm working on Python and nodeMCU with websocket connection. So, I send a string from Python to nodeMCU and nodeMCU collects the string and decodes to set values to a stepper motor. Initial code ...
-1
votes
2answers
49 views

How can I execute a string in my Arduino Uno board?

I was making a project with Arduino Uno , It's working is like this it connects to a key pad and a 7segment display ,and when you press a run button connected to Arduino it should run the code written....
1
vote
1answer
79 views

EEPROM programmer works with serial monitor but not with pySerial

I'm trying to modify Ben Eater's eeprom programmer to flash a 32K eeprom, since the arduino has 32K of program data total the data wouldn't fit in the program. So I wrote a python program using ...
1
vote
1answer
155 views

ESP8266 SocketIOclient constant disconnect with Python WebServerSocket

I am writing a program that echos back the message sent to the web socket server on a host machine. When running the ESP module, the connection is established but immediately disconnects as seen in ...
39
votes
10answers
168k views

Programming an Arduino using Python, rather than C/C++

I am not very skilled with the C Language and I was wondering if there is a way in which python could be used to program an Arduino. This would most likely require a different IDE in order to be able ...
0
votes
0answers
137 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 ...
12
votes
1answer
3k views

Update Dynamically Tkinter Widget Scale from Arduino Ports using python and firmata

I'm having trouble trying to get Arduino digital ports values and set these values into a Python Tkinter Widget Scale. I'm using Python and Arduino with Firmata. I'm able to access my arduino board ...
0
votes
1answer
36 views

share enum between python and arduino

I have created a gui in python that allows an arduino controlled mecanum wheel cart to move around. The cart allows for 8 different move directions and can rotate left and right. Commands are sent ...
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
426 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 ...
4
votes
5answers
53k views

Can't communicate with arduino using python (Windows)

I am new to programming and am trying to communicate with my arduino using python through serial communication. I am using the following code: Arduino code: int ledPin = 11; void setup() { Serial....
0
votes
1answer
165 views

Serial Read Data Loss With Arduino Nano

I am trying to use Serial reading from a python serial code (which is running on my Jetson Nano) in my project, but in some loop in my code, my data is receiving wrong. I use Serial.readBytesUntil() ...
0
votes
2answers
3k views

Send numbers to arduino via serial port using python

I have a file with numbers called fginputs.txt. For example it could be something like this: 4958 4154 4154 4154 4154 4154 4154 4154 4154 4154 4154 4154 4154 4154 4154 4154 4154 4958 I want python to ...
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
58 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
3answers
6k views

ESP8266 and Python Communication

I'm new to networking and working with ESP8266. I have successfully setup my ESP8266 and can program it from Arduino IDE (tested a blinky code). I want to send some data from a Python script running ...
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 ...
2
votes
2answers
2k views

Writing a float to a BLE characteristic. What data format?

I am currently working on a python-based Bluetooth Low Energy client for OS X and I got stuck while trying to write a remote float characteristic value. First of all: my setup is an Arduino 101 with ...
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....
1
vote
1answer
115 views

Best way to ask Arduino for data from Python?

I'm trying to send numerical data from inertial sensors from my Arduino to a Python script via serial (PySerial). I found that if I continuously send the data from the Arduino without stopping, the ...
1
vote
1answer
93 views

Code for 2 ultrasonic sensors

This is my code: int trigPin=13; //Sensor Trig pin connected to Arduino pin 13 int echoPin=11; //Sensor Echo pin connected to Arduino pin 11 float pingTime; //time for ping to travel from sensor to ...
0
votes
0answers
110 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: ...
1
vote
1answer
775 views

Flash firmware with hex file over serial with Python (no avrdude, Arduino IDE)

I'm trying to make a Python function in the TCLab package to flash firmware to an Arduino Leonardo (32u4). I can compile the TCLab ino (firmware) and deploy with the Arduino IDE or with the Python ...
1
vote
2answers
13k views

Send multiple int values from Python to Arduino using pySerial

I'm trying to send 3 ints in the range of 0-180 from Python to the Arduino Uno device using pySerial (py3K). I have managed to send 1 int by using python's struct lib (not sure if it's the best or ...
0
votes
1answer
1k views

Arduino Serial Monitor works but not on PySerial and PuTTY

I made simple custom arduino board using an atmega328p and the PL2303 serial to USB chip. In my arduino program, I am in a loop that sends out a string continuously. I can read this in the Arduino ...
2
votes
1answer
12k views

Handle reading timing in Python using pySerial

I'm not sure about how to properly handle timing readings from serial inside a Python script. I need to read a value every 5 seconds. From Arduino I could do, Serial.println(value); delay(5000); // ...
3
votes
1answer
15k views

Graph plotting on Python using Tkinter Canvas

I'm trying to plot a graph with python using the canvas widget, I'm currently sending data in from an arduino sensor sketch ..does anyone have an idea on how I can plot this graph in real time on ...
0
votes
2answers
4k views

Error 'exec: “python”: executable file not found in $PATH Error compiling for board AI Thinker ESP32-CAM.' in Arduino IDE 1.8.12

I am trying to upload a sketch to the ESP32-CAM board using Arduino IDE 1.8.12 and I get an error message: exec: "python": executable file not found in $PATH Error compiling for board AI Thinker ...
0
votes
2answers
55 views

Arduino sends bad data ONLY when not connected at the launch my application

I'm trying to write a little sensor reading application with a light sensor attached to an Arduino, which writes the information from the sensor over serial. I have written a python program to read ...
1
vote
2answers
155 views

Debugging different serial receive / send behavior between Uno & Mega

I have a simple text parser (as a component of a larger project) coded up and seemingly working correctly. It parses a key-value delimited command like the following: <key1=value1;key2=value2;key3=...