Dht_u.h Library Download

0 views
Skip to first unread message

Práxedes Jamal

unread,
Aug 3, 2024, 5:05:24 PM8/3/24
to dremrodogpa

DHT_U is old stuff and deprecated, according to _DHT_Unified. So, unless "someonelse" is calling a very specific part of the library on the code that you have, its not necessary and can be replaced just by Adafruits DHT.h library.

This is the completed program for the DHT11 Temperature and Humidity Sensor. As you can see we included two libraries, DHT.h and DHT_U.h. We are using the library to read the temperature and humidity out of the sensor.

In the setup function, we are setting up the serial communication with Serial.begin(9600). After that, we are initializing the library with dht.begin. You can look more about the DHT library at -sensor-library

In the loop function, we are first starting off by delaying for 2 seconds. We are reading the temperature using the dht.readTemperature using the library. This gives the tempreture in Celsius. Later we converted the temperature from Celsius to Fahrenheit using the formula F=C*9/5+32. We are also reading the humidity using the dht.readHumidity function.

I am installing Arduino IDE in a new PC and uploaded a code with DHT sensor that was compiled and working in another PC. The same happens with your DHT11 scketch code.
In this new one when code is compiled I received many erros specially saying that DHT.h does not exists.
I tried many different DHT libraries, for github ( -sensor-library) and from Arduino webpages and others that I found but no one worked.

The Adafruit library is the one that I use (but there are MUCH better sensors than any of the DHT range).
However, it also requires this library to be installed:
GitHub adafruit/Adafruit_SensorCommon sensor library. Contribute to adafruit/Adafruit_Sensor development by creating an account on GitHub.

You need to install the Adafruit Unified Sensor driver library. In your Arduino IDE, type in the search box Adafruit Unified Sensor, scroll all the way down to find the library and install it.

Writing the code to get temperature and humidity is also simple thanks to the DHT library. Getting temperature and humidity readings is as simple as using the readTemperature() and readHumidity() methods.

Easiest way is to hook it up to a ESP8266 (ESP-12 or similar) and use Arduino IDE for ESP8266. You can just run a small web server that dishes out the DHT info. I do it (currently d18b20) with an additional attached Relay so I can control heating. Pretty much done away with Arduinos for my projects. Too expensive total cost.

One more unstable issue is delay() method operation. From time to time it starts to work with falce delay interval much less than requested by parameter of the method. Usually it turns into normal opreation after a few minutes ubnormality.

Affiliate Disclosure: Random Nerd Tutorials is a participant in affiliate advertising programs designed to provide a means for us to earn fees by linking to Amazon, eBay, AliExpress, and other sites. We might be compensated for referring traffic and business to these companies.

It looks like your node does not join TTN. There are several possible reasons, most common is AppEUI, DevEUI and AppKey not matching the application credentials (possibly because of wrong byte ordering). If you want an answer and not just a load of speculation you need to post (a pointer) to the exact code you are using, and a pointer to the exact version of the stack. (Site and version)

In your screen shots you are using ABP mode while the code is for OTAA. Change the device so the activation method in the code and on TTN match. I would suggest to switch the device back to OTAA in the TTN console.

@cslorabox
Thank you for your answer
I have test many libs and i get every time no data in the sensor option only the message in the gateway info
I only want for my first steps the sx1276 with arduino pro mini 3,3v and dht22 or ds18b20 sensor for making a chep solar powered sensor node. Maybe you can send me a link for a good working lib and code that would be great

Are the EUIs and the AppKey the same? Did you check on the correct byte order to enter them in the code? (In the TTN gateway page you can see both EUIs when an OTAA request is received, do those match the information on the device page?)

To start with, use the examples ttn-abp.ino and ttn-otaa.ino that are included with the LMIC library that you are using.
To prevent running into version incompatibilities: use the examples included with your library and do not use examples from a different version of the same library or from a different library/repository.

As @cslorabox and @descartes already mentioned you may quickly run out of memory when using MCCI LMIC with ATmega328 MCU boards like a Pro Mini (when doing anything more than bare basics). If so then the older Classic LMIC may be a good alternative.
(That said, memory size is probably unrelated to your current issue.)

ps. i know the TTN fair use policy i have only for my short test used the 7 seconds but i now leave it at 60 seconds and i never will use so much traffic i only want sensor nodes for 2-6 data transfers per day. so all good

