Thank you very much Renzo, I send you the code of the emitters ( 2 arduino nano) and receiver, in the emitters I use arduino nano and in the receiver a Mega:
Emitter 1 code (Nano):
#include "Arduino.h"
#include "LoRa_E22.h"
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
LoRa_E22 e22ttl(&mySerial, 3, 7, 6); // AUX M0 M1
void setup() {
Serial.begin(9600);
delay(500);
// Startup all pins and UART
e22ttl.begin();
Serial.println("Hi, I'm going to send message!");
struct Message {
char type[5] = "1";
byte amp1[5];
byte volt1[6];
} message;
*(int*)(message.amp1)=100;
*(int*)(message.volt1)=10;
// Send message
ResponseStatus rs = e22ttl.sendMessage(&message, sizeof(Message));
// Check If there is some problem of succesfully send
Serial.println(rs.getResponseDescription());
}
void loop() {
delay(2000);
struct Message {
char type[5] = "1";
byte amp1[5];
byte volt1[6];
} message;
if (*(int*)(message.amp1)>999){
*(int*)(message.amp1)=10;
}
(*(int*)(message.amp1))++;
if (*(int*)(message.volt1)>99){
*(int*)(message.volt1)=10;
}
(*(int*)(message.volt1))++;
// Send message
ResponseStatus rs = e22ttl.sendMessage(&message, sizeof(Message));
// Check If there is some problem of succesfully send
Serial.println(rs.getResponseDescription());
}
//——————————————————————–
Emitter 2 code (Nano):
#include "Arduino.h"
#include "LoRa_E22.h"
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5); // Arduino RX <-- e22 TX, Arduino TX --> e22 RX
LoRa_E22 e22ttl(&mySerial, 3, 7, 6); // AUX M0 M1
void setup() {
Serial.begin(9600);
delay(500);
// Startup all pins and UART
e22ttl.begin();
Serial.println("Hi, I'm going to send message!");
struct Message {
char type[5] = "2";
byte amp2[5];
byte volt2[6];
} message;
*(int*)(message.amp2)=100;
*(int*)(message.volt2)=10;
// Send message
ResponseStatus rs = e22ttl.sendMessage(&message, sizeof(Message));
// Check If there is some problem of succesfully send
Serial.println(rs.getResponseDescription());
}
void loop() {
delay(1900);
struct Message {
char type[5] = "2";
byte amp2[5];
byte volt2[6];
} message;
if (*(int*)(message.amp2)>999){
*(int*)(message.amp2)=10;
}
(*(int*)(message.amp2))++;
if (*(int*)(message.volt2)>99){
*(int*)(message.volt2)=10;
}
(*(int*)(message.volt2))++;
// Send message
ResponseStatus rs = e22ttl.sendMessage(&message, sizeof(Message));
// Check If there is some problem of succesfully send
Serial.println(rs.getResponseDescription());
}
//-----------------------------------------------------------------------
Maintaining a repository (or site or forum) is a lot like tending to a garden - it requires constant care and attention to keep it thriving. If you're a skilled gardener (or coder!) and want to help keep our repository blooming, we'd love to have you on board! We're also looking for talented writers and forum moderators to help us grow our community. Interested in joining our team? Don't hesitate to reach out and let us know how you can contribute!
Are you a fan of electronics or programming? Share your knowledge with others, write a simple tutorial or how to make a great project Contact me: share_your_ideas@mischianti.org