Code Monkey home page Code Monkey logo

rtl_map's Introduction

rtl_map

FFT-based visualizer for RTL-SDR devices. (RTL2832/DVB-T)

820t2

DVB-T dongles based on the Realtek RTL2832U can be used as a cheap SDR (Software-defined radio), since the chip allows transferring the raw I/Q (In-phase / Quadrature) samples to the host, which is officially used for DAB/DAB+/FM demodulation. (More about history & discovery of rtl-sdr)

There is various software for DSP (Digital signal processing), spectral analysis and signal intelligence using RTL-SDR such as SDR#, gqrx and gnuradio. Apart from these, there is librtlsdr which most of the user-level packages rely because of the reason that librtlsdr comes as a part of the rtl-sdr codebase. This codebase contains both the library itself and also a number of command line tools such as rtl_test, rtl_sdr, rtl_tcp, and rtl_fm for testing RTL2832 and performing basic data transfer functions. Therefore, librtlsdr is one of the major tools in RTL-SDR community.

Most of the technically questions RTL-SDR enthusiasts ask is about reading samples from device and processing raw I/Q samples. I wanted to answer that kind of questions and demonstrate a implementation of this with rtl_map project which is built on top of librtlsdr. Also, I went a step further and added graph feature that creates amplitude (dB) - frequency (MHz) graph using gnuplot and FFT (Fast Fourier transform) algorithm. (fftw used for this approach) I can list other useful open-source projects as #1, #2 and #3.

Another purpose of this project is making a testing tool & frequency scanner application for security researches.

https://www.rtl-sdr.com/rtl_map-a-simple-fft-visualizer-for-rtl-sdr/

Installation

Dependencies

  • libusb1.0 (development packages must be installed manually, see libusb.info)
  • gnuplot (must be installed manually, see installation page)
  • librtlsdr (cmake / automatic installation & linking)
  • fftw3 (cmake / automatic installation & linking)

Clone Repository

git clone https://github.com/orhun/rtl_map

Building with CMake (recommended)

cd rtl_map
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig

Building with GCC

gcc rtl_map.c -o rtl_map -lrtlsdr -lfftw3 -lm

Usage

Command Line Arguments

-d, set device index (default: 0)
-s, set sample rate (default: 2048000 Hz)
-f, center frequency (Hz) [mandatory argument]
-g gain (0 for auto) (default: ~1-3)
-n number of reads (default: int_max.)
-r, refresh rate for continuous read (default: 500ms)
-D, don't show gnuplot graph (default: show)
-C, continuously read samples (default: off)
-M, show magnitude graph (default graph: dB)
-O, disable offset tuning (default: on)
-T, turn off terminal log colors (default: on)
-h, show help message and exit
filename (a '-' dumps samples to stdout)

Example: Print samples to file

[k3@arch ~]$ rtl_map -f 88000000 -D capture.dat
[01:00:26] INFO Starting rtl_map ~
[01:00:26] INFO Found 1 device(s):
[01:00:26] INFO #0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
[01:00:27] INFO Using device: #0
[01:00:27] INFO Gain set to 14.
Supported 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 22.9 25.4 
128.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 
[01:00:27] INFO Center frequency set to 88000000 Hz.
[01:00:27] INFO Sampling at 2048000 S/s
[01:00:27] INFO Reading samples...
[01:00:27] INFO Done, exiting...

Example: Print samples to stdout

rtl_map -f 88000000 -D -

print samples to stdout

Example: Print 10x512 samples to stdout

rtl_map -f 88000000 -D -C -n 10 -

Example: Create FFT graph from samples

[k3@arch ~]$ rtl_map -f 88000000
[01:00:28] INFO Starting rtl_map ~
[01:00:28] INFO Found 1 device(s):
[01:00:28] INFO #0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
[01:00:28] INFO Using device: #0
[01:00:28] INFO Gain set to 14.
Supported 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 22.9 25.4 
28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 
[01:00:29] INFO Center frequency set to 88000000 Hz.
[01:00:29] INFO Sampling at 2048000 S/s
[01:00:29] INFO Creating FFT graph from samples using gnuplot...
[01:00:29] INFO Done, exiting...

fft graph

Example: Continuously read samples and create FFT graph

rtl_map -f 88000000 -C -r 100

continuously read

DC Offset & I/Q Imbalance

