38
SDR Sejuta Umat RTL-SDR (+Docker) Eueung Mulyana http://eueung.github.io/docker-stuff/rtl-sdr CodeLabs | Attribution-ShareAlike CC BY-SA 1 / 38

Rtl sdr software defined radio

Embed Size (px)

Citation preview

Page 1: Rtl sdr   software defined radio

SDR Sejuta Umat

RTL-SDR (+Docker)Eueung Mulyana

http://eueung.github.io/docker-stuff/rtl-sdrCodeLabs | Attribution-ShareAlike CC BY-SA

1 / 38

Page 2: Rtl sdr   software defined radio

Outline

Preparation

Google Radio Receiver

RTL-SDR with Docker

OpenWebRX

rtl_fm + Stream

rtl_fm_python

2 / 38

Page 3: Rtl sdr   software defined radio

Preparation

3 / 38

Page 4: Rtl sdr   software defined radio

$ flash -c config.yaml -d /dev/mmcblk0 hypriotos-rpi-v0.8.0.img

# config.yamlhostname: node1wifi: interfaces: wlan0: ssid: "lk8fm" password: "1234567890"

# ---$ sudo ./blacklist.sh $ less /etc/modprobe.d/rtlsdr-blacklist.conf

# blacklist.sh - manually blacklist#!/bin/bash

sudo echo -e "blacklist rtl2832\n\blacklist r820t\n\blacklist rtl2830\n\blacklist dvb_usb_rtl28xxu" > /etc/modprobe.d/rtlsdr-blacklist.conf

4 / 38

RPI

Page 5: Rtl sdr   software defined radio

$ apt-cache policy rtl-sdrrtl-sdr: Installed: 0.5.3-5 Candidate: 0.5.3-5 Version table: *** 0.5.3-5 500 500 http://kambing.ui.ac.id/ubuntu xenial/universe amd64 Packages 100 /var/lib/dpkg/status

$ sudo apt install rtl-sdr

# package$ cat /etc/modprobe.d/rtl-sdr-blacklist.conf # This system has librtlsdr0 installed in order to# use digital video broadcast receivers as generic# software defined radios.blacklist dvb_usb_rtl28xxublacklist e4000blacklist rtl2832

# manual$ cat /etc/modprobe.d/rtlsdr-blacklist.conf blacklist rtl2832blacklist r820tblacklist rtl2830blacklist dvb_usb_rtl28xxu

5 / 38

PC/LaptopTest - Setup

Page 6: Rtl sdr   software defined radio

$ rtl_test -hrtl_test, a benchmark tool for RTL2832 based DVB-T receivers

Usage: [-s samplerate (default: 2048000 Hz)] [-d device_index (default: 0)] [-t enable Elonics E4000 tuner benchmark] [-p[seconds] enable PPM error measurement (default: 10 seconds)] [-b output_block_size (default: 16 * 16384)] [-S force sync output (default: async)]

$ rtl_testFound 1 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEMFound Rafael Micro R820T tunerSupported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7[R82XX] PLL not locked!Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report ifsamples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...

6 / 38

PC/LaptopTest

Page 7: Rtl sdr   software defined radio

$ lsusbBus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet AdapterBus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ lsusbBus 001 Device 004: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-TBus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet AdapterBus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ rtl_test...

7 / 38

RPITest

Page 8: Rtl sdr   software defined radio

Local Receiver

Google Radio Receiverradioreceiver@github by @jtarrio

8 / 38

Page 9: Rtl sdr   software defined radio

9 / 38

RTL2832U820T2

Page 10: Rtl sdr   software defined radio

radioreceiver 

10 / 38

Page 11: Rtl sdr   software defined radio

radioreceiver 

11 / 38

Page 12: Rtl sdr   software defined radio

radioreceiver 

12 / 38

Page 13: Rtl sdr   software defined radio

Remote Receiver

RTL-SDR with Docker

13 / 38

Page 14: Rtl sdr   software defined radio

14 / 38

RTL2832U820T2

Page 15: Rtl sdr   software defined radio

$ docker run --rm -it --device=/dev/bus/usb sysrun/rpi-rtl-sdr-base:0.4 /bin/sh# which rtl_tcp# which rtl_fm# which rtl_test/usr/local/bin/rtl_test

# rtl_testFound 1 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEMFound Rafael Micro R820T tunerSupported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7[R82XX] PLL not locked!Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report ifsamples get lost. If you observe no further output, everything is fine....

15 / 38

Image bysysrun

Page 16: Rtl sdr   software defined radio

# Dockerfile-01FROM resin/rpi-raspbian:jessie-20160601

MAINTAINER EM

RUN apt-get update && \ apt-get install -y rtl-sdr && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*

WORKDIR /

$ docker build -f Dockerfile-01 --rm -t em-rtlsdr:jessie .

# Test$ docker run --rm -it --device=/dev/bus/usb em-rtlsdr:jessie /bin/sh

16 / 38

Build NewImage

Page 17: Rtl sdr   software defined radio

$ docker run --rm -it -p 5325:5325 --device=/dev/bus/usb sysrun/rpi-rtl-sdr-base:0.4 rtl_tcp

#or$ docker run --rm -it -p 5325:5325 --device=/dev/bus/usb em-rtlsdr:jessie rtl_tcp -a 0.0

17 / 38

Start Serverrtl_tcp

Page 18: Rtl sdr   software defined radio

Start rtl_tcp Client & Connect ...We're using SDR#

