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();
}
}
}
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(“—————————————-“);
}