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.ino (3345B)

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