Go Down

Topic: Serial communication between Python and off-board Arduino (Read 1 time) previous topic - next topic



I'm working on a project that involves two Arduinos implemented off-board receiving serial data from a computer.

Currently I've got the project receiving the data from the MIDI output on my Firebox, which works great (inexplicably - didn't use an optoisolator and it doesn't like to receive MIDI data from any other devices).  What I'd like to do is use my Arduino board (ATmega-less) for its USB-Serial chip and communicate directly Python -> ATmegas.

I'm concerned that there's some sort of message mismatch, maybe bytes or something.

On the Arduino, this is what I'm doing:
Code: [Select]
byte incomingByte;
incomingByte = Serial.read();
if (Serial.available() > 0) {
    incomingByte = Serial.read();
    if (incomingByte== 176){
    else if ( (action==1)&&(controller==0) ){
    }else if ( (action==1)&&(controller!=0) ){
      writeLights(controller, value);

and this is what I was doing with Python:

Code: [Select]
ser = serial.Serial("/dev/tty.usbserial-A6008hrf", 31250)

def sendMidi(status, controller, value):

def main():
sendMidi(176, 37, 127)

Now I was hoping that I could just connect the Serial RX pin on the Arduino board (ATmega-less) to the Serial RX pin on my off-board Arduino.  This didn't work.  The board's Rx LED lit up, so it's receiving something... I'm just not entirely sure how to troubleshoot this.  I would love to know the actual bytes coming off the Arduino, but I don't have an LCD...


Why are you doing a Serial.read() before checking to see if there is any data to be read?


Err that'd be a typo.  It's not there in my real code.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131