Hi, previously I made a data transmission program from esp32 to another esp32 using LoRa, and using thinger io as the interface resulting from sending the sensor data.
Well before I tried to connect and send data to thinger io and it worked.
but now the data from esp32(receiver) not showing on thinger io.
and this is when i try again now
my code :
#include <LoRa.h>
#include <SPI.h>
#define ss 5
#define rst 14
#define dio0 2
#define THINGER_SERIAL_DEBUG
#include <ThingerESP32.h>
#include "arduino_secrets.h"
ThingerESP32 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
int rssi;
String LoRaMessage;
String jarak;
String sensorValue;
String sensorVoltage;
String tinggiAir;
String readingID;
// Replaces placeholder with Sensor values
String processor(const String& var){
//Serial.println(var);
if(var == "jarak"){
return jarak;
}
else if(var == "tinggiair"){
return tinggiAir;
}
else if(var == "sensorValue"){
return sensorValue;
}
else if (var == "RRSI"){
return String(rssi);
}
return String();
}
void setup() {
// open serial for debugging
Serial.begin(115200);
thing.add_wifi(SSID, SSID_PASSWORD);
while (!Serial);
Serial.println("LoRa Receiver");
int counter;
LoRa.setPins(ss, rst, dio0); //setup LoRa transceiver module
while (!LoRa.begin(433E6) && counter < 10) //433E6 - Asia, 866E6 - Europe, 915E6 - North America
{
Serial.println(".");
counter++;
delay(500);
}
LoRa.setSyncWord(0xA5);
Serial.println("LoRa Initializing OK!");
thing["SONIC"] >> [](pson& out){
out ["jarak"] = jarak;
};
thing["WaterLevel"] >> [](pson& out){
out ["tinggiAir"] = tinggiAir;
};
}
void loop() {
int packetSize = LoRa.parsePacket(); // try to parse packet
if (packetSize)
{
Serial.print("Received packet '");
while (LoRa.available()) // read packet
{
String LoRaData = LoRa.readString();
Serial.print(LoRaData);
int pos1 = LoRaData.indexOf('/');
int pos2 = LoRaData.indexOf('&');
readingID = LoRaData.substring(0, pos1);
jarak = LoRaData.substring(pos1 +1, pos2);
tinggiAir = LoRaData.substring(pos2+1, LoRaData.length());
}
Serial.print("' with RSSI "); // print RSSI of packet
Serial.println(LoRa.packetRssi());
}
thing.handle();
}