Turn on Light With Reyax RYLR896 LoRa Modules With Acknowledgement
by CarlosVoltT in Circuits > Arduino
140 Views, 2 Favorites, 0 Comments
Turn on Light With Reyax RYLR896 LoRa Modules With Acknowledgement
In this tutorial, you will learn how to use the Reyax RYLR896 LoRa modules to wirelessly and reliably control lights.
In this tutorial, you will learn how to use the Reyax RYLR896 LoRa modules to wirelessly and reliably control lights. We will take advantage of these modules' ability to send and receive data over long distances, as well as their acknowledgement functionality, to ensure that light on and off signals are received correctly.
Tutorial Contents:
Introduction to RYLR896 LoRa Modules :
- Features and technical specifications.
- Initial setup and connection.
- Introduction to RYLR896 LoRa Modules :Features and technical specifications.Initial setup and connection.
Necessary materials :
- LoRa Reyax RYLR896 modules (two units).
- Luces LED.
- Microcontrollers (Arduino uno and nano).
- Additional components (resistors, cables, power supply).
- Necessary materials :LoRa Reyax RYLR896 modules (two units).Luces LED.Microcontrollers (Arduino uno and nano).Additional components (resistors, cables, power supply).
Hardware Configuration :
- Connecting LoRa modules to the microcontroller.
- Mounting the light control circuit.
- Hardware Configuration :Connecting LoRa modules to the microcontroller.Mounting the light control circuit.
Microcontroller Programming :
- Configuring the LoRa module for transmission and reception.
- Code to send the on/off signal.
- Implementation of acknowledgement to ensure signal reception.
- Microcontroller Programming :Configuring the LoRa module for transmission and reception.Code to send the on/off signal.Implementation of acknowledgement to ensure signal reception.
Testing and Troubleshooting :
- Verifying communication between modules.
- Troubleshooting common issues and configuration settings.
- Testing and Troubleshooting :Verifying communication between modules.Troubleshooting common issues and configuration settings.
Practical applications :
- Examples of home use and automation projects.
- Project expansion to control multiple lights or devices.
- Practical applications :Examples of home use and automation projects.Project expansion to control multiple lights or devices.
Tutorial Objectives:
- Understand the basic operation of Reyax RYLR896 LoRa modules.
- Learn how to configure and use modules for wireless communication.
- Implement a lighting control system with confirmation of signal reception.
- Develop skills to integrate LoRa into IoT and automation projects.
This tutorial is ideal for electronics and automation enthusiasts who want to explore the potential of LoRa communication for practical, long-range applications. Upon completion, you will have a functional system that will allow you to control lights wirelessly and reliably.
868/915MHz LoRa® Antenna Transceiver Module
- ◆ Certification: NCC, FCC
- ◆ Frequency range: 868/915 MHz
- ◆ Motor Semtech SX1276
- ◆ High efficiency power amplifier
- ◆ Excellent immunity to blocking.
- ◆ Low receiving current
- ◆ High sensitivity
- ◆ Easy control via AT commands
- ◆ Rango dinámico RSSI de 127 dB
- ◆ Designed with integrated antenna
- ◆ AES128 data encryption
- ◆ Working temperature: -40℃ to +85℃
- ◆ Dimensions: 42.5 x 18.36 x 5.5 mm
- ◆ Weight: 7 g
Description
The RYLR896 transceiver module features the LoRa® long-range modem that provides ultra-long-range spread spectrum communication and high immunity to interference while minimizing current consumption. The module is NCC and FCC certified.
Electronic components of the project
Arduino Nano
A socket for arduino
Un resistor de 1 KOhm
A 5mm LED diode
Female pins
Dupont cables female male
Display oled sh1106
This is a 128x64 dot monochrome OLED display module with I2C interface. It has several advantages over LCD displays, such as high brightness, very good contrast, a wider viewing angle, and low power consumption. It is compatible with Arduino Rasberry Pi and PIC microcontrollers among others. It works with logic levels from 3.3V to 5V and has a viewing angle greater than 160 degrees. The screen size is 1.3 inches. It is powered by a voltage of 3.3V to 5V. It can be used in applications such as smart watches, MP3, thermometers, instruments, and various projects, etc.
Characteristics
- Interface: I2C(3.3V / 5V logic level)
- Resolution: 128 x 64
- Angle of view: >160 degree
- Display color: Blue
- Display size: 1.3 inch
- Driver IC: SH1106
- Power supply: DC 3.3V~5V
- Operating temperature: -20~70’C
- Application: smart watch, MP3, thermometer, instruments, DIY projects, etc.
A KY-004 push button module
PCB
Electronic pcb diagram
Circuit with arduino nano
Circuit with Arduino Uno
Source Code Emisor
#include <U8glib.h>
// Inicializa el display SH1106
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);
// Define el pin del botón
const int pinBoton = 12;
bool botonPresionado = false;
bool mensajeEnviado = false;
// Variables para los mensajes a mostrar en el display
String mensajeDisplay = "Presiona la tecla";
// Configuración inicial
void setup() {
// Configura el pin del botón como entrada con resistencia pull-up interna
pinMode(pinBoton, INPUT_PULLUP);
// Inicializa la comunicación serial
Serial.begin(9600);
// Dibuja el mensaje inicial en el display
dibujar();
}
// Función para dibujar en el display
void dibujar() {
u8g.firstPage();
do {
u8g.setFont(u8g_font_unifont);
u8g.drawStr(0, 22, mensajeDisplay.c_str());
} while (u8g.nextPage());
}
// Loop principal
void loop() {
// Lee el estado del botón (inverso porque estamos usando pull-up)
if (digitalRead(pinBoton) == LOW) {
if (!botonPresionado) {
botonPresionado = true;
mensajeEnviado = true;
// Envía el mensaje por el puerto serial con retorno de carro y nueva línea
Serial.print("AT+SEND=0,5,HELLO\r\n");
// Cambia el mensaje del display
mensajeDisplay = "Mensaje enviado!";
// Dibuja en el display
dibujar();
// Espera para evitar rebotes del botón
delay(200);
}
} else {
botonPresionado = false;
}
// Revisa si hay datos disponibles en el puerto serial
if (Serial.available() > 0) {
// Lee la entrada serial
String entrada = Serial.readStringUntil('\n');
// Procesa el mensaje recibido utilizando indexOf para buscar las palabras clave
if (entrada.indexOf("luzon") != -1) {
mensajeDisplay = "Luz encendida";
dibujar();
} else if (entrada.indexOf("luzoff") != -1) {
mensajeDisplay = "Luz apagada";
dibujar();
}
}
// Si no se ha enviado ningún mensaje aún, mantiene el mensaje inicial
if (!mensajeEnviado) {
dibujar();
}
}
Source Code Receiver
const int pinLed = 12; // Pin digital al que está conectado el LED
bool estadoLed = false; // Variable para rastrear el estado del LED
void setup() {
// Configura el pin digital como salida
pinMode(pinLed, OUTPUT);
// Inicia la comunicación serial a 9600 baudios
Serial.begin(9600);
}
void loop() {
// Verifica si hay datos disponibles en el puerto serial
if (Serial.available() > 0) {
// Lee la cadena entrante
String entrada = Serial.readStringUntil('\n');
// Busca la palabra "HELLO" en la cadena
int indiceHello = entrada.indexOf("HELLO");
// Si "HELLO" está presente, cambia el estado del LED
if (indiceHello != -1) {
estadoLed = !estadoLed; // Cambia el estado del LED
digitalWrite(pinLed, estadoLed ? HIGH : LOW); // Enciende o apaga el LED según el nuevo estado
// Envía el mensaje por el puerto serie según el estado del LED
if (estadoLed) {
Serial.println("AT+SEND=0,5,luzon\r\n");
} else {
Serial.println("AT+SEND=0,6,luzoff\r\n");
}
}
}
}