Çözüldü5.98K görüntülenmeArduinoproblem lora and arduino proje
0

For end school project i have to do  Arduino and LORA net
I have bought 2 sx 1276 and 2 antenna (868 MHZ)
https://www.aliexpress.com/item/1005002925290600.html?spm=a2g0o.productlist.0.0.714c14b2v3XLYQ&algo_pvid=e3ae67dd-fbe6-4394-9bda-db58f51a27f2&algo_exp_id=e3ae67dd-fbe6-4394-9bda-db58f51a27f2-3
https://www.aliexpress.com/item/32850539643.html?spm=a2g0o.store_pc_allProduct.8148356.3.638b21fdYtGxtH.
I have do some test but i can’t have communication (see attach)
Can you help me?
 
 

////////////////TRASMITTER code

#include
<SoftwareSerial.h>
#include “EBYTE.h”
#define PIN_RX 2
#define PIN_TX 3
#define PIN_M0 4
#define PIN_M1 5
#define PIN_AX 6

struct DATA {
unsigned long Count;
int Bits;
float Volts;
float Amps;
};
int Chan;
DATA MyData;

SoftwareSerial ESerial(PIN_RX, PIN_TX);
// create the transceiver object, passing in the serial and pins
EBYTE Transceiver(&ESerial, PIN_M0, PIN_M1, PIN_AX);

void setup() {
Serial.begin(9600);
// start the transceiver serial port–i have yet to get a different
// baud rate to work–data sheet says to keep on 9600
ESerial.begin(9600);
Serial.println(“Starting Sender”);
// this init will set the pinModes for you
Transceiver.init();

}
void loop() {
// measure some data and save to the structure
MyData.Count++;
MyData.Bits = analogRead(A0);
MyData.Volts = MyData.Bits * ( 5.0 / 1024.0 );

Transceiver.SendStruct(&MyData, sizeof(MyData));

Serial object
// ESerial.write((uint8_t*) &Data, PacketSize );
// let the use know something was sent
Serial.print(“Sending: “); Serial.println(MyData.Count);
delay(1000);
}

////////////////RECEIVER code

#include
<SoftwareSerial.h>
#include “EBYTE.h”
#define PIN_RX 2
#define PIN_TX 3
#define PIN_M0 4
#define PIN_M1 5
#define PIN_AX 6
 
struct DATA {
unsigned long Count;
int Bits;
float Volts;
float Amps;
};
 
int Chan;
DATA MyData;
unsigned long Last;

SoftwareSerial ESerial(PIN_RX, PIN_TX);
// create the transceiver object, passing in the serial and pins
EBYTE Transceiver(&ESerial, PIN_M0, PIN_M1, PIN_AX);
void setup() {
Serial.begin(9600);
ESerial.begin(9600);
Serial.println(“Starting Reader”);
// this init will set the pinModes for you
Transceiver.init();
// all these calls are optional but shown to give examples of what you
can do
// Serial.println(Transceiver.GetAirDataRate());
// Serial.println(Transceiver.GetChannel());
// Transceiver.SetAddressH(1);
// Transceiver.SetAddressL(0);
// Chan = 5;
// Transceiver.SetChannel(Chan);
// save the parameters to the unit,
// Transceiver.SaveParameters(PERMANENT);
// you can print all parameters and is good for debugging
// if your units will not communicate, print the parameters
// for both sender and receiver and make sure air rates, channel
// and address is the same
Transceiver.PrintParameters();
}
void loop() {
// if the transceiver serial is available, proces incoming data
// you can also use Transceiver.available()
if (ESerial.available()) {
// i highly suggest you send data using structures and not
// a parsed data–i’ve always had a hard time getting reliable data
using
// a parsing method
Transceiver.GetStruct(&MyData, sizeof(MyData));
// You only really need this library to program these EBYTE units.
// For reading data structures, you can call readBytes directly on the
EBYTE Serial object
// ESerial.readBytes((uint8_t*)& MyData, (uint8_t) sizeof(MyData));
// dump out what was just received
Serial.print(“Count: “); Serial.println(MyData.Count);
Serial.print(“Bits: “); Serial.println(MyData.Bits);
Serial.print(“Volts: “); Serial.println(MyData.Volts);
// if you got data, update the checker
Last = millis();
}
else {
// if the time checker is over some prescribed amount
// let the user know there is no incoming data
if ((millis() – Last) > 1000) {
Serial.println(“Searching: “);
Last = millis();
}
}
}

Soru yeni cevaplara kapalıdır.
Mehmet En iyi cevap olarak seçildi Ekim 18, 2021
0

well Actually i didnt understand your code. but i see you are not using usb parameter setting device. I am strongly recommend to use that part for edditing parameter setting for Lora E32.

https://urun.n11.com/arduino-urunleri-ve-setleri/lora-parametre-ayarlari-icin-usb-stick-usb-uart-cp2102-e15-usb-t2-P479061354

