OSWIN Gateway with RFM12B, SRF and OOK Support

OSWIN with RFM12B, XRF and OOK receiver.
OSWIN with RFM12B, XRF and OOK receiver.

So after getting an SRF based TinyTX and an OOK based one running I thought I should update the gateway code for my OSWIN gateway to support both types of sensors as well as the RFM12B.

To receive the SRF node I’m using a Ciseco XRF in the Xbee socket and the OOK receiver is plugged in across four of the analogue pins (only 3 are used).

The updated code is available on Github here, there are some defines near the top to enable or disable which type of radios are to be used and a few settings to configure which pins the OOK radio is connected to. ACKs and the NTP time transmit function are only supported with the RFM12B for now but I may add them to the SRF/XRF combo later.

This shows the serial debug mode showing the three different types of nodes coming in, an RFM12B based node, an OOK node and an SRF node.

Data received from RFM12B Node 2
-> ack sent
Connecting to server
Sending to emoncms: {rf_fail:0,node2_data1:2431,node2_data2:28393,node2_v:2987}
Sent OK
Disconnected
Data received from OOK Node 90
Connecting to server
Sending to emoncms: {rf_fail:0,node90_data1:2600,node90_v:2956}
Sent OK
Disconnected
Data received from SRF/XRF Node 99
Connecting to server
Sending to emoncms: {rf_fail:0,node99_data1:0,node99_v:2948}
Sent OK
Disconnected

The XRF is on the second hardware UART (Serial1) so I’m using the hardware version of the EasyTransfer library as opposed to the software version used on the SRF sensor node.

The Manchester encoding library that I used for the OOK receiver didn’t have any settings for a device running at 12MHz so I had to add the elif clause highlighted in blue below to the Manchester.cpp file as follows:

  Timer 2 is used with a ATMega328.
  http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf page 162
  How to find the correct value: (OCRxA +1) = F_CPU / prescaler / 15625 / 4
  */

  TCCR2A = _BV(WGM21); // reset counter on match
  #if F_CPU == 1000000UL
    TCCR2B = _BV(CS21); // 1/8 prescaler
    OCR2A = (32 >> speedFactor) - 1; // interrupt every 32 counts for base speed
  #elif F_CPU == 8000000UL
    TCCR2B = _BV(CS22); // 1/64 prescaler
    OCR2A = (32 >> speedFactor) - 1; // interrupt every 32 counts for base speed
// Added for 12MHz OSWIN support
  #elif F_CPU == 12000000UL
    TCCR2B = _BV(CS22); // 1/64 prescaler
    OCR2A = (48 >> speedFactor) - 1; // interrupt every 48 counts for base speed
// End addition for 12MHz OSWIN support
  #elif F_CPU == 16000000UL
    TCCR2B = _BV(CS22) | _BV(CS20); // 1/128 prescaler
    OCR2A = (32 >> speedFactor) - 1; // interrupt every 32 counts for base speed
  #else
  #error "Manchester library only supports 8mhz, 16mhz on ATMega328"
  #endif  
  TIMSK2 = _BV(OCIE2A); // Turn on interrupt
  TCNT2 = 0; // Set counter to 0
#endif

I know it says ATMega328 there but all the registers used are the same for the ATmega1284P and the 328 is the default processor option in the Manchester library so only that elif is required to correct the speed for OSWIN running at 12MHz.

So that’s it all three radios happily running on the same device. nRF24L01 next then?

 

3 thoughts on “OSWIN Gateway with RFM12B, SRF and OOK Support

  1. Just want to confirm – do the OOK and RFM12B modules not interfere with each other or pick up each others incoming data?

  2. They won’t pick up each others data as they are using different transmission methods (FSK/ASK) and protocols. There may be some clashes/interference between multiple sensors but this would be no more of a problem than it would be between sensors of the same type.

    To deal with clashes/interference with the RFM12B sensors I use ACKs so the sensor knows if its transmission was received by the base station and if not it resends it. You can’t do this with the OOK modules as they are basic transmitter and receivers not transceivers.

  3. Hi Nathan,

    very nice blog here. I’m working on a gateway services solution between Raspb. PI and some sensors based on attiny and arduino mini pro.
    I ask myself:
    What is the differnce between SRF and RFM12B? It looks like that the same data structure is used in their package structures and only the libs for arduino (jeelib fpr rfm12B and Arduino-EasyTransfer fpr SRF) are different…. or better say: jeelib is much much better in many ways.

    Therefore my question is: can I use an SRF Chip like “B023 – Slice of Radio” (http://openmicros.org/index.php/articles/94-ciseco-product-documentation/raspberry-pi/282-b023-slice-of-radio) with jeelib code? Are there really differneces between rfm12B modul and SRF RF module. Looks like that they are compatible for jeelib right?

    I need to ask that before I will flash the demosketch for rfm12B on that raspberry PI extension board (b023-slice-of-radio) without having a backup of the currently installed code. And it looks like that the orignale code for b023-slice-of-radio is not downloadable.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.