acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
RF69_Receive.ino (2213B)
1 /* 2 RadioLib RF69 Receive Example 3 4 This example receives packets using RF69 FSK radio module. 5 To successfully receive data, the following settings have to be the same 6 on both transmitter and receiver: 7 - carrier frequency 8 - bit rate 9 - frequency deviation 10 - sync word 11 12 For default module settings, see the wiki page 13 https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 14 15 For full API reference, see the GitHub Pages 16 https://jgromes.github.io/RadioLib/ 17 */ 18 19 // include the library 20 #include <RadioLib.h> 21 22 // RF69 has the following connections: 23 // CS pin: 10 24 // DIO0 pin: 2 25 // RESET pin: 3 26 RF69 radio = new Module(10, 2, 3); 27 28 // or using RadioShield 29 // https://github.com/jgromes/RadioShield 30 //RF69 radio = RadioShield.ModuleA; 31 32 void setup() { 33 Serial.begin(9600); 34 35 // initialize RF69 with default settings 36 Serial.print(F("[RF69] Initializing ... ")); 37 int state = radio.begin(); 38 if (state == RADIOLIB_ERR_NONE) { 39 Serial.println(F("success!")); 40 } else { 41 Serial.print(F("failed, code ")); 42 Serial.println(state); 43 while (true); 44 } 45 } 46 47 void loop() { 48 Serial.print(F("[RF69] Waiting for incoming transmission ... ")); 49 50 // you can receive data as an Arduino String 51 String str; 52 int state = radio.receive(str); 53 54 // you can also receive data as byte array 55 /* 56 byte byteArr[8]; 57 int state = radio.receive(byteArr, 8); 58 */ 59 60 if (state == RADIOLIB_ERR_NONE) { 61 // packet was successfully received 62 Serial.println(F("success!")); 63 64 // print the data of the packet 65 Serial.print(F("[RF69] Data:\t\t")); 66 Serial.println(str); 67 68 // print RSSI (Received Signal Strength Indicator) 69 // of the last received packet 70 Serial.print(F("[RF69] RSSI:\t\t")); 71 Serial.print(radio.getRSSI()); 72 Serial.println(F(" dBm")); 73 74 } else if (state == RADIOLIB_ERR_RX_TIMEOUT) { 75 // timeout occurred while waiting for a packet 76 Serial.println(F("timeout!")); 77 78 } else if (state == RADIOLIB_ERR_CRC_MISMATCH) { 79 // packet was received, but is malformed 80 Serial.println(F("CRC error!")); 81 82 } else { 83 // some other error occurred 84 Serial.print(F("failed, code ")); 85 Serial.println(state); 86 87 } 88 }