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
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 ...
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 ...
9
votes
2answers
32k views

How to send numbers to Arduino UNO via Python 3 and the module serial

I am new to Arduino (and computer programming in general), so I apologize if this question looks silly. Once I set up a basic arduino-LED connection, I have problems sending INTEGERS to arduino ...
5
votes
2answers
6k views

Arduino serial port reset in Serial monitor & Python

So am I using an Arduino with a shield to gain some voltage values for an ECG. I am then plotting that data in Python. However whenever I "observe" the serial port, be that through the Arduino serial ...
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....
4
votes
1answer
3k views

Problem sending string with Python to Arduino through serial port

I want to send string 50 to Arduino through serial port, the Arduino UNO seems it communicates with port COM25 but it doesnt receive the string properly: import serial # if you have not already done ...
3
votes
4answers
208 views

Which Arduino is the most suitable for my project?

I've started to prototype something using an Arduino Mega and Yún Shield. It's simple. It reads an ADC at 50Hz and sends data to a server through a socket. But because of that combination, I need to ...
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 ...
2
votes
2answers
12k views

Arduino Serial Communication with Python: sending an array

I am a bit new to both Arduino and Python. My aim is to send commands to Arduino to run a stepper motor. I need to send an array containing the parameters. After consulting many earlier posts like: ...
2
votes
1answer
910 views

What's the problem with baudrate?

I was trying to evaluate the speed of communication between pc and Arduino, using this code in Arduino: void setup() { Serial.begin(9600); } void loop() { Serial.println("Ciao Arduino"); } and ...
2
votes
3answers
5k views

Serial Comm. timing issue between Arduino and Pyserial

This is my first post to Stack Exchange so please forgive any formatting errors. I am conducting an experiment that has 7 total sensors: 5 thermocouples, 2 humidity sensors and 1 pressure sensor. I ...
2
votes
3answers
7k views

Receiving two-byte int values over serial

I am using Python smbus write_word_data method to send int values from a Raspberry Pi to an Arduino using I²C. This seems to be the correct method. When I send values from 0-255, I see the following ...
2
votes
1answer
921 views

How can I use Python from a sketch?

I'd like to be able to use Python from a sketch. According to the Arduino playground, one can use PySerial from a computer to talk with an Arduino via Python. It looks like from that page you can ...
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 ...
2
votes
2answers
4k views

Python - Arduino communication not reliable

I'm trying to establish basic communication between python and my arduino due. I have managed to get a message sent to the arduino and sent back, but the code that achieves this task does not give ...
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); // ...
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 ...
2
votes
1answer
244 views

Why is communication between a Python program and Arduino not producing the expected result?

I have written some Arduino code (with help from the post Serial Input Basics). On serial I send some data and, based on certain values sent, certain LEDs will be lit. Here is the Arduino code: const ...
2
votes
3answers
1k views

Share data between the two processors of the Arduino Yun

The linux processor runs a Python script from which I would like to send an array of integers to the Yun microprocessor. How can I do that? And then, how can I retrieve and then use this array in my ...
2
votes
1answer
895 views

How to connect an Elegoo Nano to a Raspberry Pi and program it?

I own an several Elegoo Nanos and a Raspberry Pi. I would like to connect an Elegoo Nano to the Pi and upload nanpy onto the board and control it's GPIO pins. I have plugged the nano into the Pi and ...
2
votes
1answer
854 views

Controlling I2C slave on Arduino with Python

Typically, when I connect my Arduino to a slave device through I2C or SPI, I'll control the slave using instructions coded in the firmware. The output data will be then printed to the Serial port and ...
2
votes
2answers
2k views

Bidirectional communication between Arduino and Raspberry Pi over USB possible?

Is it possible to have bidirectional communication betweeen an Arduino Uno Rev 3 and a Raspberry Pi Modell B+ running Rasbian? They're connected ofer USB, and it would be good if I could use Python on ...
2
votes
2answers
7k views

How to read data from Arduino with Raspberry Pi via I2C?

I have connected a Raspberry Pi 2 model B to an Arduino Uno via Bi-Directional Level shifter, from this BLOG: Raspberry pi GND ---------- GND Arduino 3.3v ---------- ...
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
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 ...
2
votes
1answer
75 views

The arduino can't seem to output correctly

i am a beginner at python and I am average at Arduino and I had the idea of using both of them together for a project. I have been trying to make a Arduino + Python car which I can control with my ...
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
1answer
2k views

How to make data sent by Python (via serial connection) wait for Arduino to finish current task? [closed]

I am trying to make my Arduino micro-controller and my Mac talk together, and I have created a functional serial connection. My computer is sending data to my Arduino, and my Arduino is sending a 1 ...
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
3answers
9k views

Why does serial port stop sending data?

I'm using an Arduino Leonardo to interface with two pressure sensors and Python on my laptop, a MackBook Pro. I'm using arduino IDE V. 1.5.4, Python V. 2.7.6, and OSX 10.8.5. One pressure sensor is ...
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
1answer
1k views

Unpacking Arduino binary data on a python sketch

As a follow up to my earlier post: Simultaneously reading data from multiple serial ports, I am stuck trying to develop a python sketch that can read the incoming serial data from the com port on my ...
1
vote
3answers
13k views

Plotting a real time graph of sensor data from Arduino on Processing, MatLab or Python

I have an accelerometer connected to my Arduino Due to spit out data on my serial monitor as described in my earlier post. I'm trying to find a sketch I could use to plot a continuous real-time graph ...
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
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 ...
1
vote
1answer
647 views

Running Python on Arduino

I've been using Python for quite long, and I was wondering if it can be used as a programming language for Arduino, rather than C/C++. When I'm using the Arduino IDE, the sketch is compiled into a ...
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 ...
1
vote
2answers
954 views

Communication with socketserver fails after specific number of packets

I'm trying to implement a full-duplex communication between my ESP8266 and a socketserver running on my laptop. In concrete I need each of the devices to initiate communication whenever it needs to. ...
1
vote
2answers
4k views

Arduino-Pyserial communication on Python 3, Windows machine: Pyserial.write() doesn't seem to do anything

I've recently gotten my hands on an Arduino (or rather a Genuino, but the overall architecture should be the same) UNO. I'm now using that Arduino to test how data is transmitted from a USB to Serial ...
1
vote
1answer
1k views

Serial available doesn't work right after upload

I have 2 programs to test serial communication, an simple arduino program that echoes whatever is on the serial port and a python program that writes to the serial port and prints the reply. I'm ...
1
vote
2answers
862 views

Getting Firmata to control WS2801 LEDs

I am trying to control a strip of WS2801 LEDs through an arduino uno running firmata from Python on my laptop. I've written some basic code based on adafruit's library here (from line 187): from ...
1
vote
1answer
1k views

BLE Python with GUI on OSX [closed]

Has anyone connected BLE devices with Python + GUI on OSX? I've looked into a few libraries (most are old), but one that has the most success if Adafruit's BlueFruit library. However, this library ...
1
vote
2answers
1k views

Python script to toggle LED's

I have 8 LED's connected to a shift register on my arduino uno r3. I am trying to write a Python3 script that will prompt a user to select one of the LED's and then prompt to toggle on or off. Should ...
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 ...
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(&...
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 ...
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
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 ...