devansh_tangri
Published © MIT

LoRa powered Garage Door Model using ESP32 and RYLR988

This project demonstrates a wireless garage door control system using LoRa communication between two ESP32-based nodes. The system uses the

BeginnerFull instructions provided2 hours48

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
×1
RYLR988
×2
SparkFun Breadboard Power Supply 5V/3.3V
SparkFun Breadboard Power Supply 5V/3.3V
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×2
Espressif ESP32 Development Board - Developer Edition
Espressif ESP32 Development Board - Developer Edition
×2

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

Garage Housing 3D Model

Garage Door 3D Model

Schematics

Garage Side Wiring Diagram

Remote Side Wiring Diagram

Code

Remote MCU Code

C/C++
#include <Arduino.h>

#define LORA_RX 4 //Change these pins accordingly
#define LORA_TX 5 //Change these pins accordingly

HardwareSerial loraSerial(1);
uint8_t buttonState;
uint8_t lastButtonState = 0;
uint8_t lastPressTime;

void setup() {
  loraSerial.begin(115200, SERIAL_8N1, LORA_RX, LORA_TX);
  pinMode(2, INPUT_PULLUP);

  delay(250);
  loraSerial.write("AT+ADDRESS=0\r\n");
  delay(250);
  loraSerial.write("AT+NETWORKID=18\r\n");
  delay(250);
  loraSerial.write("AT+BAND=865000000\r\n");
}

void loop() {
  static bool doorState = false;
  uint8_t currentReading = digitalRead(2);

  if (lastButtonState != currentReading) {
    if (currentReading == LOW) {
      delay(150);
      if (currentReading == LOW) {
        doorState = !doorState;
        loraSerial.print("AT+SEND=2,1," + String(doorState) + "\r\n");
      }
    }
  }

  lastButtonState = currentReading;
}

Garage MCU Code

C/C++
#include <ESP32Servo.h>

Servo S1;

#define LORA_RX 26 //Change these pins accordingly
#define LORA_TX 27 //Change these pins accordingly
#define servoPin 14 //Change these pins accordingly
HardwareSerial loraSerial(1);

void driveServo(int a) {
  static int position = 40;

  if (a > position) {
    while (a > position) {
      S1.write(position++);
      delay(10);
    }
  } else if (a < position) {
    while (a < position) {
      S1.write(position--);
      delay(10);
    }
  }
}
void setup() {
  loraSerial.begin(115200, SERIAL_8N1, LORA_RX, LORA_TX);

  ESP32PWM::allocateTimer(0);
  ESP32PWM::allocateTimer(1);
  ESP32PWM::allocateTimer(2);
  ESP32PWM::allocateTimer(3);
  S1.setPeriodHertz(50);
  S1.attach(servoPin, 500, 2500);
  S1.write(40);

  delay(250);
  loraSerial.write("AT+ADDRESS=2\r\n");
  delay(250);
  loraSerial.write("AT+NETWORKID=18\r\n");
  delay(250);
  loraSerial.write("AT+BAND=865000000\r\n"); //Please change the band according to your country laws
}

void loop() {
  if (loraSerial.available()) {
    String data = loraSerial.readStringUntil('\n');
    data = data.substring(9, 10);

    if (data == "1") driveServo(100);
    else if (data = "0") driveServo(40);
  }
}

Credits

devansh_tangri
4 projects • 10 followers
I'm a 17 yo student, making Arduino Projects and Electrical Circuits is my favorite hobby. I have been making circuits for about 8 years.

Comments