or any other rtl_tcp-compatible clients ...

18 / 38

Page 19: Rtl sdr   software defined radio

SDR# 

19 / 38

Page 20: Rtl sdr   software defined radio

Remote Receiver

OpenWebRX

20 / 38

Page 21: Rtl sdr   software defined radio

#Dockerfile-02FROM sysrun/rpi-rtl-sdr-base:0.4

MAINTAINER EM, Frederik Granna

RUN apt-get update && \ apt-get install -y libfftw3-dev apt-utils nmap python2.7 vim --no-install-recommends && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*

WORKDIR /tmp

RUN git clone https://github.com/simonyiszk/csdr.git && \ cd csdr && \ make && \ make install && \ cd / && \ rm -rf /tmp/csdr

WORKDIR /opt

RUN git clone https://github.com/simonyiszk/openwebrx.git

WORKDIR /opt/openwebrx

EXPOSE 8073 8888 4951

CMD python2.7 openwebrx.py

21 / 38

Dockerfile

Page 22: Rtl sdr   software defined radio

$ docker build -f Dockerfile-02 --rm -t rpi-openwebrx:v1 ....$ cd ~/openwebrx && git clone https://github.com/simonyiszk/openwebrx.git$ nano config_webrx.py# center_freq = 143980000# ppm = 9

$ docker run --rm -it -p 8073:8073 --device=/dev/bus/usb -v ~/openwebrx/openwebrx:/opt/openwebrx rpi-openwebrx:v1

22 / 38

Build & Run

Page 23: Rtl sdr   software defined radio

OpenWebRX 

23 / 38

Page 24: Rtl sdr   software defined radio

OpenWebRX 

24 / 38

Page 25: Rtl sdr   software defined radio

Remote Receiver

rtl_fm + Stream

25 / 38

Page 26: Rtl sdr   software defined radio

# Dockerfile-03FROM em-rtlsdr:jessie

MAINTAINER EM

RUN apt-get update && \ apt-get install -y sox socat libsox-fmt-mp3 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*

WORKDIR /work

# ---# start-03.sh#!/bin/sh

rtl_fm -M wbfm -f $1 | sox -traw -r24k -es -b16 -c1 -V1 - -tmp3 - | socat -u - TCP-LISTEN:

26 / 38

Dockerfile &Script

Page 27: Rtl sdr   software defined radio

$ docker build -f Dockerfile-03 --rm -t rpi-rtlfm:v1 ....

$ docker run --rm -ti -p 8080:8080 -v $(pwd):/work --device=/dev/bus/usb rpi-rtlfm:v1 /bin/sh start-

27 / 38

Build & Run

Page 28: Rtl sdr   software defined radio

# deps$ sudo apt install sox libsox-fmt-mp3

# receive & play$ netcat node1.local 8080 | play -t mp3 -

#

28 / 38

Client 1sox

Page 29: Rtl sdr   software defined radio

29 / 38

Client 2vlc

Page 30: Rtl sdr   software defined radio

Remote Receiver

rtl_fm_python

30 / 38

Page 31: Rtl sdr   software defined radio

# Dockerfile-04FROM resin/rpi-raspbian:jessie-20160601

MAINTAINER EM

RUN apt-get update && apt-get install -y \ python python-dev python-pip python-virtualenv \ rtl-sdr && \ build-essential git libusb-1.0-0.dev librtlsdr0 librtlsdr-dev vlc && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*

RUN pip install flask

WORKDIR /work

RUN git clone https://github.com/eueung/rtl_fm_python.git && \ cd rtl_fm_python && ./build.sh

RUN chmod +x /work/rtl_fm_python/web.sh

RUN sed -i 's/geteuid/getppid/' /usr/bin/vlc

WORKDIR /work/rtl_fm_python

CMD ["/bin/sh","web.sh"]

# ---# web.sh./rtl_fm_python_web.py -M wbfm -f 107.5M -p 9 - | cvlc --demux=rawaud --rawaud-channels=

31 / 38

Dockerfile

Page 32: Rtl sdr   software defined radio

$ docker build -f Dockerfile-04 --rm -t em-rtlfmpy:v1 .

$ docker run --rm -ti -p 10100:10100 -p 10101:10101 --device=/dev/bus/usb em-rtlfmpy:v1$ docker run --rm -ti -p 10100:10100 -p 10101:10101 --device=/dev/bus/usb em-rtlfmpy:v1 /bin/sh web.sh

32 / 38

Build & Run

Page 33: Rtl sdr   software defined radio

33 / 38

Page 34: Rtl sdr   software defined radio

34 / 38

Page 35: Rtl sdr   software defined radio

35 / 38

VLC Client

Page 36: Rtl sdr   software defined radio

Refs

36 / 38

Page 37: Rtl sdr   software defined radio

Refs1. Rtl_fm Guide: Updates for rtl_fm overhaul2. th0ma5w/rtl_fm_python: An API and web application to interact with a

running instance of RTL_FM3. google/radioreceiver: An application to listen to broadcast stereo FM and AM

radio from your Chrome browser or your ChromeBook computer using a $15USB digital TV tuner.

4. sdr.hu/openwebrx5. SDR#6. Sysrun.io | Magic Smoke And Software

37 / 38

Page 38: Rtl sdr   software defined radio

ENDEueung Mulyana

http://eueung.github.io/docker-stuff/rtl-sdrCodeLabs | Attribution-ShareAlike CC BY-SA

38 / 38