summaryrefslogtreecommitdiff
path: root/md/writeup/rtlsdr_usage.md
blob: b6e0eedc6dc2b206049c8a99a33a0db4ba6b2d13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
title:Using RTLSDR
keywords:linux,rtlsdr,gqrx

# RTLSDR usage
## Setup rtlsdr


By rtlsdr usually call RTL2832U chip based tv-tunners which
can be used for not just receiving DVB-T frequencies but much more
and yes price is ~$10 it mean that anyone can just buy and try
without "loosing" money. None of examples below requires any modifications
or extra hardware to run.

As of 2022 the version r820t2 that is commonly available.


### Get sources


Main development repository is on http://sdr.osmocom.org/trac/wiki/rtl-sdr
on github you can find more repos with experimental 
features (https://github.com/keenerd/rtl-sdr).

Getting sources from git:
```
  git clone git://git.osmocom.org/rtl-sdr.git
```
I prefer using plain binaries without any kind of installation. Just
compile and use binary without any troubles.
Build:
```bash
  cmake .
  make
```
All binaries is in src dir.

Util | Desc 
--- | ---
_rtl_adsb_ | recieve plain ADSB plain packets 
_rtl_eeprom_ | read |   
_rtl_power_ | log power over frequency range  
_rtl_fm_ | demodulate signals 
_rtl_sdr_ | output raw rtlsdr data  
_rtl_tcp_ |  remote rtlsdr server 
_rtl_test_ |  test rtlsdr 

### Drivers


Linux kernel have some drivers for rtlsdr stick and DVB-T. When you will plug
rtlsdr then kernel probably will load DVB-T drivers and you will not able
to use you rtlsdr for sdr. Way yo fix is it add some drivers to black list and
next time when you will plug rtlsdr this drivers will not be loaded.

Check if rtlsdr related drivers is loaded:
```bash
  lsmod | grep rtl28
```
If there is some drivers then blacklist driver by creating file
in */etc/modprobe.d/* with content:
```
  blacklist dvb_usb_rtl28xxu
```
Next thing that could appear is permissions on rtlsdr usage when its plugged in.
To allow everyone to use create file in */etc/udev/rules.d/* with content:
```
  SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", \
  GROUP="adm", MODE="0666", SYMLINK+="rtl_sdr"
```

### Check if works

How to test if rtlsdr works? Run one of commands:
```
  rtl_test
```
I like to run rtl_adsb as you can see there that something is received and
you see that everything "works":
```
  rtl_adsb
```

There should be line by line showing up some "hex" lines. If some data is shown
then adsb data from plains is received.

## Collection of tools  


### rtl_fm, FM modulation

Get some sound transmitted from FM radio stations. 
Find local radio station and set frequency choose wide band FM modulation __-M wbfm__
set SDR sample rate to any supported, but more then 150kHz, for example __-s 200000__.
Resample SDR output to audio frequency __-r 48000__. Pipe output to any audio tool
here is example for aplay where sampling rate set to same resampled rate of SDR.
IQ format from rtlsdr is signed 16 bit little-endian __-f S16_LE__. 

```bash
  rtl_fm -f 96.3e6 -M wbfm -s 200000 -r 48000 - | aplay -r 48k -f S16_LE
```


### rtl_power, Spectrum diagram

Scan spectrum to find some activities on different frequencies.
Good link with all description is http://kmkeen.com/rtl-power/ . 
Main usage of rtl_power is :
```bash
  rtl_power -f 76M:108M:125k -i 1 fm_stations.csv
```
and then draw image :
```bash
  heatmap.py fm_stations.csv fm_stations.png
```

### rtl_adsb, ADS-B

ADS-B ( Automatic dependent surveillance broadcast ) in simple words airplane
geo location, speed, height and flight number broadcasting. You can receive
this data and see how many plains is around and sometimes flight number.

rtlsdr have default one rtl_adsb program but it shows only received data,
without any decoding. Here is dump1090 specifically for rtlsdr and nothing
more:

  https://github.com/antirez/dump1090

description howto install could be found also here

  http://www.satsignal.eu/raspberry-pi/dump1090.html

Using in interactive mode with height in meters:
```bash
  dump1090 --interactive --metric
```
Output:

```
  Hex    Flight   Altitude  Speed   Lat       Lon       Track  Messages Seen .  
  ------------------------------------------------------------------------------
  71be01          10052     1009    36.434    33.544    45    9         1 sec
  424913 SDM6329  10966     711     36.440    33.405    221   65        0 sec
```


### GQRX, FSK1200

Gqrx is graphical SDR software where you can scan across frequencies
and demodulate and listen FM broadcasts and HAM bands frequencies.
Easy way how to explore the available frequency range

  http://gqrx.dk/

It have built-in AFSK1200 demodulator or in simple words ham radio packets.
And you could try to see what people sending in text around the world.

### Multimon-ng

Support many digital transmission modes.

  https://github.com/EliasOenal/multimon-ng


### Waterfall 

Here is few waterfalls for rtlsdr

  https://github.com/roger-/pyrtlsdr

It have demo waterfall and also thats is python bindings to libsdr that
could used for fast prototyping

### rtl-entropy

  https://github.com/EliasOenal/multimon-ng

Project that make rtlsdr as entropy source, uses FIPS 140-2 standard to
verify that data is random enough to pass test.

### rtl_433

Generic ISM data receiver. Can use to track remote sensors, weather stations and many
other devices. 

  https://github.com/merbanan/rtl_433


```
rtl_433 
```


## Projects where rtlsdr used  

### WebSDR

WebSDR probably best site where you can go and click on some radio receiver 
and listen what happens in some particular country. WebSDR site contains
about 80 radio receivers around the world that can be accessed trough web
interface. 

  http://websdr.org/

If you want setup your own radio reliever read FAQ, prepare mail and send mail
after that you could receive p recompiled websdr software with is easy
to setup with rtlsdr stick.

## Problems 

### Sync errors

Once there was sync error when was trying to use rtl_test or rtl_adsb.
To fix that changes for better quality usb cable.

### More then 1 dongle

When you run you run usually more then 5 dongles you could get error saying
something about libusb error (-5) you need to decrease buffer as default one 
is (16 * 16384) and it should work

```bash
rtl_test -b [NEW_SIZE]
```

thx goes to libera.chat/##rtlsdr chan

## Links

1. [http://kmkeen.com/rtl-demod-guide/](http://kmkeen.com/rtl-demod-guide/)
2. http://kmkeen.com/rtl-power/
3. http://sdr.osmocom.org/trac/wiki/rtl-sdr
4. http://www.rtl-sdr.com/
5. https://github.com/antirez/dump1090
6. http://gqrx.dk
7. https://github.com/roger-/pyrtlsdr
8. https://github.com/EliasOenal/multimon-ng  
9. https://github.com/merbanan/rtl_433