There is a common issue with cheap RTL-SDR receivers which is center frequency spike or central peak problem related to I/Q imbalance. This problem can be solved with a implementation of some algorithms. (For more details: #1, #2)

TODO(s)

  1. Implement I/Q correction
  2. Find the maximum value of samples, show it on graph with a different color. Might be useful for frequency scanner.
  3. Frequency scanner feature
  4. Check correctness of min/max point calculation.
  5. Check correctness of amplitude (dB) calculation.
  • 820T2 tuner used for testing. Other RTL-SDR devices must be tested.

Contribution

You can contribute to this project if you are a RTL-SDR enthusiast or researcher. Fork the repository and start coding. I hope some people on this planet will consider my TODO(s) and help me build the frequency scanner tool :)

License

GNU General Public License (v3)

Copyright

Copyright (c) 2019-2023, orhun

rtl_map's People

Contributors

orhun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtl_map's Issues

Compiling Error

This happens while running "make".

pi@raspberrypi:~/rtl_map/build $ cmake ../ -- Checking FFTW3... -- FFTW3 found! -- Checking RTL_SDR... -- RTL_SDR found! -- Configuring done -- Generating done -- Build files have been written to: /home/pi/rtl_map/build

pi@raspberrypi:~/rtl_map/build $ make [ 50%] Building C object CMakeFiles/rtl_map.dir/rtl_map.c.o /home/pi/rtl_map/rtl_map.c:53:15: error: initializer element is not constant _samp_rate = n_read * 4000, /*!< [ARG] Sample rate (optional) */ ^~~~~~ CMakeFiles/rtl_map.dir/build.make:62: recipe for target 'CMakeFiles/rtl_map.dir/rtl_map.c.o' failed make[2]: *** [CMakeFiles/rtl_map.dir/rtl_map.c.o] Error 1 CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/rtl_map.dir/all' failed make[1]: *** [CMakeFiles/rtl_map.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

Linux raspberrypi 4.14.90-v7+ #1183

all points y value undefined!

Hi,

compile and link works fine. No output, see:

rtl_map -f 109000000
[18:48:25] INFO Starting rtl_map ~
[18:48:25] INFO Found 1 device(s):
[18:48:25] INFO #0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
[18:48:25] INFO Using device: #0
[18:48:25] INFO Supported 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 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[18:48:25] INFO Gain set to 2.7
[18:48:25] INFO Center frequency set to 109000000 Hz.
[18:48:25] INFO Sampling at 2048000 S/s
Allocating 15 zero-copy buffers
[18:48:26] INFO Creating FFT graph from samples using gnuplot...
[18:48:26] INFO Done, exiting...
Warning: empty x range [-1.04858e+06:-1.04858e+06], adjusting to [-1.05906e+06:-1.03809e+06]

gnuplot> plot '-' smooth frequency with linespoints lt -1 notitle
^
line 513: all points y value undefined!

This is the capture.dat