anyway lets continue to dangerous way.

primarily, you should make a connection M0 and M1 to 5v and than use that for setting E32 lora. original code is over here:

https://github.com/xreef/LoRa_E32_Series_Library/blob/master/examples/arduinoSetConfiguration/arduinoSetConfiguration.ino

/*
 * LoRa E32-TTL-100
 * Set configuration.
 * https://www.mischianti.org/2019/10/29/lora-e32-device-for-arduino-esp32-or-esp8266-configuration-part-3/
 *
 * E32-TTL-100----- Arduino UNO
 * M0         ----- 3.3v
 * M1         ----- 3.3v
 * TX         ----- PIN 2 (PullUP)
 * RX         ----- PIN 3 (PullUP & Voltage divider)
 * AUX        ----- Not connected
 * VCC        ----- 3.3v/5v
 * GND        ----- GND
 *
 */
#include "Arduino.h"
#include "LoRa_E32.h"
 LoRa_E32 e32ttl100(2, 3); // e32 TX e32 RX
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
 void setup() {
 Serial.begin(9600);
 delay(500);
  // Startup all pins and UART
 e32ttl100.begin();
  ResponseStructContainer c;
 c = e32ttl100.getConfiguration();
 // It's important get configuration pointer before all other operation
 Configuration configuration = *(Configuration*) c.data;
 Serial.println(c.status.getResponseDescription());
 Serial.println(c.status.code);
  printParameters(configuration);
 configuration.ADDL = 0x0;
 configuration.ADDH = 0x1;
 configuration.CHAN = 0x19;
  configuration.OPTION.fec = FEC_0_OFF;
 configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
 configuration.OPTION.ioDriveMode = IO_D_MODE_PUSH_PULLS_PULL_UPS;
 configuration.OPTION.transmissionPower = POWER_17;
 configuration.OPTION.wirelessWakeupTime = WAKE_UP_1250;
  configuration.SPED.airDataRate = AIR_DATA_RATE_011_48;
 configuration.SPED.uartBaudRate = UART_BPS_115200;
 configuration.SPED.uartParity = MODE_00_8N1;
  // Set configuration changed and set to not hold the configuration
 ResponseStatus rs = e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
 Serial.println(rs.getResponseDescription());
 Serial.println(rs.code);
 printParameters(configuration);
 c.close();
}
 void loop() {
 }

After you set 2 lora modules with same paremeters and same channel but different adress. one adres should be 44 and another adres should be 63

you can use my sample codes like that:

circuit should be like that and be careful for be wary of contactless situations. for test using you can use without rezistance.

this code will send message to adress 44

#include "LoRa_E32.h"
#include <SoftwareSerial.h>
  SoftwareSerial mySerial(10, 11);
  /*
   Pinler     Arduino Nano    Lora E32 433T20d
                  11                3
                  10                4
*/
  LoRa_E32 e32ttl(&mySerial);
  struct Signal {
  char type[15] = "Fixaj.com";
  byte temp[4];
} data;
    void setup() {
  Serial.begin(9600);
  e32ttl.begin();
  delay(500);
}
  void loop() {
    ResponseStatus rs = e32ttl.sendFixedMessage(0, 44, 23, &data, sizeof(Signal));
  Serial.println(rs.getResponseDescription());
    delay(2000);
    while (e32ttl.available()  > 1) {
    ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(Signal));
    struct Signal data = *(Signal*) rsc.data;
    Serial.print("Yer: ");
    Serial.println(data.type);
    Serial.print("Ortam Sıcaklığı: ");
    Serial.println(*(float*)(data.temp));
    rsc.close();
  }
}

and this code will receive and than send to adres 63

#include "LoRa_E32.h"
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // Arduino RX <-- e32 TX, Arduino TX --> e32 RX
LoRa_E32 e32ttl(&mySerial);
  struct Signal {
  char type[15];
  byte temp[4];
} data;
  void setup() {
  Serial.begin(9600);
  e32ttl.begin();
  delay(500);
}
  void loop() {
  while (e32ttl.available()  > 1) {
      // Gelen mesaj okunuyor
    ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(Signal));
    struct Signal data = *(Signal*) rsc.data;
    Serial.print("Gelen Messaj: ");
    Serial.println(data.type);
    rsc.close();
      //Gönderilecek paket veri hazırlanıyor
    struct Signal  {
      char type[15] = "Bebek Odası";
      byte temp[4];
    } data2;
      *(float*)(data2.temp) = 19.2;
        ResponseStatus rs = e32ttl.sendFixedMessage(0, 63, 23, &data2, sizeof(Signal));
    Serial.println(rs.getResponseDescription());
    }
  }

original code is over here:

https://fixaj.com/lora-modulu-ile-alici-verici-transceiver-yapimi/

Mehmet En iyi cevap olarak seçildi Ekim 18, 2021
5 cevaptan 1'ini inceliyorsun, tüm cevapları görmek için buraya tıklayın.