Skip to content

Instantly share code, notes, and snippets.

@billautomata
Created April 19, 2015 19:53
Show Gist options
  • Save billautomata/9d2a836db89a70e992de to your computer and use it in GitHub Desktop.
Save billautomata/9d2a836db89a70e992de to your computer and use it in GitHub Desktop.
sdr sweeper
var rtlsdr = require('rtlsdr'); // require the module
var freq = 91495300 // local NPR fm (91.49mhz)
freq = 45495300 // random freq in Hz 45,495,300hz
rtlsdr.getDevices(function (err, devices) {
devices[0].open(function (err, device) {
device.setSampleRate(2048000);
device.setCenterFrequency(freq);
device.on("data", function (data) {
var diff = 0
for(var i = 0; i < data.length; i++){
diff += Math.abs(data.readUInt8(i) - 127)
}
var b = []
for(var i = 0; i < 32; i++){
b.push(data.readUInt8(i))
}
// output the average, the array, and the frequency on the same line
console.log((diff/data.length).toFixed(14), b.join(' '),freq)
// change frequency
freq+=100000
device.setCenterFrequency(freq)
});
device.start();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment