have an elegoo mega 2650 rev3 and an uno R4. the modules are the 915m30s both with the 915 1/2 antenna.
heres the current wiring for the mega:
VCC (Power): Connect to the 5V pin
GND (Ground): All GND connect to the GND pins
3.3V (Logic): Connect to the 3.3V pin
SDI (MOSI): Connect to pin 51
SDO (MISO): Connect to pin 50
SCK: Connect to pin 52
NSS (CS): Connect to pin 10
RST (Reset): Connect to pin 9
DIO0: Connect to pin 2
DIO1: Connect to pin 3
TX_ENABLE: Connect to pin 5
RX_ENABLE: Connect to pin 4
and for the UNO:
VCC (Power): Connect to the 5V pin
GND (Ground): All GND connect to the GND pins
3.3V (Logic): Connect to the 3.3V pin
SDI (MOSI): Connect to pin 11
SDO (MISO): Connect to pin 12
SCK: Connect to pin 13
NSS (CS): Connect to pin 10
RST (Reset): Connect to pin 9
DIO0: Connect to pin 2
DIO1: Connect to pin 3
TX_ENABLE: Connect to pin 5
RX_ENABLE: Connect to pin 4
so i set the controllers to loop into themselves to test the LEDs on the boards(rx and tx) when doing this both boards randomly would actually tx and rx, as i lowered the delay the uno received more and more actual tx from the mega.
but when i set each device to be a dedicated tx or rx, they don’t work. im currently using 1.221.1 Radiohead
heres the loop example:
#include <RadioLib.h>
// SX1276 requires the following connections:
int pin_cs = 10; // Chip Select
int pin_dio0 = 2; // DIO0
int pin_nrst = 9; // Reset
int pin_dio1 = 3; // DIO1
int pin_rx_enable = 4; // RX Enable
int pin_tx_enable = 5; // TX Enable
SX1276 radio = new Module(pin_cs, pin_dio0, pin_nrst, pin_dio1);
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
delay(500); // Wait for Arduino to be ready to print
Serial.print("[SX1276] Initializing ... ");
int state = radio.begin(915.0); // 915 gang
if (state == RADIOLIB_ERR_NONE) {
Serial.println("init success!");
} else {
Serial.print("failed, code ");
Serial.println(state);
while (true); // Halt execution if initialization fails
}
radio.setRfSwitchPins(pin_tx_enable, pin_rx_enable);
}
void loop() {
Serial.print("[SX1276] Transmitting packet ... ");
char output[] = "Hello, LoRa!";
int state = radio.transmit(output);
if (state == RADIOLIB_ERR_NONE) {
Serial.println("success!");
} else {
Serial.print("failed, code ");
Serial.println(state);
}
delay(1000); // Wait for a second before receiving
Serial.print("[SX1276] Receiving packet ... ");
String receivedMessage;
state = radio.receive(receivedMessage);
if (state == RADIOLIB_ERR_NONE) {
Serial.print("Received message: ");
Serial.println(receivedMessage);
} else {
Serial.print("Receive failed, code ");
Serial.println(state);
}
delay(2000); // Wait before the next loop
}
Heres the rx code for the mega:
#include <RadioLib.h>
// SX1276 requires the following connections:
int pin_cs = 10; // Chip Select
int pin_dio0 = 2; // DIO0
int pin_nrst = 9; // Reset
int pin_dio1 = 3; // DIO1
int pin_rx_enable = 4; // RX Enable
int pin_tx_enable = 5; // TX Enable
SX1276 radio = new Module(pin_cs, pin_dio0, pin_nrst, pin_dio1);
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
delay(500); // Wait for Arduino to be ready to print
Serial.print("[SX1276] Initializing ... ");
int state = radio.begin(915.0); // Use the correct frequency for your region
if (state == RADIOLIB_ERR_NONE) {
Serial.println("init success!");
} else {
Serial.print("failed, code ");
Serial.println(state);
while (true); // Halt execution if initialization fails
}
radio.setRfSwitchPins(pin_tx_enable, pin_rx_enable);
}
void loop() {
Serial.println("Checking for data...");
if (radio.available()) {
String receivedMessage;
int state = radio.receive(receivedMessage);
if (state == RADIOLIB_ERR_NONE) {
Serial.print("Received message: ");
Serial.println(receivedMessage);
// Get and print the RSSI value
int rssi = radio.getRSSI();
Serial.print("RSSI: ");
Serial.println(rssi);
} else {
Serial.print("Receive failed, code ");
Serial.println(state);
}
} else {
Serial.println("No data available");
}
delay(1000); // Adjust delay to ensure the receiver has time to process data
}
heres the uno’s tx code:
#include <RadioLib.h>
// SX1276 requires the following connections:
int pin_cs = 10; // Chip Select
int pin_dio0 = 2; // DIO0
int pin_nrst = 9; // Reset
int pin_dio1 = 3; // DIO1
int pin_rx_enable = 4; // RX Enable
int pin_tx_enable = 5; // TX Enable
SX1276 radio = new Module(pin_cs, pin_dio0, pin_nrst, pin_dio1);
int counter = 0;
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud rate
delay(500); // Wait for Arduino to be ready to print
Serial.print("[SX1276] Initializing ... ");
int state = radio.begin(915.0); // 915 gang
if (state == RADIOLIB_ERR_NONE) {
Serial.println("init success!");
} else {
Serial.print("failed, code ");
Serial.println(state);
while (true); // Halt execution if initialization fails
}
radio.setRfSwitchPins(pin_tx_enable, pin_rx_enable);
radio.setOutputPower(2); // Lower the transmission power for close distance
}
void loop() {
Serial.print("[SX1276] Transmitting packet ... ");
char output[50];
sprintf(output, "Counter: %d", counter++);
int state = radio.transmit(output);
if (state == RADIOLIB_ERR_NONE) {
Serial.println("success!");
} else {
Serial.print("failed, code ");
Serial.println(state);
}
delay(1000); // Adjust delay to ensure receiver has time to process
}
is it me, the wires, how tx rx is being handled? please help! :?