Coder Social home page Coder Social logo

rtlsdrjs's Introduction

πŸ“‘ rtlsdr.js

Turn your Realtek RTL2832U based device into an SDR (Software Defined Radio) receiver using JavaScript.

Supports Node.js and WebUSB compatible browsers.

Requirements

Hardware

  • Realtek RTL2832U based USB adapter with R820T tuner chip

Software

Setup

Node.js

Install: npm i rtlsdrjs

Require: const RtlSdr = require('rtlsdrjs');

Browser

Download a rtlsdr.js build from a release.

Include rtlsdr.js in you HTML page: <script src="path/of/rtlsdr.js"></script>

Usage

let readSamples = true;

async function start() {
  //
  // request a device
  // - displays prompt in browser
  // - selects first device in Node.js
  //
  // RtlSdr.getDevices() can be used to get a list of all RTL SDR's attached to system
  //
  const sdr = await RtlSdr.requestDevice();

  //
  // open the device
  //
  // supported options are:
  // - ppm: frequency correction factor, in parts per million (defaults to 0)
  // - gain: optional gain in dB, auto gain is used if not specified
  //
  await sdr.open({
    ppm: 0.5
  });

  //
  // set sample rate and center frequency in Hz
  // - returns the actual values set
  //
  const actualSampleRate = await sdr.setSampleRate(2000000);
  const actualCenterFrequency = await sdr.setCenterFrequency(1090000000);

  //
  // reset the buffer
  //
  await sdr.resetBuffer();

  while (readSamples) {
    //
    // read some samples
    // - returns an ArrayBuffer with the specified number of samples,
    //   data is interleaved in IQ format
    //
    const samples = await sdr.readSamples(16 * 16384);

    //
    // process the samples ...
    //
  }
}

Acknowledgements

This library is based on Jacobo TarrΓ­o's (@jtarrio) work in Google's Radio Receiver Chrome app, which used work from the RTL-SDR project. The Chrome USB API layer has been replaced with node-usb on Node.js and WebUSB when running in the browser.

License

Apache 2.0

rtlsdrjs's People

Contributors

jtarrio avatar sandeepmistry 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

Watchers

 avatar  avatar  avatar  avatar

rtlsdrjs's Issues

(Dumb) question

First of all, thank you for such an awesome library!

i have a question that's probably dumb, since i'm just dipping my feet to SDR world here. I ask it anyway.

I'm wondering what the data actually is that's coming out? Is it for only single frequency, or maybe frequency range somehow?

I would like to create sort of a scanner to show which frequencies have data. How could i do that? I mean from the current data how can i know which frequency range is it, to be able to compose wide spectrum of frequencies?

Documentation for front end

The current documentation doesn't give a good method to load the library.

I have tried a few methods, but here is the current use case I am unable to get working... I am trying to serve up the library from an isolated virtual machine and let the client alone load the RTL-SDR device. In other words, the dongle is NOT connected to the system running nodejs.

Error on the client:

Uncaught ReferenceError: require is not defined
    at browser.js:1

express application loader

const RtlSdr = require('rtlsdrjs');
const express = require('express')
const app = express()
const port = 9943

/* The folder structure
public/
 |_ rtlsdjs/
 |      |_ lib/
 |_____ browser.js
 |_ index.html
 */
app.use(express.static('public'))

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

The web content...

<script src="rtlsdrjs/browser.js"></script>
<script>
let readSamples = true;

async function start() {
  //
  // request a device
  // - displays prompt in browser
  // - selects first device in Node.js
  //
  // RtlSdr.getDevices() can be used to get a list of all RTL SDR's attached to system
  //
  const sdr = await RtlSdr.requestDevice();

  //
  // open the device
  //
  // supported options are:
  // - ppm: frequency correction factor, in parts per million (defaults to 0)
  // - gain: optional gain in dB, auto gain is used if not specified
  //
  await sdr.open({
    ppm: 0.5
  });

  //
  // set sample rate and center frequency in Hz
  // - returns the actual values set
  //
  const actualSampleRate = await sdr.setSampleRate(2000000);
  const actualCenterFrequency = await sdr.setCenterFrequency(1090000000);

  //
  // reset the buffer
  //
  await sdr.resetBuffer();

  while (readSamples) {
    //
    // read some samples
    // - returns an ArrayBuffer with the specified number of samples,
    //   data is interleaved in IQ format
    //
    const samples = await sdr.readSamples(16 * 16384);

    //
    // process the samples ...
    //
  }
}
</script>

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.