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 |
SX1231_Transmit.ino (1835B)
1 /* 2 RadioLib SX1231 Transmit Example 3 4 This example transmits packets using SX1231 FSK radio module. 5 6 NOTE: SX1231 offers the same features as RF69 and has the same 7 interface. Please see RF69 examples for examples on AES, 8 address filtering, interrupts and settings. 9 10 For default module settings, see the wiki page 11 https://github.com/jgromes/RadioLib/wiki/Default-configuration#rf69sx1231 12 13 For full API reference, see the GitHub Pages 14 https://jgromes.github.io/RadioLib/ 15 */ 16 17 // include the library 18 #include <RadioLib.h> 19 20 // SX1231 has the following connections: 21 // CS pin: 10 22 // DIO0 pin: 2 23 // RESET pin: 3 24 SX1231 radio = new Module(10, 2, 3); 25 26 // or using RadioShield 27 // https://github.com/jgromes/RadioShield 28 //SX1231 radio = RadioShield.ModuleA; 29 30 void setup() { 31 Serial.begin(9600); 32 33 // initialize SX1231 with default settings 34 Serial.print(F("[SX1231] Initializing ... ")); 35 int state = radio.begin(); 36 if (state == RADIOLIB_ERR_NONE) { 37 Serial.println(F("success!")); 38 } else { 39 Serial.print(F("failed, code ")); 40 Serial.println(state); 41 while (true); 42 } 43 } 44 45 void loop() { 46 Serial.print(F("[SX1231] Transmitting packet ... ")); 47 48 // you can transmit C-string or Arduino string up to 256 characters long 49 int state = radio.transmit("Hello World!"); 50 51 // you can also transmit byte array up to 256 bytes long 52 /* 53 byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; 54 int state = radio.transmit(byteArr, 8); 55 */ 56 57 if (state == RADIOLIB_ERR_NONE) { 58 // the packet was successfully transmitted 59 Serial.println(F("success!")); 60 61 } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) { 62 // the supplied packet was longer than 256 bytes 63 Serial.println(F("too long!")); 64 65 } 66 67 // wait for a second before transmitting again 68 delay(1000); 69 }