This was often needed for ATmega328 to fix timing issues when using Classic LMIC or older versions of MCCI LMIC.
To my understanding use of LMIC_setClockError() should not be needed with recent versions of MCCI LMIC but I may be mistaking and have not tested this myself.

Now i am able to send the Temp and Humidity to TTN and see the payload and the Values but when i test it to send to my ThingSpeak Account then the Values are not correct because the payload must be in a ThingSpeak Format. Maybe anybody know how i format i correct !?

Hello, I am attempting to program my ESP32 using the Arduino IDE to read temperature and humidity data and report back to my Android phone via RemoteXY app. I have installed the RemoteXY library. I have semi-successfully got it working using esp32 in AP mode, although for some reason the wifi signal is VERY low.. phone needs to be directly next to esp32 device. Trying to instead connect via bluetooth, I changed "#define REMOTEXY_MODE_ESP32CORE_WIFI_POINT" to, "#define REMOTEXY_MODE__ESP32CORE_BLE" and ended up getting the compile error: "#error RemoteXY mode does not defined or defined error: REMOTEXY_MODE__XXXXXXX"

Doing some googling lead me to this forum and a link to a modified version of the RemoteXY library that I supposedly needed to use, but after replacing with that library, the compile error remained. This is the forum post: =689 I looked into the .h file and noticed the #define should read "REMOTEXY_MODE__ESP32_BT" or "REMOTEXY_MODE__ESP32_BLE" depending on which type of BT I want to use. I still get the same compile error. I have tried restarting the arduino IDE software to make sure that wasn't the problem. I can't figure out what to try next. Any suggestions?

Thank you, I didn't know that would make a difference! Would someone happen to know why the RemoteXY app kicks me out of my remote session after a little while? Only works for maybe 30 seconds at a time.. even after purchasing the paid app. then it just quits out to the remote list. Did this using WiFi also. Might have to do with my low signal.. is there a way to change signal strength or channeling within this library?

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

I am experiencing trouble in sending the actual sensor values to Thingspeak. I use a code template that I downloaded from a github repository -arduino/tree/master/examples/ESP32/WriteMultipleFields. The main issue is that I don't know how to fill out the source code to get real sensor values instead of random values.

How should I name my sensor variables? Can I figure it out by looking at the library of the sensor in question? In this DHT sensor case I should probably check them from DHT_U.h (DHT Unified Sensor) library, at home/(name)/.arduino/libraries. I looked for a proper variable declaration from the file, and after trial and error I found dht.temperature().getEvent(&event); and dht.humidity().getEvent(&event); to be valid, i.e. not unknown nor erroneous according to the Arduino IDE compiler. However, with these variables I seem to get only number ones (1) as sensor values to my Thingspeak channel (check the image). So I am still trying to find sensor variables that give me the real, measured sensor values.

I'm not 100% sure of the dht syntax there, but if its correct, that says to read the present temperature. You want to read the temperature in each loop, not just at initialization. However, I bet the sensor isn't even warmed up then, which is perhaps why you get the value of 1. I'm not sure why the value isn't increasing in each loop, but it could be because it is a float type and not an integer. ++ operator isn't defined for float types.

but the compiler would always return an apparently insurmountable error message as follows: "void value not ignored as it ought to be." For some reason, I got it through when I changed the "sensors" to "events". However, the "events" appear to give me only the value of 1. And they seem to do so irrespective of whether the commands are inside the loop or not.

For this first project we will be using an Arduino + Ethernet Shield + DHT11 sensor for reading temperature and humidity. But you can use any other device like an Adafruit CC3000, Texas Instrument CC3200, Arduino Wifi, Arduino Yun, or even a simple ESP8266. There are some basic examples for all those devices.

For this project we can use the EthernetShield example provided in the thinger.io library. You can open this example at File > Examples > thinger.io > ArduinoEthernet. You should see a very basic example like this shown below (may vary depending on the library installed):

This sketch is a very basic example that allows reading the millis function of our Arduino (very similar as we will be reading the temperature and humidity from DHT11) and providing some other input and output examples. Please note that there is a variable called thing of ThingerEthernet class. This instance takes some parameters, that are the USERNAME, DEVICE_ID, and DEVICE_CREDENTIAL. You must change this default values with the username you used at login, the device identifier you choose in the device register process, and its device credential.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages