Adding reading dht22 temp to Sodaqtracker

Hi all,

I love sodaq tracker just to test the One, but I attached a dht22 sensor and I would like to use it in the Tracker scketch.

I defined the library and the pin , but how and where I read the sensor and how could I attach the temp to the hexadecimal message?

Many thank’s

Eduard

Short (stripped down) example for a DHT22 with https://github.com/adafruit/DHT-sensor-library.git and https://github.com/thesolarnomad/lora-serialization on a SODAQ ONE on Pin 10:

#include <LoraMessage.h>
#include <DHT.h>
#define DHTPIN 10
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  // init Lora here
}

void loop() {
  // Temperature
  float temperature = dht.readTemperature();
  log(F("Temperature:\t"))
  log(temperature, 1);
  logln(F("°C"));
  float humidity = dht.readHumidity();
  log(F("Humidity:\t"))
  log(humidity, 1);
  logln(F("%"));

  LoraMessage message;
  message
    .addTemperature(temperature)
    .addHumidity(humidity);
  uint8_t s = LoRaBee.send(1, message.getBytes(), message.getLength());
}

and then on the TTN side:

function Decoder(bytes, port) {
  return decode(
    bytes,
    [temperature,    humidity    ],
    ['temperature',  'humidity'  ]
  );
}

// Paste decoder.js from https://github.com/thesolarnomad/lora-serialization here