merhaba; iki adet lorayı tarama yontemi ile veriyi alıyorum .her hangi bir sorun yok . Ancak arduino mega bir sure sonra donuyor bu yuzden watcdog timer kullanmak zorunda kalıyorum. sizde de donma sorunu oldumu .donma sorunu ne olabilir teşekkurler . aşagıya kodun ozetini paylaşıyorum.derlediğim zaman hata vermiyor.
#include "LoRa_E32.h"<br />#include <avr/wdt.h><br />#include <SoftwareSerial.h><br />SoftwareSerial mySerial(52, 51); // using Arduino mega<br />LoRa_E32 e32ttl(&mySerial);<br />void printParameters(struct Configuration configuration);<br />void printModuleInformation(struct ModuleInformation moduleInformation);<br /> void setup()<br />{<br />wdt_enable(WDTO_8S);<br />Serial.begin(9600);<br />delay(50);<br />Serial1.begin(9600);<br />delay(50);<br />e32ttl.begin();<br />delay(50);<br /> Serial.println("start!!!!!!!!!!!!");<br /> }<br /> struct Message {<br />char message[8];<br />byte temperature[4];<br />} ;<br />struct MessageHumidity {<br />char message[8];<br />byte humidity;<br />} ;<br />byte Sensor = 0;<br />int delayy = 3500;<br /> int times;<br />boolean message_coming;<br /> const byte Address[2] = {1, 3}; //1, 3 address of sensors to be read<br /> void loop() {<br /> for (Sensor = 0; Sensor < 2 ; Sensor++) {<br /> scanner();<br />}<br />}<br /> void scanner() {<br /> ResponseStatus rs = e32ttl.sendFixedMessage( 0 , Address[Sensor] , 6 , "up" ); // Sensor scanning//&message, sizeof(Message)<br />Serial.println(rs.getResponseDescription());<br /> message_coming = true;<br />times = millis();<br />wdt_reset();<br /> while (message_coming) {<br /> if (millis() > times + delayy) {<br /> times = millis();<br /> message_coming = false;<br /> }<br />else<br />{<br /> if (e32ttl.available() > 1) {<br /> char type[5];<br />ResponseContainer rs = e32ttl.receiveInitialMessage(sizeof(type));<br />String typeStr = rs.data;<br />if (typeStr == "TEMP")<br />{<br />ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(Message));<br />struct Message message = *(Message*) rsc.data;<br /> rsc.close();<br />}<br />else if (typeStr == "HUM")<br />{<br /> ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(MessageHumidity));<br />struct MessageHumidity message = *(MessageHumidity*) rsc.data;<br />rsc.close();<br /> } else {<br />Serial.println("Something goes wrong!!");<br />}<br />}<br />}<br />}<br />}
Soru yeni cevaplara kapalıdır.
Mehmet En iyi cevap olarak seçildi Haziran 6, 2021
hocam kodu bana mail atar mısınız, derlenmiş halini bende kod hiç çalışmıyor.
Mehmet Yeni yorum gönderildi Mayıs 26, 2021
#include “LoRa_E32.h”
#include
#include
SoftwareSerial mySerial(52, 51); // using Arduino mega
LoRa_E32 e32ttl(&mySerial);
void printParameters(struct Configuration configuration);
void printModuleInformation(struct ModuleInformation moduleInformation);
void setup()
{
wdt_enable(WDTO_8S);
Serial.begin(9600);
delay(50);
Serial1.begin(9600);
delay(50);
e32ttl.begin();
delay(50);
Serial.println(“start!!!!!!!!!!!!”);
}
struct Message {
char message[8];
byte temperature[4];
} ;
struct MessageHumidity {
char message[8];
byte humidity;
} ;
byte Sensor = 0;
int delayy = 3500;
int times;
boolean message_coming;
const byte Address[2] = {1, 3}; //1, 3 address of sensors to be read
void loop() {
for (Sensor = 0; Sensor times + delayy) {
times = millis();
message_coming = false;
}
else
{
if (e32ttl.available() > 1) {
char type[5];
ResponseContainer rs = e32ttl.receiveInitialMessage(sizeof(type));
String typeStr = rs.data;
if (typeStr == “TEMP”)
{
ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(Message));
struct Message message = *(Message*) rsc.data;
rsc.close();
}
else if (typeStr == “HUM”)
{
ResponseStructContainer rsc = e32ttl.receiveMessage(sizeof(MessageHumidity));
struct MessageHumidity message = *(MessageHumidity*) rsc.data;
rsc.close();
} else {
Serial.println(“Something goes wrong!!”);
}
}
}
}
}