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 |
RTTY_Transmit_AFSK.ino (3180B)
1 /* 2 RadioLib RTTY Transmit AFSK Example 3 4 This example sends RTTY message using SX1278's 5 FSK modem. The data is modulated as AFSK. 6 7 Other modules that can be used for RTTY: 8 - SX127x/RFM9x 9 - RF69 10 - SX1231 11 - CC1101 12 - Si443x/RFM2x 13 14 For default module settings, see the wiki page 15 https://github.com/jgromes/RadioLib/wiki/Default-configuration 16 17 For full API reference, see the GitHub Pages 18 https://jgromes.github.io/RadioLib/ 19 */ 20 21 // include the library 22 #include <RadioLib.h> 23 24 // SX1278 has the following connections: 25 // NSS pin: 10 26 // DIO0 pin: 2 27 // RESET pin: 9 28 // DIO1 pin: 3 29 SX1278 radio = new Module(10, 2, 9, 3); 30 31 // or using RadioShield 32 // https://github.com/jgromes/RadioShield 33 //SX1278 radio = RadioShield.ModuleA; 34 35 // create AFSK client instance using the FSK module 36 // pin 5 is connected to SX1278 DIO2 37 AFSKClient audio(&radio, 5); 38 39 // create RTTY client instance using the AFSK instance 40 RTTYClient rtty(&audio); 41 42 void setup() { 43 Serial.begin(9600); 44 45 // initialize SX1278 with default settings 46 Serial.print(F("[SX1278] Initializing ... ")); 47 int state = radio.beginFSK(); 48 49 // when using one of the non-LoRa modules for RTTY 50 // (RF69, CC1101, Si4432 etc.), use the basic begin() method 51 // int state = radio.begin(); 52 53 if(state == RADIOLIB_ERR_NONE) { 54 Serial.println(F("success!")); 55 } else { 56 Serial.print(F("failed, code ")); 57 Serial.println(state); 58 while(true); 59 } 60 61 // initialize RTTY client 62 // NOTE: Unlike FSK RTTY, AFSK requires no rounding of 63 // the frequency shift. 64 Serial.print(F("[RTTY] Initializing ... ")); 65 // space frequency: 400 Hz 66 // frequency shift: 170 Hz 67 // baud rate: 45 baud 68 // encoding: ASCII (7-bit) 69 // stop bits: 1 70 state = rtty.begin(400, 170, 45); 71 if(state == RADIOLIB_ERR_NONE) { 72 Serial.println(F("success!")); 73 } else { 74 Serial.print(F("failed, code ")); 75 Serial.println(state); 76 while(true); 77 } 78 79 /* 80 // RadioLib also provides ITA2 ("Baudot") support 81 rtty.begin(400, 170, 45, ITA2); 82 83 // All transmissions in loop() (strings and numbers) 84 // will now be encoded using ITA2 code 85 86 // ASCII characters that do not have ITA2 equivalent 87 // will be sent as NUL (including lower case letters!) 88 */ 89 } 90 91 void loop() { 92 Serial.print(F("[RTTY] Sending RTTY data ... ")); 93 94 // send out idle condition for 500 ms 95 rtty.idle(); 96 delay(500); 97 98 // RTTYClient supports all methods of the Serial class 99 100 // Arduino String class 101 String aStr = "Arduino String"; 102 rtty.println(aStr); 103 104 // character array (C-String) 105 rtty.println("C-String"); 106 107 // string saved in flash 108 rtty.println(F("Flash String")); 109 110 // character 111 rtty.println('c'); 112 113 // byte 114 // formatting DEC/HEX/OCT/BIN is supported for 115 // any integer type (byte/int/long) 116 rtty.println(255, HEX); 117 118 // integer number 119 int i = 1000; 120 rtty.println(i); 121 122 // floating point number 123 float f = -3.1415; 124 rtty.println(f, 3); 125 126 // turn the transmitter off 127 rtty.standby(); 128 129 Serial.println(F("done!")); 130 131 // wait for a second before transmitting again 132 delay(1000); 133 }