3

I am integrating the MPU-6050 Accelerometer + Gyro sensor into a large project that contains 12 Arduino boards and 6 Raspberry Pis. At some point, I will have to load the output of my MPU-6050 sensor into another application through command line. The process is to be all done with Python and Bash (on the Raspberry Pi side), and so what I need is a way to store the output of my Arduino boards.

What I am currently looking at is the python program ino. I have used the product for about a year now, and as far as I am aware of, the only way to exit out of serial mode in ino is by closing the command-line window!

Is there a way I can achieve what I've discussed above? Essentially, all I want is a way to hold the output of my Arduino serial output so I can use it later in other parts of my project.

2
  • If I understand you correctly, you want to store the data recorded from an Arduino Uno through serial on a Raspberry Pi?
    – asheeshr
    Mar 5 '14 at 7:33
  • not necessarily the Pi, but in my case, yes Mar 5 '14 at 7:33
3

Well, I don't know about your ino program, but here's how I'd do it:

get_serial.py

import serial, sys

with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
    while ser.isOpen():
        print(ser.readline())

The idea, here, is to print on stdout the data coming on the serial line:

python get_serial.py /dev/ttyACM0 115200 > output.log

or you can do it this way:

get_serial.py

import serial, sys

with open(sys.argv[3]) as f:
    with serial.Serial(port=sys.argv[1], baudrate=sys.argv[2]) as ser:
        while ser.isOpen():
            f.write(ser.readline())

which is ran:

python get_serial.py /dev/ttyACM0 115200 output.log

Hope this helps!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.