February 20, 2013

Connecting Arduino to MK802 running Lubuntu

I had an idea of combining a MK802 running Linux with an Arduino UNO to get some I/O pins controllable from the MK802. This post describes how to do serial communication over the USB cable with a terminal application and with Python.

Boot Lubuntu and login then connect the USB cable from the Arduino to the MK802 and open a LXTerminal and type:


It will print of lot of information but look at the end for lines similar to these:

[  217.500000] cdc_acm 3-1:1.0: ttyACM0: USB ACM device
[  217.510000] usbcore: registered new interface driver cdc_acm
[  217.510000] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

This means that you Arduino is mapped on the device name ttyACM0. To open a serial terminal to this device type:

screen /dev/ttyACM0

If screen is missing install it by typing:
sudo apt-get install screen

Below I have run screen with the example "Communication -> ASCII table" from the Arduino Software. I prepared the Arduino UNO with the code on a Windows computer before  I connected it to the MK802.

The serial communication can also be done with a Python script. Create a file named Arduino.py with the lines below it an run it with:
python Arduino.py

import serial
ser = serial.Serial('/dev/ttyACM0')
while 1:
  while ser.inWaiting() > 0:
    print ser.readline()
It should result in a something similar to the picture below.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.