2022 Developer Survey is open! Take survey.

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
1 answer
56 views

Sending float values from Python to Arduino using Serial communication

I need to send an array of floating-point numbers from python to Arduino Mega. For that, I read many sources [this this this this this] this] and many more links for the same I referred. But unable to ...
user avatar
1 vote
1 answer
76 views

Pan and tilt bracket move to sound, control servo motors using microphone sound sensors

I'm trying to code the pan and tilt bracket to turn based on where I speak, I know how to move the servo motors, but I really need help with the sound sensing. This is the code I've got currently: #...
user avatar
0 votes
1 answer
33 views

Controlling Arduino through python

How to set the registers of Arduino through python code to vary the sampling rate of Arduino? Can we control Arduino through python?
user avatar
  • 21
1 vote
1 answer
54 views

`time.sleep` in python script reading serial output causes erratic behavior

I am attempting to control the position of my computer's cursor using a potentiometer hooked up to my arduino nano. The arduino is running the following code: int potPin = 3; // select the input ...
user avatar
3 votes
1 answer
177 views

get data from arduino using python

I am trying to read potential meter data from Arduino using python, with the program on Arduino as follows : #include <cvzone.h> SerialData serialData; int sendVals[2]; void setup() { ...
user avatar
1 vote
0 answers
61 views

I can get arduino code/board to show voltage using analog input but not python/board

I am trying to simply read a voltage from a battery. I am able to work out how to do this using arduino code on an arduino board. (UNO) When I try to do the same thing on a board using python the ...
user avatar
1 vote
0 answers
27 views

Serial communication between Python & Arduino: [duplicate]

I need to transfer information between pyton script and arduino. Data is always built like this "wheelbase:1000" wheelbase can be another word and 1000 can be another value, : is always the ...
user avatar
  • 113
1 vote
0 answers
145 views

esp8266 wifi/ read serial data with python

I'm trying to read some serial (ADC) data from my esp8266 nodeMCU v3 over wifi using python. I connected the esp on my local wifi and set it with fixed local IP using arduino IDE, but I couldn't find ...
user avatar
1 vote
1 answer
46 views

opencv reading the display and doesnot provide serial communication with arduino

I was creating a project where the following part of the code reads certain area of the display(which i screen shared from mobile) import cv2 as cv import numpy as np from PIL import ImageGrab import ...
user avatar
  • 13
1 vote
1 answer
45 views

Arduino randomly stops sending data to python over serial

I want to send commands to Arduino over USB Serial from my python program and Arduino should send back received command to make sure data wasn't lost. However Arduino randomly stops sending data back. ...
user avatar
  • 21
1 vote
1 answer
104 views

How do I control a servo with python through an Arduino

I'm trying to make it so I can control 2 servos with data that I get from a python script that tracks my face. I have found 2 libraries that do this:pySerial and pyfirmata. Is one superior to the ...
user avatar
1 vote
0 answers
98 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 ...
user avatar
1 vote
1 answer
138 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/...
user avatar
2 votes
0 answers
24 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 ...
user avatar
  • 21
0 votes
1 answer
31 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....
user avatar
  • 103
2 votes
1 answer
137 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 ...
user avatar
1 vote
1 answer
164 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(&...
user avatar
  • 61
0 votes
1 answer
356 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....
user avatar
0 votes
1 answer
176 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, ...
user avatar
1 vote
0 answers
70 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 ...
user avatar
-2 votes
1 answer
403 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 ...
user avatar
  • 19
-1 votes
2 answers
62 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....
user avatar
1 vote
1 answer
471 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 ...
user avatar
1 vote
1 answer
129 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 ...
user avatar
  • 21
0 votes
1 answer
57 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 ...
user avatar
  • 101
2 votes
0 answers
51 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 ...
user avatar
2 votes
0 answers
1k 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 ...
user avatar
  • 21
1 vote
0 answers
35 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 ...
user avatar
1 vote
0 answers
61 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 ...
user avatar
1 vote
0 answers
92 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(...
user avatar
1 vote
0 answers
125 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 ...
user avatar
1 vote
1 answer
268 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 ...
user avatar
  • 11
1 vote
1 answer
252 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 ...
user avatar
1 vote
1 answer
762 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 ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
0 votes
1 answer
336 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() ...
user avatar
0 votes
2 answers
62 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 ...
user avatar
1 vote
2 answers
188 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=...
user avatar
  • 39
1 vote
1 answer
407 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 = ...
user avatar
1 vote
0 answers
128 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) ...
user avatar
  • 11
-1 votes
1 answer
32 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 ...
user avatar
0 votes
2 answers
6k 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 ...
user avatar
0 votes
1 answer
2k views

Communication between Arduino and python: serial port sending empty data

Arduino code: this code is provided communication between sensor gy-521 and arduino. I read data by the command "1", after 1000 samples arduino is waited for new command for read data. Arduino code ...
user avatar
  • 9
0 votes
4 answers
69 views

How to link a computer processor to an Arduinno on a board? [closed]

I am completely new to Arduinno, so please forgive if the question is stupid. Here is the problem: I have a project where I want an Arduino (or similar microchip board) to handle some sensors and ...
user avatar
0 votes
1 answer
1k views

How to program Arduino LCD shield with Python?

so I want to run a Arduino LCD shield with Python code..But after having some research on the Internet, I can not found any tutorial, some just give some basic code with LED. And one things that how ...
user avatar
1 vote
0 answers
792 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/...
user avatar
0 votes
1 answer
2k views

find out the pin numbers for the Arduino IDE for a certain board - the esp 32

I followed the tutorial I found here https://techtutorialsx.com/2019/03/29/esp32-arduino-controlling-a-dc-motor/ On the very interesting topic controlling a DC motor with the esp32 and Arduino I have ...
user avatar
1 vote
0 answers
52 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, ...
user avatar
1 vote
1 answer
223 views

Arduino IDE display DEBUG PORT Serial1 output

How can I display / capture Arduino IDE's Serial1 output? Can I display it using Arduino IDE or using a script in Python? This python script (courtesy of Chad G) works for the Serial: #!/usr/bin/env ...
user avatar
  • 352
0 votes
2 answers
274 views

How Should I Send Data to My Laptop from Multiple Arduinos?

I'm working a project which involves reading multiple RFID tags, from multiple directions, at the same time. Because of the multiple directions, I need to use multiple antennae. Because of the ...
user avatar