flok99

rfm96

May 11th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. // ** RECV **
  2.  
  3. #include <SPI.h>
  4.  
  5. #include <RFM69.h>
  6. #include <RFM69Config.h>
  7.  
  8. RFM69 radio;
  9.  
  10. void interrupt_function(){
  11.   radio.isr0();
  12. }
  13.  
  14. void setup() {
  15.   Serial.begin(115200);
  16.  
  17.   radio.init();
  18.  
  19.   attachInterrupt(0, interrupt_function, RISING);
  20.   delay(100);
  21.  
  22.   // radio.setFrequency(868.0f);
  23.   radio.setModeRx();
  24. }
  25.  
  26. void loop() {
  27.   if (radio.available()) {
  28.     Serial.print(radio.lastRssi());
  29.  
  30.     uint8_t buf[65];
  31.     uint8_t len = sizeof(buf) - 1;
  32.    
  33.     radio.recv(buf, &len);
  34.     buf[64] = 0x00;
  35.    
  36.     Serial.println((char *)buf);
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment