Çözüldü4.89K 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
0

ok daniel if connection problem still continue. contact with me whatsapp +905446271985 . it will be faster.

Mehmet Cevaplanan soru Eylül 28, 2021
0

Hello,

i have use usb programmingArduino code

Daniele Lucchesi Cevaplanan soru Eylül 28, 2021
0

Hello,

for programming i use arduino code

#include “Arduino.h”
#include “LoRa_E32.h”

LoRa_E32 e32ttl100(9,8); // e32 TX e32 RX
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);

void setup() {
Serial.begin(9600);
e32ttl100.begin();
delay(100);

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.ADDH = 0x0;
configuration.ADDL = 0x3;
//configuration.CHAN = 0x06;

/*configuration.OPTION.fec = FEC_1_ON;
configuration.OPTION.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
configuration.OPTION.ioDriveMode = IO_D_MODE_OPEN_COLLECTOR; //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_9600;
configuration.SPED.uartParity = MODE_00_8N1;
*/

ResponseStatus rs = e32ttl100.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE); //LOSE

ResponseStructContainer cMi;
cMi = e32ttl100.getModuleInformation();

// It’s important get information pointer before all other operation
ModuleInformation mi = *(ModuleInformation*)cMi.data;

Serial.println(cMi.status.getResponseDescription());
Serial.println(cMi.status.code);

printModuleInformation(mi);

//e32ttl100.setMode(MODE_0_NORMAL);
e32ttl100.begin();
}

void loop() {}

void printParameters(struct Configuration configuration) {
Serial.println(“—————————————-“);

Serial.print(F(“HEAD BIN: “)); Serial.print(configuration.HEAD);Serial.print(” “);Serial.print(configuration.HEAD, DEC);Serial.print(” “);Serial.println(configuration.HEAD, HEX);
Serial.println(F(” “));
Serial.print(F(“AddH BIN: “)); Serial.println(configuration.ADDH);
Serial.print(F(“AddL BIN: “)); Serial.println(configuration.ADDL);
Serial.print(F(“Chan BIN: “)); Serial.print(configuration.CHAN, DEC); Serial.print(” -> “); Serial.println(configuration.getChannelDescription());
Serial.println(F(” “));
Serial.print(F(“SpeedParityBit BIN : “)); Serial.print(configuration.SPED.uartParity, DEC);Serial.print(” -> “); Serial.println(configuration.SPED.getUARTParityDescription());
Serial.print(F(“SpeedUARTDataRate BIN : “)); Serial.print(configuration.SPED.uartBaudRate, DEC);Serial.print(” -> “); Serial.println(configuration.SPED.getUARTBaudRate());
Serial.print(F(“SpeedAirDataRate BIN : “)); Serial.print(configuration.SPED.airDataRate, DEC);Serial.print(” -> “); Serial.println(configuration.SPED.getAirDataRate());

Serial.print(F(“OptionTrans BIN : “)); Serial.print(configuration.OPTION.fixedTransmission, DEC);Serial.print(” -> “); Serial.println(configuration.OPTION.getFixedTransmissionDescription());
Serial.print(F(“OptionPullup BIN : “)); Serial.print(configuration.OPTION.ioDriveMode, DEC);Serial.print(” -> “); Serial.println(configuration.OPTION.getIODroveModeDescription());
Serial.print(F(“OptionWakeup BIN : “)); Serial.print(configuration.OPTION.wirelessWakeupTime, DEC);Serial.print(” -> “); Serial.println(configuration.OPTION.getWirelessWakeUPTimeDescription());
Serial.print(F(“OptionFEC BIN : “)); Serial.print(configuration.OPTION.fec, DEC);Serial.print(” -> “); Serial.println(configuration.OPTION.getFECDescription());
Serial.print(F(“OptionPower BIN : “)); Serial.print(configuration.OPTION.transmissionPower, DEC);Serial.print(” -> “); Serial.println(configuration.OPTION.getTransmissionPowerDescription());

Serial.println(“—————————————-“);

}
void printModuleInformation(struct ModuleInformation moduleInformation) {
Serial.println(“—————————————-“);
Serial.print(F(“HEAD BIN: “)); Serial.print(moduleInformation.HEAD, BIN);Serial.print(” “);Serial.print(moduleInformation.HEAD, DEC);Serial.print(” “);Serial.println(moduleInformation.HEAD, HEX);

Serial.print(F(“Freq.: “)); Serial.println(moduleInformation.frequency, HEX);
Serial.print(F(“Version : “)); Serial.println(moduleInformation.version, HEX);
Serial.print(F(“Features : “)); Serial.println(moduleInformation.features, HEX);
Serial.println(“—————————————-“);

}

Daniele Lucchesi Cevaplanan soru Eylül 21, 2021
Whatsapp'tan Yaz
1
Ürün Danışmanı Burada!
fixaj.com Ürün Danışmanı
Merhaba,

Ben sadece "Satın Alma" konularında destek vermekteyim.

Kodlama yardımı, haberleşme hataları, bağlantı şemaları vb. konularla ilgili "Soru&Cevap" https://fixaj.com/sorucevap/ sayfamızı ziyaret edebilirsiniz.