Adding RFM12B to my GTI

Have started to play with an idea that it may be possible to add RFM12B to my GTI to provide on line information to emoncms.

As brought to my attention by Jorg our german friends have written an open source code for standard GTI design which seems to be very well commented and easy to adapt to any standard GTI (like powerjack, greenpower etc...). The GTI is based on ATMEGA 8 variant and therefore very easy to program with tools we are familiar with from this board.

As the programming happens using almost standard SPI interface this same interface is almost there for jeelabs RFM12B board - only Chip Select (SEL) signal is needed additionally. Current firmware for GTI uses PortD 2 for led 3 - normally indicating power on which could be "stolen" for RF12 CS and hence also showing Chip Select activity.

So hardware wise the wiring could be the following using almost standard plug in connection.

// PortD                                    1 = EIN, 0 = AUS
#define RELAIS                         1 // Eingangsrelais
#define LED3                           2 // grün, Power
#define LED2                           3 // grün, MPPTracker +
#define LED4                           4 // grün, MPPTracker -
#define LED1                           5 // rot, Fehler

Next challenge would be to find out how to implement "send only" code for RFM12B without jeelibs. Any suggestions to which direction to look for this kind of code ?

MartinR's picture

Re: Adding RFM12B to my GTI

There's transmit only RFM12B code that doesn't use JeeLib (or IRQ) buried in my sketch here..

it should be fairly easy to pull out the functions you need



Petrik's picture

Re: Adding RFM12B to my GTI

Excellent - will have a look at your source when with a bit more time...

To me this would be a giant leap to be able to have virtually any standard GTI to deliver monitoring info feed In to

JBecker's picture

Re: Adding RFM12B to my GTI

Another idea would be to use a standard Jeenode (or something similar) and connect this via SPI (or bit-banged I²C or Uart) to the GTI as an RF gateway. At the moment I have an LCD connected to the ISP adapter, but as Petri says, a direct 'link' to emoncms would be perfect!!!

BR, Jörg.

PS: If someone else here is interested in 'open source' firmware for a number of chinese GTIs, just contact me (or Petri) or take a look here (sorry, only in german).



Petrik's picture

Re: Adding RFM12B to my GTI


Finally had time to look the code from MartinR - simplified it to a RFM12B sending module only. Then realized that it needs SPI library implementation. Anyway the packet sender routine is the key information to implement standalone. Copy it here in case anyone else needs to understand how emontx sends the data to emoncms.

rfm_write(0x8228); // OPEN PA

  SPI.transfer(0xb8); // tx register write command
    while(digitalRead(SDOPIN)==0); // wait for SDO to go high
      case 0:
      case 1:
      case 2: next=0xaa; txstate++; break;
      case 3: next=0x2d; txstate++; break;
      case 4: next=800; txstate++; break; // Group ID
      case 5: next=30; txstate++; break;  // node ID
      case 6: next=size; txstate++; break;
      case 7: next=data[i++]; if(i==size) txstate++; break;
      case 8: next=(byte)crc; txstate++; break;
      case 9: next=(byte)(crc>>8); txstate++; break;
      case 10:
      case 11:
      case 12: next=0xaa; txstate++; break; // dummy bytes (if <3 CRC gets corrupted sometimes)
    if((txstate>4)&&(txstate<9)) crc = _crc16_update(crc, next);
  rfm_write( 0x8208 ); // CLOSE PA


Petrik's picture

Re: Adding RFM12B to my GTI


Maybe this could work as basis for sending without SPI ...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.