First I love all the great work here and the great stable connection from the BLE gateway. Thank you !
Now I’m trying to make a custom arduino LoRa sensor for the LoRa gateway, but after several days trying I cannot make it work .
- I used option 1, uploading from the web with the ttgo-lora32-v1-868 environment. (I also used option 2, uploaded by VSC, but I don’t see any difference for my settings)
- for the gateway I use the TTGO 868 V1.0 version, for the sender I use the TTGO 868 V1.6 version (versions)
- for the sender I use a BME280 sensor.
In the Serial monitor from the sender i get the following data format:
{“tempc”:20.5,“hum”:47.6,“pres”:1026.7}
In the “home/OpenMQTTGateway_ESP32_LORA/LORAtoMQTT” MQTT topic i get the following data format:
{“rssi”:-44,“snr”:0.75,“pferror”:-15275,“packetSize”:39,“hex”:“BB22B8593E69C3223A7E242C35AC2BF8ED6DE2F6380EBE2FB9AA395E6D77222AF1F09A162A397C”}
What am I doing wrong, someone has a idea?
I used the following sketch for the sender:
#include <Wire.h>
#include <LoRa.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <ArduinoJson.h> // Include the ArduinoJson library
#define SDA 21
#define SCL 22
#define LORA_SCK 5
#define LORA_MISO 19
#define LORA_MOSI 27
#define LORA_SS 18
#define LORA_RST 23
#define LORA_DI0 26
Adafruit_BME280 bme;
void setup() {
Wire.begin(SDA, SCL);
Serial.begin(115200);
while (!Serial);
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_SS);
LoRa.setPins(LORA_SS, LORA_RST, LORA_DI0);
LoRa.enableCrc();
LoRa.setSyncWord(0x12);
if (!LoRa.begin(868E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("LoRa sender module started!");
}
void loop() {
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F;
char tempStr[10];
char humStr[10];
char presStr[10];
dtostrf(temperature, 4, 1, tempStr);
dtostrf(humidity, 4, 1, humStr);
dtostrf(pressure, 6, 1, presStr);
String jsonData = "{\"tempc\":";
jsonData += String(tempStr);
jsonData += ",\"hum\":";
jsonData += String(humStr);
jsonData += ",\"pres\":";
jsonData += String(presStr);
jsonData += "}";
Serial.println(jsonData);
LoRa.beginPacket();
LoRa.print(jsonData);
LoRa.endPacket();
delay(10000);
}