xreef / LoRa_E32_Series_Library

Arduino LoRa EBYTE E32 device library complete and tested with Arduino, esp8266, esp32, STM32 and Raspberry Pi Pico (rp2040 boards). sx1278/sx1276
https://www.mischianti.org
Other
348 stars 72 forks source link

is that posiible to use Lora at esp32 with software serial? #41

Closed fixajteknik closed 2 years ago

fixajteknik commented 2 years ago

well, I am using HMI display and Lora in a same project. but only I can use RX2/TX2 hardware serial but also I need to use a serial for connecting HMI display do you have prefer any example?

fixajteknik commented 2 years ago

well Actually I found another way with your hardware selection method like this,

#include "LoRa_E32.h"
 #include <HardwareSerial.h>
 HardwareSerial mySerial(1);
LoRa_E32 e32(2,15,&mySerial, UART_BPS_RATE_9600);

struct Signal {
  char type[15] = "ESP32 Selam";
  byte temp[4];
} data;

#define M0 18
#define M1 19

#define TX 2
#define RX 15

void setup() {

  pinMode(M0, OUTPUT);
  pinMode(M1, OUTPUT);
  digitalWrite(M0, LOW);
  digitalWrite(M1, 0);

  Serial.begin(9600);
  mySerial.begin(9600, SERIAL_8N1, TX, RX);
  delay(500);
  e32.begin();
  delay(500);

}

void loop() {
  ResponseStatus rs = e32.sendFixedMessage(0, 1, 6, &data, sizeof(Signal));
  Serial.println(rs.getResponseDescription());

  delay(2000);

  while (e32.available()  > 1) {
    // Gelen mesaj okunuyor
    ResponseStructContainer rsc = e32.receiveMessage(sizeof(Signal));
    struct Signal data = *(Signal*) rsc.data;
    Serial.print("Yer: ");
    Serial.println(data.type);
    rsc.close();
  }
}

İs this safe to use?

xreef commented 2 years ago

Hi @fixajteknik, yes, you can find more information about the constructor in this paragraph. https://www.mischianti.org/2019/10/21/lora-e32-device-for-arduino-esp32-or-esp8266-library-part-2/#Constructor

Bye Renzo