Hello, I'm sending INA219 sensor parameters through LoRa. On the receiver side, I received LoRaData in the format as shown in the picture or as code snippet below:
From the receiver, I want to send the LoRaData (Value1, Value2, Value3, Value4, Value5) to API. The sensor data will be sent every few seconds. I've tried using dummy data by putting hardcoded data (Value1, Value2, Value3, Value4, Value5), and it worked fine (data able to be sent successfully).
Can anyone advise how would be the code if I want to set/parse the LoRaData (Value1, Value2, Value3, Value4, Value5) automatically into the String serverPath ?
if (packetSize) {
//received a packet
Serial.println("Received packet\n ");
//read packet
while (LoRa.available()) {
LoRaData = LoRa.readString();
/*LoRaData format received:
Bus Voltage: value1 V
Shunt Volatge: value2 mV
Load Voltage: value3 V
Current: value4 mA
Power: value5 mW */
Serial.print(LoRaData);
}
}
//Send an HTTP POST request every 10 minutes
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
Thanks John ! I'll try your suggestion. But before that, how can we parse (Value1...Value5) from LoRaData (into Arduino sketch)?
Serial.print (LoRaData) will show (below) in Serial Monitor :
Bus Voltage: value1 V
Shunt Volatge: value2 mV
Load Voltage: value3 V
Current: value4 mA
Power: value5 mW
I'm trying to figure out, how can I get (Value1...Value5) from LoRaData into Arduino sketch so that it can be append into your suggestion code:
However, when I applied this code, the value reading duplicated until 5 times. To make things easier, instead of sending string data in 5 lines, I'm sending data like below:
You used the wrong character for the end of the label. Change it back to: String LoRaLabel = LoRa.readStringUntil(':');
Also, the 'Until' character is not included in the returned string so, for example, "Bus Voltage:" should be "Bus Voltage", like I had it in my example.