Çö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
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.