I’ve an Arduino Uno R3 and a Dragino LoRa Shield. I can get the shield to communicate with nearby gateways and register the string “Hello World!” in the TTN console. I also have a DHT11 temp/humidity sensor. This sensor works with it’s own sketch when using a combination digital/analogue pin (A0 - A5).
In order to use the DHT11 the following is required:
dht.begin();
That little bit of code does the following according to the library:
void DHT::begin(uint8_t usec) {
// set up the pins!
pinMode(_pin, INPUT_PULLUP);
// Using this value makes sure that millis() - lastreadtime will be
// >= MIN_INTERVAL right away. Note that this assignment wraps around,
// but so will the subtraction.
_lastreadtime = millis() - MIN_INTERVAL;
DEBUG_PRINT("DHT max clock cycles: ");
DEBUG_PRINTLN(_maxcycles, DEC);
pullTime = usec;
}
Now, the issue: As soon as I initialise the sensor with dht.begin(); the program on the arduino either hangs, or starts loading the readTemperature variable with “corrupt” data. Changing between any of the combination digital/analogue pins doesn’t seem to make a difference. Running dht.begin(); then a temperature query, then pinMode(A0,LOW); then allowing the program to continue doesn’t seem to help.
I can run the sensor via the analogue pins on the Dragino board, providing I do not load any of the dragino libraries. To be more specific, putting the following at the top of void setup() results in the same issues.
dht.begin(); //This is the troublemaker.
float temperature = dht.readTemperature();
Serial.print("Temperature: "); Serial.print(temperature);
I’m using the latest official DHT sensor library by Adafruit, though I suspect this isn’t the issue.
Any bright ideas on how to read this sensor with the Dragino LoRa shield?
Board: Arduino Shield featuring LoRa® technology
LMIC Library by MCCI: GitHub - mcci-catena/arduino-lmic: LoraWAN-MAC-in-C library, adapted to run under the Arduino environment version: latest
DHT11 sensor library: GitHub - adafruit/DHT-sensor-library: Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors v1.3.10