New feature in SDRNode build #20170213 : control external devices with Arduino

arduino-on-sdrplay

SDR receivers like the SDRPlay or the Airspy cover a very wide frequency range, and most of the time one single antenna is not suitable to cover the different spectrum portions. SDRNode offers a way to remotely receive the IQ radio stream but – when multiple antennas are needed – a way to switch from one antenna to another was missing.

Freshly released Build #20170213 comes with a solution for this: connect an external Arduino to your SDRNode and let it switch the relevant antenna based on the actual received frequency !

To enable this feature, you need to:

  • Write a code on the Arduino listening to serial frames sent by the SDRNode program. An example is available on our GitHub repository at https://github.com/Cloud-SDR/ArduinoSwitch
  • Decide what are your SDR devices that need to be monitored / processed by your Arduino
  • Activate the external messaging.

The scripting features of SDRNode will be used here. In the following we assume we want to switch antennas behind one of our SDRPlay receivers.

Open your sdrnode.js configuration script and look for the SDRplay section and update it as follows (line 6):

// generated code for SdrPlay_RSP2
         if( sourceDef.name == 'SdrPlay_RSP2') {
             var device = new RFSource( sourceDef.UID );
             var serial_number = device.getRxSerialNumber() ;
             if( serial_number == '160505A700') {
		 device.setDeviceName('SDRPlay');
                 device.setSampleRate( 1536000 ) ;
                 device.setCompressionType(0);
                 device.setLock(false);
                 device.setRxGain( 0,-50.0) ;
                 device.setRxGain( 1,0.0) ;

                 // Configure playstream

                 var rxstream = device.createStream( 128000, 'playstream' ) ;
                 rxstream.setCompressionType(3);
                 rxstream.setCloneable(true);
                 rxstream.setPublic(true);
                 // end of config for playstream

             }
         }

This setDeviceName(‘SDRPlay’) will inform the SDRnode core that this device has to be transmitted to external control using the alias ‘SDRplay’. Note that you can use the same alias for multiple devices if you want…

Then you need to activate the external control system and say:

  1. What is the COM port to be used,
  2. What is the relevant speed.

This is done with the ‘postboot.js‘ script :

if( SDRNode.startSDRMonitor( "7", 9600 ) ) {
	print('External device monitor registered on COM7 at 9600 bauds.');
}  

Line 1 of this example informs SDRNode server that an external device is waiting for data on COM7 and is running at 9600 Bauds. Note that we use in this post an Arduino but of course any device can be used. A PIC would also work…

From now, any action sent to SDR device will send a RS232 frame to the device. The protocol is pretty simple (look at the example on GitHub):

  1. your device must inform SDRnode it is ready to accept date. It must send a ! followed by a new line,
  2. SDRnode replies by <SDRNODE> followed by new line.
  3. Then each tune, gain change, start / stop action is sent to the device by single frames looking like:
    • <device_name>:<command>:<arg>\n
    • For example a tune on SDRPlay is  SDRPlay:f:14.203 to say SDR was retuned to 14.203 MHz
    • SDRPlay:on when device is turned on,
    • SDRPlay:off when device is turned off.

External device can test SDRNode is still alive by sending a “?\n” to receive the welcome message.

In future releases, other commands will be added offering external device capacity to request status for connected devices.

Stay tuned !