Skip to content
Snippets Groups Projects
Commit 33a7f791 authored by Zhaoliang Zheng's avatar Zhaoliang Zheng
Browse files

try to query the variables but failed

parent 9afcba9a
Branches
No related merge requests found
......@@ -8,7 +8,9 @@ String success;
// Define variables to store BME280 readings to be sent
String strdata = "";
String valdata = "";
String quedata = "";
int count = 0;
double memory=0;
// Define variables to store incoming readings
String incomingStr = "";
......@@ -22,6 +24,7 @@ typedef struct struct_message {
String StrD;
double ValD;
String DebugM;
String QueM;
} struct_message;
// Create a struct_message to hold incoming sensor readings
......@@ -90,18 +93,27 @@ void loop()
strdata += char(inChar);
delay(10);
count +=1;
if (count == 3){
if (count == 3 && !isDigit(inChar)){
sentData.StrD = strdata;
Serial.println(sentData.StrD);
}
if (isDigit(inChar) || inChar == '.' || inChar == '-'){
valdata += char(inChar);
}
if (inChar == '?'){
quedata += char(inChar);
sentData.QueM = quedata;
}
if (inChar == '\n'){ //after message is sent
sentData.ValD = valdata.toDouble();
Serial.println(sentData.ValD);
if (valdata!=""){
// memory = valdata.toDouble();
sentData.ValD = valdata.toDouble();
valdata = "";
Serial.println(sentData.ValD);
sentData.QueM = "";
}
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &sentData, sizeof(sentData));
// esp_now_send(RxMACaddress, (uint8_t *) &sentData, sizeof(sentData));
//-------------------------------------------------------------------------------------
......@@ -110,7 +122,8 @@ void loop()
//-------------------------------------------------------------------------------------
delay(500);
strdata = "";
valdata = "";
// valdata = "";
quedata = "";
count = 0;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment