noob confuse with SPI - setSS() missing / RFM70 module

Hi,

as said I'm am not an expert. I want to get a RFM70 modul running and tried/copied the example code from http://www.rkner.at/home/news.avr.rfm70.html

I am not sure how outdated the code is even it says 2011. But they used WProgram.h and Spi.h which is now Arduino.h and SPI.h.

I changed "Spi.mode(1<<SPR0)" to "SPI.setDataMode(1<<SPR0)". But I am not 100% sure if this is right.

They also call "Spi.setSS()" quite often. But I can't find any replacement.

So did anything change with the SPI library. Is there a document about this?

Or is there any other example running RFM70 available?

Any suggestions are welcome.

thx n rgds

The Spi.setSS() should probably be "digitalWrite(ssPin, LOW)" where 'ssPin' is whatever pin you are using for the Slave Select signal.

did you get it to work?
I'm stuck with the same problem.

You also want to check out this site
http://www.voti.nl/rfm70/index_1.html

Hi,

I have the same problem. I have replaced the "Spi.setSS()" with "digitalWrite(10, LOW)", and I have run over other problems when compiling.

F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_pcmd(const uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:70: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:71: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:75: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg(uint8_t, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:80: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:81: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:84: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t read_reg(uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:91: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:94: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:142: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:143: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:147: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void read_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:152: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:153: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:159: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t send_packet(uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:168: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:173: error: 'class SPIClass' has no member named 'setSS
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_pcmd(const uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:70: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:71: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:75: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg(uint8_t, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:80: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:81: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:84: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t read_reg(uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:91: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:94: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void write_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:142: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:143: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:147: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'void read_reg_pbuf(uint8_t, uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:152: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:153: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:159: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp: In function 'uint8_t send_packet(uint8_t*, uint8_t)':
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:168: error: 'class SPIClass' has no member named 'setSS'
F:\Arduino\arduino-0022\libraries\RFM70\rfm70.cpp:173: error: 'class SPIClass' has no member named 'setSS

The problem seem's to be in the .cpp library file. I think he is using different Spi.h and WProgram.h. I really nead this RFM for my project but I dont know how to repair it.
Also I replaced all the "Spi.[...]" forms in the library files with "SPI.[...]", as seen in the quoate of the debbuging

Hi everyone,
I also tried the code from
http://www.rkner.at/home/news.avr.rfm70.html,
but I found out that it is not really Arduino compatible.

So I ported my own RFM70 driver from the original HopeRF example code.
It is working, but it is slow because I am not using the Arduino SPI driver.
If you are interrested tell me and I can post my code here.

Fred

Here is a page (http://goews.com/rfm70) with a Chat project example using two RFM70 modules and ATMEGAs. Though it is strictly AVR code, not Arduino, but it may help.

@Superfred- Please post your code! I cannot find any online.

Hello sbright33,

here is the link to the library: skip.co.at/RFM70/RFM70.zip
unpack it to C:\Program Files (x86)\arduino-1.0\libraries\RFM70.

Pinout:
CE Pin 9
CSN Pin 10
SCK Pin 13
MISO Pin 12
MOSI Pin 11
IRQ Pin 8

and don't forget the 3.3 V stepdown converter!

Please ask me if you have any questions!

Example code (not all was tested):

#include "RFM70.h"

RFM70class RFM70;

byte RFM70_buf[MAX_PACKET_LEN];  //RFM70 data buffer
unsigned long RFMSendTime = 0;   //next send time
int RFMSendSpeed=1000;           //send packet every 1000 msec


void setup()
{
    Serial.begin(57600);  
    Serial.println("Arduino Start");    
    RFM70.begin();
    RFM70.Initialize();
    RFMSendTime = millis();
  
} 

void loop()
{
    rfmTask();                                    //check for RFM70 event in polling mode
    if (millis() > RFMSendTime)                   //send packet
    {                                                    
      RFMSendTime = millis() + RFMSendSpeed; 
      RFM70_buf[0]=0X41;      
      RFM70_buf[1]=0X42;
      RFM70_buf[2]=0X43;
      RFM70_buf[3]=0X44;      
      RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
      Serial.println("Sending data");       
    }  
}

void rfmTask()                //RFM70 event handler
{
  if (RFM70.RfmInterrupt())
  {
    if (RFM70.TxDataSentInterrupt())
    {
       Serial.println("Data sent OK");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.TxDataSentErrorInterrupt())
    {
       Serial.println("Data sent error");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.RxDataReadyInterrupt())
    {
       Serial.println("Data received: ");
       byte rx_len = RFM70.Receive_Packet(RFM70_buf);
       if (rx_len) 
       {
          for(byte i=1;i<rx_len;i++)
          {
            Serial.print(i);
            Serial.print("->");
            Serial.println(RFM70_buf[i]);
          }         
       }    
     }
  }
}

Thanks will try it later! I feel like I've been paid back for all the hard work I've done on the motor code...

Superfred:
Hello sbright33,

here is the link to the library: skip.co.at/RFM70/RFM70.zip
unpack it to C:\Program Files (x86)\arduino-1.0\libraries\RFM70.

Pinout:
CE Pin 9
CSN Pin 10
SCK Pin 13
MISO Pin 12
MOSI Pin 11
IRQ Pin 8

and don't forget the 3.3 V stepdown converter!

Please ask me if you have any questions!

Example code (not all was tested):

#include "RFM70.h"

RFM70class RFM70;

byte RFM70_buf[MAX_PACKET_LEN];  //RFM70 data buffer
unsigned long RFMSendTime = 0;   //next send time
int RFMSendSpeed=1000;           //send packet every 1000 msec

void setup()
{
    Serial.begin(57600); 
    Serial.println("Arduino Start");   
    RFM70.begin();
    RFM70.Initialize();
    RFMSendTime = millis();
 
}

void loop()
{
    rfmTask();                                    //check for RFM70 event in polling mode
    if (millis() > RFMSendTime)                   //send packet
    {                                                   
      RFMSendTime = millis() + RFMSendSpeed;
      RFM70_buf[0]=0X41;     
      RFM70_buf[1]=0X42;
      RFM70_buf[2]=0X43;
      RFM70_buf[3]=0X44;     
      RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
      Serial.println("Sending data");       
    } 
}

void rfmTask()                //RFM70 event handler
{
  if (RFM70.RfmInterrupt())
  {
    if (RFM70.TxDataSentInterrupt())
    {
       Serial.println("Data sent OK");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.TxDataSentErrorInterrupt())
    {
       Serial.println("Data sent error");
       RFM70.SwitchToRxMode();
    }
    if (RFM70.RxDataReadyInterrupt())
    {
       Serial.println("Data received: ");
       byte rx_len = RFM70.Receive_Packet(RFM70_buf);
       if (rx_len)
       {
          for(byte i=1;i<rx_len;i++)
          {
            Serial.print(i);
            Serial.print("->");
            Serial.println(RFM70_buf[i]);
          }         
       }   
     }
  }
}

This is code for transmitting? How recive? I have 2 arduino's and 2 rfm70 mnodule.

Hello Fajkowsky,

this code is transmitting and receiving.

Ecery second we are sending one packet:

    if (millis() > RFMSendTime)                   //send packet
    {                                                    
      RFMSendTime = millis() + RFMSendSpeed; 
      RFM70_buf[0]=0X41;      
      RFM70_buf[1]=0X42;
      RFM70_buf[2]=0X43;
      RFM70_buf[3]=0X44;      
      RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
      Serial.println("Sending data");       
    }

We are constantly polling the RFM70 status:

rfmTask();

If the data was sent successfully or an error occoured we switch back to RX Mode:

RFM70.SwitchToRxMode();

So this code sends every second one packet, the rest of the time the RFM70 is waiting in receive mode.

If you load this code in two Arduinos with RFM70s, it can work but if both are sending exactly the same time it will not. To overcome this you can have only one sending and one receiving (delete the send code in one) , or you choose different (maybe random) send times (like Ethernet wait a random time if the sending was unsuccessful), or you use a polling mode where the master tells the slave when to send.

Tell me if you have still questions.
Fred

i have done exactly the same setup of yours and i also cared for this following thing:

If you load this code in two Arduinos with RFM70s, it can work but if both are sending exactly the same time it will not. To overcome this you can have only one sending and one receiving (delete the send code in one) , or you choose different (maybe random) send times (like Ethernet wait a random time if the sending was unsuccessful), or you use a polling mode where the master tells the slave when to send.

The its not receiving anything , i have deumilanove on receiver side with atmega8 and the uno on the sender side.

Hi NI$HANT,

do you get any serial info from polling rfmTask() like "Data sent OK" or "Data sent error" on the sender side?
You should get at least "Data sent error" if the Receiver side is off.
If not it seems that you have a hardware problem.

Do you use this pinout?
CE Pin 9
CSN Pin 10
SCK Pin 13
MISO Pin 12
MOSI Pin 11
IRQ Pin 8

and don't forget the 3.3 V stepdown converter!

Fred

do you get any serial info from polling rfmTask() like "Data sent OK" or "Data sent error" on the sender side?

Hi Fred i just get the "Sending data" on serial from the TX and Arduino start on the rx and nothing else and i have tried using the original code of yours at both the tx and rx and also tweaked the code to just BE a tx or a rx so no interference happens, still it works the same NOTHING is there.

Do you use this pinout?
CE   Pin 9
CSN  Pin 10
SCK  Pin 13
MISO Pin 12
MOSI Pin 11
IRQ  Pin 8

Yes, exactly this connectivity.

and don't forget the 3.3 V stepdown converter!

I just powered the modules from 3.3v at other sites the people were doing the same and i read i think that the SPI pins on RFM70 are 5v tolerant.

Hi,

I was using 1K Resistors to seperate the 5V Arduino and the 3.3 V RFM70.
I can't say if the RFM70 is 5V tolerant.

The logic of my code is:
Every second a packet is sent,
and independently RFMTask() is polling the IRQ pin.

This Pin goes low if one of the following events occour:
-Data sent OK (Ack from receiver received)
-Data sent Error (no Ack received)
-Data received

RFM70.TxDataSentInterrupt(), RFM70.TxDataSentErrorInterrupt() and RFM70.RxDataReadyInterrupt() functions checks the RFM70 on SPI level which of the events trigged the IRQ (and clears the IRQ).

If you still have problems you can uncomment the //Serial.print commands (there are many of them) in the RFM70.cpp file (you may have to restart your Arduino IDE to activate the change) to get low level trace printout of the SPI interface data.
You can send me the Trace data for debugging.

My code don't stop if the RFM70 is not present, so you get no error but you will receive no events.

Fred

Hi Fred thank you for the help actually if you see this>> http://www.hoperf.com/upload/rf/RFM70.pdf then you can note on the page 22 that im connecting correctly and i have double checked my connections as such they are fine , im just not having the Decoupling caps in the systems thats just a small difference but i checked the power on the wireless modules its comingin fine to them.

One thing more , Is there a need to set CHANNEL's in both of these modules tx and rx both, However i have tried also with this by setting them to same channel that is 1.

Im now receiving like this: after making some changes and putting a ATmega168 in one of the modules instead of an ATmega8

Data received: 
Sending data
Data sent OK
Data received: 
Data sent OK
Data received: 
->f
->L
->?
->?
->?
->e
a->L
->É
Data sent OK
Data received: 
Data sent error
Data sent OK
Data sent OK
Data sent OK
Data sent error
Data received: 
Data received: 
Data received: 
Data sent OK
Data received: 
Data sent error
Data received: 
Data sent OK
Data sent OK

now again the problem BOTH The modules just keep on sending nothing received.

Hi,

You receive events, so there cant be much wrong anymore.

Start just in the simplest case: one side is only sending, the other side is only receiving.
(comment out all sending code on the receiving side, at least

//RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);

I inserted a debug line to print out how many bytes are received:

       .....
if (RFM70.RxDataReadyInterrupt())
    {
       Serial.print("Data received, length: ");
       byte rx_len = RFM70.Receive_Packet(RFM70_buf);
       Serial.println(rx_len);
       if (rx_len) 
       {
          for(byte i=1;i<rx_len;i++)
          {
            Serial.print(i);
            Serial.print("->");
            Serial.println(RFM70_buf[i]);
       ......
          }

The number of Bytes sent is the last argument in the RFM70.Send_Packet() command.
The same number of bytes should be received on the receiving end.

ATMEGA8:
My driver uses only GPIO functions, so I don't see any problem to use ATMEGA8, but maybe there is just a Pin numbering problem and SCK, MISO and MOSI uses different Pins compared to ATMEGA168.