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 |
Si443x_Transmit.ino (2284B)
1 /* 2 RadioLib Si443x Transmit Example 3 4 This example transmits packets using Si4432 FSK radio module. 5 Each packet contains up to 64 bytes of data, in the form of: 6 - Arduino String 7 - null-terminated char array (C-string) 8 - arbitrary binary data (byte array) 9 10 Other modules from Si443x/RFM2x family can also be used. 11 12 For default module settings, see the wiki page 13 https://github.com/jgromes/RadioLib/wiki/Default-configuration#si443xrfm2x 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 // Si4432 has the following connections: 23 // nSEL pin: 10 24 // nIRQ pin: 2 25 // SDN pin: 9 26 Si4432 radio = new Module(10, 2, 9); 27 28 // or using RadioShield 29 // https://github.com/jgromes/RadioShield 30 //Si4432 radio = RadioShield.ModuleA; 31 32 void setup() { 33 Serial.begin(9600); 34 35 // initialize Si4432 with default settings 36 Serial.print(F("[Si4432] 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("[Si4432] Transmitting packet ... ")); 49 50 // you can transmit C-string or Arduino string up to 51 // 64 characters long 52 // NOTE: transmit() is a blocking method! 53 // See example Si443x_Transmit_Interrupt for details 54 // on non-blocking transmission method. 55 int state = radio.transmit("Hello World!"); 56 57 // you can also transmit byte array up to 64 bytes long 58 /* 59 byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; 60 int state = radio.transmit(byteArr, 8); 61 */ 62 63 if (state == RADIOLIB_ERR_NONE) { 64 // the packet was successfully transmitted 65 Serial.println(F(" success!")); 66 67 } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) { 68 // the supplied packet was longer than 256 bytes 69 Serial.println(F(" too long!")); 70 71 } else if (state == RADIOLIB_ERR_TX_TIMEOUT) { 72 // timeout occured while transmitting packet 73 Serial.println(F(" timeout!")); 74 75 } else { 76 // some other error occurred 77 Serial.print(F("failed, code ")); 78 Serial.println(state); 79 80 } 81 82 // wait for a second before transmitting again 83 delay(1000); 84 }