Skip to main content
6 votes
Accepted

Arduino Serial Communication with Python: sending an array

If I use >BBB instead of >iii... That's because "B" is a byte. So you end up sending 3 bytes: struct.pack("BBB", 1, 2, 3) \x01\x02\x03 "i" is an int and has a size of 4, so you send 4*3 = 12 bytes: ...
001's user avatar
  • 963
5 votes
Accepted

What's the problem with baudrate?

On a direct USB CDC/ACM connection (as you get on the Micro) there is no such thing as baud rate. Any baud rate setting performed by the host (the PC) is merely an instruction to the device (the ...
Majenko's user avatar
  • 106k
4 votes

Which Arduino is the most suitable for my project?

Both Mega 2560 and Due can handle 4 channels of 1,440 samples per second A-to-D and the least significant byte of the system time stamp sent as a continuous stream of vectors through the USB port to ...
Douglas Daseeco's user avatar
4 votes

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

Unless you want to implement some form of scripting engine, you can't. Arduino code is compiled code, not interpreted code. There is no way of converting text into runnable code, since that is done by ...
Majenko's user avatar
  • 106k
4 votes

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

What you are trying to achieve is not easy. Expect to spend a lot of time developing, testing and tuning it. The first step would be to work the acoustics of your device. The sound sensors are not ...
Edgar Bonet's user avatar
  • 44.3k
4 votes
Accepted

How to ignore garbage values in serial communication between arduino and python

The effect that you see is type promotion, in the C++ standard called "integral promotion", which happens implicitly. Values of type char are cast to int. Commonly, and in your case too, the ...
the busybee's user avatar
  • 2,200
3 votes

Serial Comm. timing issue between Arduino and Pyserial

Your main problem is in erroneously having a delay in both the sender and the receiver. While this sometimes works by lucky accident, it essentially never does what is hoped for by those who try it. ...
Chris Stratton's user avatar
3 votes
Accepted

Python - Arduino communication not reliable

In case other people run into similar issues, I'll lay out what I've found today. -The inconsistent output was due to the fact that when you open a serial connection with python, it resets the ...
cpoole's user avatar
  • 51
3 votes
Accepted

serial.write if condition

You declare incomingchar as a char. In your if you compare that char to a string (double quotes) incomingchar=="g". I think you want to compare it to a char (single quotes) like this: if ( ...
Mazaryk's user avatar
  • 1,139
3 votes
Accepted

easy_install pip on Arduino Yun fails

Found this Arduino Forum Thread helpful. # wget \ https://pypi.python.org/packages/source/p/pip/pip-6.0.8.tar.gz#md5=2332e6f97e75ded3bddde0ced01dbda3\ --no-check-certificate # easy_install pip-6.0....
Shan-Desai's user avatar
3 votes
Accepted

Problem sending string with Python to Arduino through serial port

The AVR Arduinos (Uno, Nano, Mega) have auto-reset function. At opening of USB connection the circuit around USB resets the MCU. After reset the bootloader waits a second for a new upload. If the ...
Juraj's user avatar
  • 18.2k
3 votes

share enum between python and arduino

One approach that I have used for similar purposes is to generate the appropriate header files (or module or whatever) from a simple text file for all the required uses. Since you already know python ...
Mat's user avatar
  • 464
2 votes
Accepted

BLE Python with GUI on OSX

If you are still searching for a lib check out: https://github.com/adafruit/Adafruit_Python_BluefruitLE Its specifically made for BLE communication on OS X or Linux by wrapping the corebluetooth and ...
ArduStack's user avatar
2 votes
Accepted

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

In your test with the serial monitor you are putting spaces between each number. Using my logic analyzer I got this being sent from your Python code to the Arduino: No spaces, right? So the Arduino ...
Nick Gammon's user avatar
  • 38.7k
2 votes

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

Yes,its possible with the recent new ArduinoPro H7 which has abilities to upload a written programme in Python and JavaScript and its a dual core,32bit.
Boyd's user avatar
  • 21
2 votes
Accepted

Fastest way to read an array of numbers from python

If you don't know the length of the data then you need to be sending start and end markers so your other code can tell where the transmission starts and ends. I usually use < and >, so the data ...
Delta_G's user avatar
  • 3,390
2 votes

Cannot mount NodeMCU with MicroPython on Mac OS X

The typical NodeMCU board uses a fixed function CP-210x USB-Serial chip. This cannot appear to a host operating system as any ordinary sort of storage device, so it is not "mountable" via ...
Chris Stratton's user avatar
2 votes
Accepted

How to work with analog readings using RPi and Firmata?

It does not appear that Firmata has proceeded with the ability to change the analog reference source. You referenced one of the issues opened for it, but I don't see anywhere where it committed to the ...
jose can u c's user avatar
  • 6,974
2 votes

Run python in Windows OS installed in micro SD card which is read by Arduino microcontroller board

With some Arduino boards, yes. You want a board like the Yun (unfortunately retired now, but there are probably others similar) which has a MIPS SoC on it that runs Linux (specifically OpenWRT). The ...
Majenko's user avatar
  • 106k
2 votes

Arduino and Python

You can not run python on an UNO. If you want to use python on a microcontoller you should look into boards supported by MicroPython or Circuit Python
Craig's user avatar
  • 2,120
2 votes
Accepted

Arduino Python to Serial command

Majenkos comment (above) solved the problem: "You need to wait after opening the serial port for the board to finish resetting and the bootloader to run and exit before you can send any commands." ...
digit's user avatar
  • 193
2 votes

Running Python on Arduino

To my knowledge, there is not a "python to ATMega architecture" compiler out there. However, it's not true that MicroPython only runs on PyBoard. There are versions for installation also on the ...
jose can u c's user avatar
  • 6,974
2 votes

How to link a computer processor to an Arduinno on a board?

It sounds like you need a lot of compute power. You can either put the sensors and AI on one device (and @majenko's suggestion of a Raspberry Pi would be a direction to pursue) or you need two devices,...
JRobert's user avatar
  • 15.3k
2 votes

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

You're calling delay() in the onWsEvent() callback. The ESPAsyncWebServer documentation specifically says not to do that in the 'Important things to remember' section: You can not use yield or delay ...
romkey's user avatar
  • 1,553
2 votes
Accepted

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

but is there something about arduino that requires using latin-1? No, not really. What it comes down to is that Serial.read() reads bytes, irrespective of whatever encoding they may be being used ...
timemage's user avatar
  • 5,414
2 votes
Accepted

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

We cannot know, if your python code also has a problem. But your Arduino code will send the series of "V" only once. You are using this while loop: while(counter < maxnum) in there you ...
chrisl's user avatar
  • 16.5k
2 votes

Arduino randomly stops sending data to python over serial

I removed free(value) - rookie mistake - but that didn't completely solved the problem (but reduced frequency of occurrences). Seems like declaring array like char val[50] and passing it to function ...
Wisien's user avatar
  • 41
2 votes
Accepted

get data from arduino using python

I would embed the call to .getData() into a try block and handle this specific exception with except UnicodeDecodeError. There can always be a transmission error, especially when the script is started....
Sim Son's user avatar
  • 1,869
2 votes

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

Thanks to chrisl and timemage's comments, I figured out the issue: the Arduino was sending the data too fast and the bytes were piling up in the computer's inbound buffer. I solved this by adding a ...
Manav Bokinala's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible