Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

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:

dmesg

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.

July 29, 2012

RTL-SDR on MK802


I wanted to see if it was possible to build a small and low cost embedded receiver with an ARM based Linux computer and a USB DVB-T tuner. The idea was to capture the signal and do some simple processing and monitoring. For the computer part a decided to go for the Rikomagic MK802 since it had a fairly fast CPU at 1 GHz and low price. I got some of my inspiration from this article:

 
MK802 runs Android on an internal flash but can also boot Linux from an microSDHC card. All my experiment where done under Linux. To find Linux images and installation guides go here: https://www.miniand.com
I used the image: Lubuntu 12.04

After preparing the Linux image and having a running system I needed to add development packages for C++ like build-essential, cmake, libusb-1.0.0-dev...

I used the graphical tool Software Center to add packages. To install it run the commands:

sudo apt-get update
sudo apt-get install software-center

(The default password is: miniand)

Building RTL-SDR

The build steps a described here:

I built it with cmake since the autotools gave me problems with libusb for some reason. After a successful build i ran the program rtl_test. It gave some promising results. Note that to access the device I needed to run it as root. I was able to run at 2.048 MSPS.

miniand@miniand:~$ sudo rtl_test -s 2048000 -t

Found 1 device(s):
0: Generic RTL2832U (e.g. hama nano)

Using device 0: Generic RTL2832U (e.g. hama nano)

Found Elonics E4000 tuner

Supported gain values (18): -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 43.0 45.0 47.0 49.0

Benchmarking E4000 PLL...

[E4K] PLL not locked for 51000000 Hz!
[E4K] PLL not locked for 2186000000 Hz!
[E4K] PLL not locked for 1093000000 Hz!
[E4K] PLL not locked for 1258000000 Hz!

E4K range: 52 to 2185 MHz

E4K L-band gap: 1093 to 1258 MHz

For a more substantial test i decide to try to receive a narrow band FM signal. There is a simple FM receiver included in the build. The command to use is:

sudo rtl_fm -f 155.5e6 -s 12000 -g -1.0 -l 150 - |play -t raw -r 12k -e signed-integer -b 16 -c 1 -V1 -
I transmitted with a Puxing PX777 at 155.5 MHz (that is a license free frequency in Sweden). I was able to hear the transmission. The audio was some what distorted but I was able to hear it. I decided to go to the next step by installing the python wrapper (some more software packages was also needed). It can be found here:

There are a few examples provided. I did successful runs of demo_waterfall.py and test.py (after some hacking in the scripts to get the settings right for frequency and sample rate). See the screen shots below.

To be continued...

I got the hardware from ebay.

MK802 ebay seller: http://stores.ebay.com/tomtopdigitalshop
Item name: "Mini Google Android 4.0 TV Box HD Player WIFI PC Allwinner A10 MK802 1GB White"

DVB-T USB TV dongle from ebay seller:http://stores.ebay.com/runteck88
Item name: "White USB DVB-T RTL2832U + E4000 for Windowns XP/ Vista/ Seven PC SDR GPS P335"