RadioLib/examples/RTTY/RTTY_Transmit/RTTY_Transmit.ino

138 wiersze
3.2 KiB
Arduino
Czysty Zwykły widok Historia

2018-08-20 18:42:14 +00:00
/*
2019-02-08 14:58:29 +00:00
RadioLib RTTY Transmit Example
2018-08-20 18:42:14 +00:00
This example sends RTTY message using SX1278's
FSK modem.
2018-10-07 10:14:42 +00:00
Other modules that can be used for RTTY:
- SX127x/RFM9x
2018-10-07 10:14:42 +00:00
- RF69
2019-02-08 14:58:29 +00:00
- SX1231
2018-12-26 10:19:30 +00:00
- CC1101
- SX126x
2019-06-02 13:03:02 +00:00
- nRF24
2020-03-30 15:39:47 +00:00
- Si443x/RFM2x
2020-04-07 11:30:27 +00:00
- SX128x
2019-06-02 13:03:02 +00:00
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration
2019-06-02 13:03:02 +00:00
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
2018-08-20 18:42:14 +00:00
*/
// include the library
2019-02-08 14:58:29 +00:00
#include <RadioLib.h>
2018-08-20 18:42:14 +00:00
2019-06-02 13:03:02 +00:00
// SX1278 has the following connections:
// NSS pin: 10
// DIO0 pin: 2
2019-12-27 12:23:35 +00:00
// RESET pin: 9
2019-06-02 13:03:02 +00:00
// DIO1 pin: 3
SX1278 radio = new Module(10, 2, 9, 3);
2019-06-02 13:03:02 +00:00
// or using RadioShield
// https://github.com/jgromes/RadioShield
//SX1278 radio = RadioShield.ModuleA;
2018-08-20 18:42:14 +00:00
// create RTTY client instance using the FSK module
RTTYClient rtty(&radio);
2018-08-20 18:42:14 +00:00
void setup() {
Serial.begin(9600);
// initialize SX1278 with default settings
2018-08-23 07:21:28 +00:00
Serial.print(F("[SX1278] Initializing ... "));
int state = radio.beginFSK();
// when using one of the non-LoRa modules for RTTY
2020-03-30 15:39:47 +00:00
// (RF69, CC1101, Si4432 etc.), use the basic begin() method
// int state = radio.begin();
2018-08-20 18:42:14 +00:00
if(state == ERR_NONE) {
2018-08-23 07:21:28 +00:00
Serial.println(F("success!"));
2018-08-20 18:42:14 +00:00
} else {
2018-08-23 07:21:28 +00:00
Serial.print(F("failed, code "));
2018-08-20 18:42:14 +00:00
Serial.println(state);
while(true);
}
// initialize RTTY client
2018-10-07 12:56:09 +00:00
// NOTE: RTTY frequency shift will be rounded
2018-12-26 10:19:30 +00:00
// to the nearest multiple of frequency step size.
// The exact value depends on the module:
2020-03-30 15:39:47 +00:00
// SX127x/RFM9x - 61 Hz
2018-12-26 10:19:30 +00:00
// RF69 - 61 Hz
// CC1101 - 397 Hz
2019-05-15 15:20:20 +00:00
// SX126x - 1 Hz
2019-06-01 18:50:58 +00:00
// nRF24 - 1000000 Hz
2020-03-30 15:39:47 +00:00
// Si443x/RFM2x - 156 Hz
2020-04-07 11:30:27 +00:00
// SX128x - 198 Hz
2018-08-23 07:21:28 +00:00
Serial.print(F("[RTTY] Initializing ... "));
2018-12-26 10:19:30 +00:00
// low ("space") frequency: 434.0 MHz
2018-08-23 07:21:28 +00:00
// frequency shift: 183 Hz
2018-08-20 18:42:14 +00:00
// baud rate: 45 baud
// encoding: ASCII (7-bit)
2018-08-20 18:42:14 +00:00
// stop bits: 1
2019-06-01 18:50:58 +00:00
state = rtty.begin(434.0, 183, 45);
2018-08-20 18:42:14 +00:00
if(state == ERR_NONE) {
2018-08-23 07:21:28 +00:00
Serial.println(F("success!"));
2018-08-20 18:42:14 +00:00
} else {
2018-08-23 07:21:28 +00:00
Serial.print(F("failed, code "));
2018-08-20 18:42:14 +00:00
Serial.println(state);
while(true);
}
/*
2019-02-08 14:58:29 +00:00
// RadioLib also provides ITA2 ("Baudot") support
rtty.begin(434, 183, 45, ITA2);
// All transmissions in loop() (strings and numbers)
// will now be encoded using ITA2 code
2019-05-24 12:15:58 +00:00
// ASCII characters that do not have ITA2 equivalent
// will be sent as NUL (including lower case letters!)
*/
2018-08-20 18:42:14 +00:00
}
void loop() {
Serial.print(F("[RTTY] Sending RTTY data ... "));
2019-05-24 12:15:58 +00:00
2018-08-23 07:21:28 +00:00
// send out idle condition for 500 ms
rtty.idle();
delay(500);
2018-08-20 18:42:14 +00:00
// RTTYClient supports all methods of the Serial class
2018-08-23 07:21:28 +00:00
// Arduino String class
String aStr = "Arduino String";
rtty.println(aStr);
// character array (C-String)
rtty.println("C-String");
2018-08-23 07:21:28 +00:00
// string saved in flash
rtty.println(F("Flash String"));
2018-08-23 07:21:28 +00:00
// character
rtty.println('c');
2019-05-24 12:15:58 +00:00
2018-08-23 07:21:28 +00:00
// byte
// formatting DEC/HEX/OCT/BIN is supported for
// any integer type (byte/int/long)
rtty.println(255, HEX);
2018-08-23 07:21:28 +00:00
// integer number
int i = 1000;
rtty.println(i);
2018-08-23 07:21:28 +00:00
// floating point number
float f = -3.1415;
rtty.println(f, 3);
2019-05-24 12:15:58 +00:00
2018-08-23 07:21:28 +00:00
Serial.println(F("done!"));
2018-08-20 18:42:14 +00:00
// wait for a second before transmitting again
delay(1000);
}