0
Offline
Newbie
Karma: 0
Posts: 12
Arduino rocks
|
 |
« on: January 16, 2012, 04:43:02 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Massachusetts, USA
Offline
Tesla Member
Karma: 96
Posts: 6376
|
 |
« Reply #1 on: January 16, 2012, 02:58:02 pm » |
The Spi.setSS() should probably be "digitalWrite(ssPin, LOW)" where 'ssPin' is whatever pin you are using for the Slave Select signal.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #2 on: January 25, 2012, 12:00:18 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #3 on: February 06, 2012, 01:26:53 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #4 on: March 03, 2012, 10:18:07 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #5 on: April 11, 2012, 07:08:17 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 4
Posts: 1132
If you're not living on the Edge, you're taking up too much space!
|
 |
« Reply #6 on: April 22, 2012, 10:01:58 am » |
@Superfred- Please post your code! I cannot find any online.
|
|
|
|
|
Logged
|
If you fall... I'll be there for you! -Floor
Skype Brighteyes3333 (262) 696-9619
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #7 on: April 23, 2012, 08:13:17 am » |
Hello sbright33, here is the link to the library: skip.co.at/RFM70/RFM70.zipunpack 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]); } } } } }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 4
Posts: 1132
If you're not living on the Edge, you're taking up too much space!
|
 |
« Reply #8 on: April 23, 2012, 10:58:04 am » |
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...
|
|
|
|
|
Logged
|
If you fall... I'll be there for you! -Floor
Skype Brighteyes3333 (262) 696-9619
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 30
|
 |
« Reply #9 on: June 06, 2012, 09:35:50 am » |
Hello sbright33, here is the link to the library: skip.co.at/RFM70/RFM70.zipunpack 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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #10 on: June 08, 2012, 08:58:37 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #11 on: June 29, 2012, 03:36:46 am » |
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.
|
|
|
|
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #12 on: June 29, 2012, 09:06:34 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
ਪੰਜਾਬ
Offline
Edison Member
Karma: 4
Posts: 1224
WANTED! A Girl with LOVE for me and Arduino!
|
 |
« Reply #13 on: June 29, 2012, 09:16:46 am » |
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.
|
|
|
|
|
Logged
|
"Real Men can Accomplish Anything" - Website - skype : nishants5 ਫ਼ਤੇਹ ਕਰੂਂ !
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #14 on: June 29, 2012, 09:56:09 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
|