cat capture.dat
1 21.548365
2 6.276362
3 9.542425
4 10.146918
5 10.979499
6 8.996703
7 9.978176
8 9.672492
9 10.635524
10 11.662192
11 9.064567
12 5.000000
13 10.322289
14 9.064567
15 9.956130
16 10.865932
17 9.130374
18 0.000000
19 10.993285
20 4.771213
21 8.010300
22 5.000000
23 6.989700
24 7.592570
25 6.276362
26 2.385606
27 3.494850
28 -inf
29 5.000000
30 5.395906
31 5.880456
32 6.989700
33 9.404068
34 8.854260
35 7.841009
36 7.456809
37 3.494850
38 5.880456
39 5.395906
40 6.276362
41 7.841009
42 6.393768
43 7.385606
44 6.505150
45 3.494850
46 3.890756
47 8.217263
48 4.515450
49 4.225490
50 5.395906
51 3.890756
52 2.385606
53 2.385606
54 2.385606
55 -inf
56 1.505150
57 3.010300
58 0.000000
59 2.385606
60 -inf
61 -inf
62 -inf
63 -inf
64 -inf
65 -inf
66 -inf
67 -inf
68 -inf
69 -inf
70 0.000000
71 -inf
72 -inf
73 0.000000
74 -inf
75 5.206964
76 3.890756
77 3.494850
78 6.276362
79 6.712113
80 -inf
81 3.494850
82 5.395906
83 -inf
84 4.225490
85 2.385606
86 7.898918
87 4.771213
88 7.156819
89 8.961958
90 7.156819
91 5.569717
92 7.781513
93 6.020600
94 11.215190
95 7.592570
96 5.395906
97 -inf
98 6.808640
99 8.450980
100 11.439009
101 5.395906
102 8.010300
103 11.682299
104 10.226615
105 9.595390
106 6.611096
107 10.021606
108 5.395906
109 8.406206
110 10.064186
111 4.515450
112 11.882885
113 8.313789
114 10.865932
115 12.235790
116 10.043000
117 11.505150
118 6.901056
119 -inf
120 10.894885
121 4.225490
122 8.116246
123 12.442754
124 10.894885
125 9.194245
126 5.569717
127 10.226615
128 13.251537
129 12.644584
130 13.360489
131 10.431799
132 5.880456
133 9.621396
134 11.416506
135 13.079750
136 8.854260
137 5.000000
138 11.864560
139 -inf
140 8.116246
141 12.799533
142 11.472331
143 13.764082
144 12.512136
145 10.085167
146 13.760242
147 6.611096
148 12.180813
149 10.635524
150 7.781513
151 12.505296
152 9.316614
153 12.334338
154 13.085002
155 14.672492
156 11.177642
157 8.854260
158 14.833055
159 12.041200
160 10.569716
161 3.890756
162 9.542425
163 11.827440
164 15.522435
165 10.667694
166 12.484648
167 10.431799
168 12.258932
169 14.191096
170 12.612221
171 10.536050
172 13.721465
173 8.890757
174 10.602870
175 0.000000
176 12.421499
177 10.806840
178 6.611096
179 14.395479
180 14.280622
181 11.989700
182 12.887459
183 14.561110
184 7.156819
185 10.635524
186 2.385606
187 10.937604
188 13.653912
189 6.989700
190 0.000000
191 8.116246
192 7.781513
193 10.322289
194 10.761441
195 11.692283
196 12.714128
197 4.515450
198 9.865640
199 13.993253
200 12.799533
201 13.464234
202 11.928031
203 9.346159
204 11.882885
205 11.537480
206 10.993285
207 11.721961
208 12.846869
209 11.370790
210 11.312256
211 14.756688
212 10.536050
213 10.064186
214 12.400035
215 13.031907
216 11.864560
217 13.069209
218 11.324089
219 10.467109
220 10.651669
221 8.313789
222 11.760913
223 12.007003
224 12.835132
225 13.266063
226 10.715075
227 9.432453
228 8.926649
229 8.313789
230 1.505150
231 6.808640
232 5.395906
233 9.097720
234 10.246090
235 9.542425
236 7.657394
237 10.265392
238 6.901056
239 12.982985
240 2.385606
241 10.894885
242 12.512136
243 11.494266
244 10.519018
245 11.631680
246 6.393768
247 10.146918
248 12.631697
249 11.494266
250 10.413927
251 10.651669
252 9.542425
253 11.416506
254 10.467109
255 9.746950
256 6.393768
257 21.548365
258 6.276362
259 9.542425
260 10.146918
261 10.979499
262 8.996703
263 9.978176
264 9.672492
265 10.635524
266 11.662192
267 9.064567
268 5.000000
269 10.322289
270 9.064567
271 9.956130
272 10.865932
273 9.130374
274 0.000000
275 10.993285
276 4.771213
277 8.010300
278 5.000000
279 6.989700
280 7.592570
281 6.276362
282 2.385606
283 3.494850
284 -inf
285 5.000000
286 5.395906
287 5.880456
288 6.989700
289 9.404068
290 8.854260
291 7.841009
292 7.456809
293 3.494850
294 5.880456
295 5.395906
296 6.276362
297 7.841009
298 6.393768
299 7.385606
300 6.505150
301 3.494850
302 3.890756
303 8.217263
304 4.515450
305 4.225490
306 5.395906
307 3.890756
308 2.385606
309 2.385606
310 2.385606
311 -inf
312 1.505150
313 3.010300
314 0.000000
315 2.385606
316 -inf
317 -inf
318 -inf
319 -inf
320 -inf
321 -inf
322 -inf
323 -inf
324 -inf
325 -inf
326 0.000000
327 -inf
328 -inf
329 0.000000
330 -inf
331 5.206964
332 3.890756
333 3.494850
334 6.276362
335 6.712113
336 -inf
337 3.494850
338 5.395906
339 -inf
340 4.225490
341 2.385606
342 7.898918
343 4.771213
344 7.156819
345 8.961958
346 7.156819
347 5.569717
348 7.781513
349 6.020600
350 11.215190
351 7.592570
352 5.395906
353 -inf
354 6.808640
355 8.450980
356 11.439009
357 5.395906
358 8.010300
359 11.682299
360 10.226615
361 9.595390
362 6.611096
363 10.021606
364 5.395906
365 8.406206
366 10.064186
367 4.515450
368 11.882885
369 8.313789
370 10.865932
371 12.235790
372 10.043000
373 11.505150
374 6.901056
375 -inf
376 10.894885
377 4.225490
378 8.116246
379 12.442754
380 10.894885
381 9.194245
382 5.569717
383 10.226615
384 13.251537
385 12.644584
386 13.360489
387 10.431799
388 5.880456
389 9.621396
390 11.416506
391 13.079750
392 8.854260
393 5.000000
394 11.864560
395 -inf
396 8.116246
397 12.799533
398 11.472331
399 13.764082
400 12.512136
401 10.085167
402 13.760242
403 6.611096
404 12.180813
405 10.635524
406 7.781513
407 12.505296
408 9.316614
409 12.334338
410 13.085002
411 14.672492
412 11.177642
413 8.854260
414 14.833055
415 12.041200
416 10.569716
417 3.890756
418 9.542425
419 11.827440
420 15.522435
421 10.667694
422 12.484648
423 10.431799
424 12.258932
425 14.191096
426 12.612221
427 10.536050
428 13.721465
429 8.890757
430 10.602870
431 0.000000
432 12.421499
433 10.806840
434 6.611096
435 14.395479
436 14.280622
437 11.989700
438 12.887459
439 14.561110
440 7.156819
441 10.635524
442 2.385606
443 10.937604
444 13.653912
445 6.989700
446 0.000000
447 8.116246
448 7.781513
449 10.322289
450 10.761441
451 11.692283
452 12.714128
453 4.515450
454 9.865640
455 13.993253
456 12.799533
457 13.464234
458 11.928031
459 9.346159
460 11.882885
461 11.537480
462 10.993285
463 11.721961
464 12.846869
465 11.370790
466 11.312256
467 14.756688
468 10.536050
469 10.064186
470 12.400035
471 13.031907
472 11.864560
473 13.069209
474 11.324089
475 10.467109
476 10.651669
477 8.313789
478 11.760913
479 12.007003
480 12.835132
481 13.266063
482 10.715075
483 9.432453
484 8.926649
485 8.313789
486 1.505150
487 6.808640
488 5.395906
489 9.097720
490 10.246090
491 9.542425
492 7.657394
493 10.265392
494 6.901056
495 12.982985
496 2.385606
497 10.894885
498 12.512136
499 11.494266
500 10.519018
501 11.631680
502 6.393768
503 10.146918
504 12.631697
505 11.494266
506 10.413927
507 10.651669
508 9.542425
509 11.416506
510 10.467109
511 9.746950
512 6.393768

khz in README.md

Hi,

in the Readme.md file are the x label from the graph is khz.

It is Mhz!?

Possible More Powerful Dependencies

Hey, your work looks similar to some things I am trying to do in C++. I appreciate the clear simple environment with references to learn. I think it's important that signal intelligence research be accessible to people who only have a cheap radio like an rtl-sdr.

I wanted to share some libraries with you. I'm using https://github.com/pothosware/SoapySDR to access the radio, rather than librtlsdr directly. This allows other radios to be used with the same code. I've found the maintainer of SoapySDR to be more available to merge fixes and improvements in than the osmosdr folks.

I've also been using https://root.cern.ch/ to draw graphs and manage data. ROOT is unfortunately C++ rather than C. This software package has some very powerful tools for working with data in C++, including three dimensional charts, multi-dimensional histograms, flexible storage formats, and a runtime C++ interpreter that can work with user-developed primitives. I expect this interpreter to aid greatly in prototyping algorithms.

There are also frameworks such as gnuradio and https://github.com/pothosware/PothosCore/wiki . If components of applications are made as blocks for one of these frameworks, there is a UI that can be used to plug them together for further prototyping possibilities.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.