I appreciate so much your help I still would like a bit of help in order to know if I could switch the part of my sketch which is encoding the float for the corresponding CayenneLPP encoding
// Prepare upstream data transmission at the next possible time.
// Read the analog value of the potmeter (0-1023)
potVal = analogRead(potPin);
// Write the value to the serial monitor
Serial.println(potVal);
// adjust for the f2sflt16 range (-1 to 1)
potVal = potVal/1023;
// Write AGAIN the value to the serial monitor
Serial.println(potVal);
// float -> int
// note: this uses the sflt16 datum (https://github.com/mcci-catena/arduino-lmic#sflt16)
uint16_t payloadPot = LMIC_f2sflt16(potVal);
Serial.println(payloadPot);
// int -> bytes
byte potLow = lowByte(payloadPot);
byte potHigh = highByte(payloadPot);
// place the bytes into the payload
payload[0] = potLow;
payload[1] = potHigh;
// prepare upstream data transmission at the next possible time.
// transmit on port 1 (the first parameter); you can use any value from 1 to 223 (others are reserved).
// don't request an ack (the last parameter, if not zero, requests an ack from the network).
// Remember, acks consume a lot of network resources; don't ask for an ack unless you really need it.
LMIC_setTxData2(1, payload, sizeof(payload)-1, 0);
Or should I use just the CayenneLPP library and drop the arduino-lmic? Because I’m watching the suggested example in here and I’m afraid I cannot combine both (CayenneLPP and arduino-lmic) because that CayenneLPP example is using also your
TheThingsNetwork.h library, is that right? I mean, I would have to rewrite the whole sketch? Could I fix my sketch just to use CayenneLPP and encode the payload in another different way?