Analogue sensor input with Dragino Node for Uno results in NaN or Freeze

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

The DHT11 is a digital sensor.

Please specify (post a link) which Dragino board you are using and provide a link to the instructions you use to load the LoRaWAN software so we know which version. Also specify which DHT11 library you are using as there are a number of them.

Good points. I’ve edited for clarity.

Given the other thread you have about getting the LMIC going, I think you’re trying to much to quickly.

If you look at http://wiki.dragino.com/index.php?title=Lora_Shield#Pin_Mapping_and_Unused_Pins you’ll see you could attach the DHT on any of 3, 4 or 5 - it’s a three wire device that needs power, gnd and data, so you should only be using one of the data pins.

Get that working with one of the Adafruit examples first, both of which have it setup for pin 2, which you absolutely can’t use with the Dragino shield, so make sure you change it.

Then we can give you some pointers on integrating it with some LMIC.