Please include the following information, in order for us to help you as effectively as possible.
-
What product do you wish to discuss? RAK4631, RAK3372, RAK11200, RAK11310, RAK11722?
-
What firmware are you using? VSCode/PlatformIO
-
What firmware version?
-
Computer OS? (MacOS, Linux, Windows) Windows
-
What Computer OS version? Windows 11
-
How often does the problem happen? it is not a problem
-
How can we replicate the problem? yes I can replicate
-
Provide source code if custom firmware is used or link to example if RAKwireless example code is used.
Good morning,
I am using CayenneLPP to pack the sensors(RAK1904, RAK1906, RAK5801 and RAK12500) values read and library SX126x-Arduino to send the LPP package to LoRa Server.
I am using “Radio.Send”(from Radio.h in teh SX126x folder) but it is not working as I was expecting, I mean the LPP package is not being sent.
Could you help me to find the correct function and the way to send the LPP package?
Regards,
Claudio
PackPayload.h
#include <Arduino.h>
#include <CayenneLPP.h>
#include <SX126x-Arduino.h>
float celsius = -4.1;
float accel[] = {1.234, -1.234, 0};
float rh = 30;
float hpa = 1014.1;
float latitude = 42.3519;
float longitude = -87.9094;
float altitude = 10;
// Low Power Payload object - LPP
CayenneLPP LPP(MAX_SIZE);
uint8_t size = 0;
extern struct Acel
{
public:
float EixoX;
float EixoY;
float EixoZ;
float Movimento[3];
} RAK1904;
extern struct Ambiental
{
public:
float Temperatura = 0;
float PressAtm = 0;
float Humidade = 0;
float ResistenciaAr = 0;
} RAK1906;
extern struct GeoLocalizacao
{
public:
float Latitude = 0; // latitude em graus
float Longitude = 0; // Longitude em graus
float Altitude = 0; // Altitude em metros
float Acuracia = 0; // índice de precisão
float HDop = 0; // dispersão horizontal
float Velocidade = 0; // Velocidade em m/s
float Direcao = 0; // Direção em graus
uint8_t sats = 0; // número de satélites
} RAK12500;
void Empacota();
extern void LoRaEnvia();
PackPayload.cpp
#include <PackPayload.h>
void Empacota()
{
LPP.reset();
size = LPP.addTemperature(0, celsius);
if (size == 0) {
// not enough byte left to add the data
}
else {
// add function returned current payload size
}
LPP.addAccelerometer(113,RAK1904.EixoX,RAK1904.EixoY,RAK1904.EixoZ);
LPP.addTemperature(7, RAK1906.Temperatura);
LPP.addRelativeHumidity(6, RAK1906.Humidade);
LPP.addBarometricPressure(8, RAK1906.PressAtm);
LPP.addGPS(10, RAK12500.Latitude, RAK12500.Longitude, RAK12500.Altitude);
// Call LoRaWAN library to send the frame
Radio.Send(LPP.getBuffer(), LPP.getSize());
}