new test using a ESP32 with a Heltec_HT-RA62 SX1262 LoRa module
running File>Examples>RadioLib>SX126x/SX126x_Transmit_Interrupt
Transmitter code
// Heltec HT_62_SX1262 _Transmit_Interrupt
// File>Examples>RadioLib>SX126x/SX126x_Transmit_Interrupt
// EDITs:
// radio.begin frequency set to 868.0
// transmitting byte array and printing it
/*
RadioLib SX126x Transmit with Interrupts Example
This example transmits LoRa packets with one second delays
between them. Each packet contains up to 256 bytes
of data, in the form of:
- Arduino String
- null-terminated char array (C-string)
- arbitrary binary data (byte array)
Other modules from SX126x family can also be used.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// HT_62 SX1262 has the following connections:
// NSS pin: 5
// DIO1 pin: 14
// NRST pin: 12
// BUSY pin: 13
SX1262 radio = new Module(5, 14, 12, 13);
// or detect the pinout automatically using RadioBoards
// https://github.com/radiolib-org/RadioBoards
/*
#define RADIO_BOARD_AUTO
#include <RadioBoards.h>
Radio radio = new RadioModule();
*/
// save transmission state between loops
int transmissionState = RADIOLIB_ERR_NONE;
// flag to indicate that a packet was sent
volatile bool transmittedFlag = false;
// this function is called when a complete packet
// is transmitted by the module
// IMPORTANT: this function MUST be 'void' type
// and MUST NOT have any arguments!
#if defined(ESP8266) || defined(ESP32)
ICACHE_RAM_ATTR
#endif
void setFlag(void) {
// we sent a packet, set the flag
transmittedFlag = true;
}
void setup() {
Serial.begin(115200);
delay(2000);
// initialize SX1262 with default settings
Serial.print(F("\n\nHT_62 [SX1262] Initializing ... "));
int state = radio.begin(868.0);
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true) { delay(10); }
}
// set the function that will be called
// when packet transmission is finished
radio.setPacketSentAction(setFlag);
// start transmitting the first packet
Serial.print(F("[SX1262] Sending first packet ... "));
// you can transmit C-string or Arduino string up to
// 256 characters long
transmissionState = radio.startTransmit("Hello World!");
// you can also transmit byte array up to 256 bytes long
/*
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
0x89, 0xAB, 0xCD, 0xEF};
state = radio.startTransmit(byteArr, 8);
*/
}
// counter to keep track of transmitted packets
int count = 0;
void loop() {
// check if the previous transmission finished
if (transmittedFlag) {
// reset flag
transmittedFlag = false;
if (transmissionState == RADIOLIB_ERR_NONE) {
// packet was successfully sent
Serial.println(F("transmission finished!"));
// NOTE: when using interrupt-driven transmit method,
// it is not possible to automatically measure
// transmission data rate using getDataRate()
} else {
Serial.print(F("failed, code "));
Serial.println(transmissionState);
}
// clean up after transmission is finished
// this will ensure transmitter is disabled,
// RF switch is powered down etc.
radio.finishTransmit();
// wait a second before transmitting again
delay(1000);
// send another one
Serial.print(F("[SX1262] Sending another packet ... "));
// you can transmit C-string or Arduino string up to
// 256 characters long
//String str = "Hello World! #" + String(count++);
//transmissionState = radio.startTransmit(str);
// you can also transmit byte array up to 256 bytes long
static byte byteArr[] = { 0x01, 0x23, 0x45, 0x67,
0x89, 0xAB, 0xCD, 0xEF };
for (int i = 0; i < sizeof(byteArr); i++)
Serial.printf("%d ", byteArr[i]);
transmissionState = radio.startTransmit(byteArr, 8);
byteArr[0]++;
}
}
using a Heltec LoRa V2 SX1276 as a receiver as in post 10
Heltec_HT-RA62 SX1262 LoRa module serial monitor output
HT_62 [SX1262] Initializing ... success!
[SX1262] Sending first packet ... transmission finished!
[SX1262] Sending another packet ... 1 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 2 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 3 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 4 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 5 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 6 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 7 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 8 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 9 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 10 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 11 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 12 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 13 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 14 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 15 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 16 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 17 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 18 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 19 35 69 103 137 171 205 239 transmission finished!
Heltec LoRa V2 SX1276 as a receiver serial monitor output
Heltec LoRa V2 SX1276 [SX1276] Initializing ... success!
[SX1276] Starting to listen ... success!
[SX1276] Received packet!
[SX1276] Data: 3 35 69 103 137 171 205 239
[SX1276] RSSI: -50.00 dBm
[SX1276] SNR: 10.00 dB
[SX1276] Frequency error: -3961.52 Hz
[SX1276] Received packet!
[SX1276] Data: 4 35 69 103 137 171 205 239
[SX1276] RSSI: -50.00 dBm
[SX1276] SNR: 9.00 dB
[SX1276] Frequency error: -3969.91 Hz
[SX1276] Received packet!
[SX1276] Data: 5 35 69 103 137 171 205 239
[SX1276] RSSI: -49.00 dBm
[SX1276] SNR: 9.75 dB
[SX1276] Frequency error: -3978.30 Hz
[SX1276] Received packet!
[SX1276] Data: 6 35 69 103 137 171 205 239
[SX1276] RSSI: -50.00 dBm
[SX1276] SNR: 9.75 dB
[SX1276] Frequency error: -3986.69 Hz
[SX1276] Received packet!
[SX1276] Data: 7 35 69 103 137 171 205 239
[SX1276] RSSI: -50.00 dBm
[SX1276] SNR: 9.50 dB
[SX1276] Frequency error: -3995.07 Hz
[SX1276] Received packet!
[SX1276] Data: 8 35 69 103 137 171 205 239
[SX1276] RSSI: -50.00 dBm
[SX1276] SNR: 9.75 dB
[SX1276] Frequency error: -3999.27 Hz
[SX1276] Received packet!
[SX1276] Data: 9 35 69 103 137 171 205 239
[SX1276] RSSI: -50.00 dBm
[SX1276] SNR: 9.75 dB
[SX1276] Frequency error: -4003.46 Hz
looking at the Heltec_HT-RA62 SX1262 LoRa schematic DIO2 is connected via some circuitry to TXEN and RXEN
when transmitting oscilloscope shows DIO2 controlling TXEN (going HIGH) and RXEN (going LOW)
the schematic of the Waveshare Core1262-868M in post 7 does not show TXEN and RXEN connected to anything
suggest you try the File>Examples>RadioLib>SX126x/SX126x_Transmit_Interrupt and SX126x_Receive_Interrupt
assuming you connected them correctly you should get a initialization success message, e.g. transmitter
[SX1262] Initializing ... success!
[SX1262] Sending first packet ... transmission finished!
[SX1262] Sending another packet ... 1 35 69 103 137 171 205 239 transmission finished!
[SX1262] Sending another packet ... 2 35 69 103 137 171 205 239 transmission finished!
if it fails you have a wiring problem
if you get initialization success messages on transmiter and receiver the transmitter should show it is transmitting messages and the receiver should show received messages
if the receiver does not show received messages check the transmitter TXEN and RXEN lines with an oscilloscope if possible
as the schematic of the Waveshare Core1262-868M in post 7 does not show TXEN and RXEN connected to anything you may have to control them yourself, e.g. on transmit taking TXEN HIGH and RXEN LOW