TTN Lora device with Cayenne DHT22 sensor data

Hi

I would like to see my DHT22 data in Cayenne.
I am using The Things Uno board. I have connected DHT22. I have
It is working correctly in TTN. Showing the dynamic sensor data. Temperature and Humidity.

Also I have tested arduino-device-lib/CayenneLPP.ino at master · TheThingsNetwork/arduino-device-lib · GitHub
It is working correctly in TTN and it shows static values in Cayenne Dasboard.

I don’t know how to adapt this sketch to combine previous sketch with CayenneLPP sketch.
void loop()
{
debugSerial.println(“-- LOOP”);

//lpp.reset();
lpp.addTemperature(1, 22.5);
lpp.addRelativeHumidity(2, 80.21);
lpp.addGPS(3, 52.37365, 4.88650, 2);

I need help…

you just need to send the DHT data in cayenne lpp format:

  float t = dht.readTemperature();
  lpp.addTemperature(5, t);

Thank you. I am almost there!
I have changed the sketch:

void loop()
{
debugSerial.println(“-- LOOP”);

TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);
CayenneLPP lpp(51); // create a buffer of 51 bytes to store the payload

float t = dht.readTemperature();
lpp.addTemperature(1, t);

float h = dht.readHumidity();
lpp.addRelativeHumidity(2, h);

ttn.sendBytes(lpp.getBuffer(), lpp.getSize());
delay(10000);
}
Values are sent TTN and Cayenne.
Cayenne shows incorrect values:


and sometimes 0 values.

do what you know what is wrong?

Add debug lines in your code to check that you are getting correct reading from DHT first.

How do I do that?
Can you give me debug lines example?

this is a debug line which prints out to the serial monitor.

Thank you…solved.

19:39:25.688 → Sending: mac tx uncnf 1 01670102026854
19:39:27.825 → Successful transmission
19:39:37.818 → – LOOP
19:39:37.853 → 25.30
19:39:37.853 → 43.10

I have added dht.begin(); in the void setup() section.
I was forgottten.
normal values , see below screenshot.
image

2 Likes