DHT11, DHT22 Sensors

@micho111 here is a link to some code that @Ian used to get his dht11 online and working.

Once you get going, don’t forget about our project submission contest going on right now!

Cheers,

-B

Woohoo! Look at you go!

As always, keep us all updated with your progress and reach out if you need help with anything. There are guys on the Cayenne community ready to help out. (And much smarter than me :slight_smile: )

Talk soon,

-B

Benny, if I wanted to send one of the community members code to a project, how do I do it?
I tried to copy and paste the code into a reply to his message and it showed up in a couple of different fonts and random parts of the code were gone.

You can highlight it all and click the pre-formatted text button at the top of the box. It looks like </>

1 Like

I’m also looking forward to the dht support. Have been using a pi for 3 years with mrtg and thingspeak with several dht22’s and just came across and immediately installed cayenne!
Jon Q

As I am new to the all stuff, based on your experiences, do you think that with Arduino, Cayenne and DHT_Cay.txt code can I hang several (multiple) DHT22 sensors and make a viable automation project? I need several DHT sensors in the project.
Bestes, pls add me on the list.
thanks

Welcome to Cayenne!

There are 2 options now. You can use Arduino and make custom code to send the values to the dashboard (scroll up for that) or you can also now do it with the Pi using MQTT. http://www.cayenne-mydevices.com/docs/#bring-your-own-thing-api

Hi Adam,

I hope you are very well, I saw that now we can add the DHT11 with Raspberry Pi, that is a great knew, I tried to find some videos that help me to understand how could I add this client (DHT11), do you know if there is any information about it?.

Thanks in advance.

Hey, so, i know I’m the 1billionth person to ask… But will this be supposed under “sensors” soon? I REALLY would love this and it seems like you’ve been saying its in the pipeline for a long while…

It’s possible now with Node-RED/MQTT. I’ll make something up here in the next few days. If you want to try to figure it out on your own here is all the info you will need:

So install the node-red-contrib-dht-sensor node then put that node in to an mqtt output node with all your Cayenne credentials and it will show up on the dashboard.

@craigfrancissfco @israelmx @copperslov @jquiros @chris.wood @woz @pallottamrc @jrustling @mikejunor_cayenne @ravter

Hi guys,

@adam created a great tutorial for adding the DHT11 / 22 sensor to the Cayenne dashboard using the Cayenne MQTT API. I realize this is probably not what you had in mind, but you can now read data from your DHT11 sensors, and send the values to Cayenne from the Raspberry Pi! I’m hoping you will give it a try, here is the post you can reference:

@Christian @lobopt @somnet @roccodegrazia @linux87s @glasermrk @adytoader @raspberrycoulis @marthinus.swanepoel @mase.hacker

Hi guys,

@adam created a great tutorial for adding the DHT11 / 22 sensor to the Cayenne dashboard using the Cayenne MQTT API. I realize this is probably not what you had in mind, but you can now read data from your DHT11 sensors, and send the values to Cayenne from the Raspberry Pi! I’m hoping you will give it a try, here is the post you can reference:

@hiren.shah @nicolasortuzari @faljeremy @brucecalder @timwellington @mat_oldaker @will @Mr.Allen @dzachareas @maurifree

Hi guys,

@adam created a great tutorial for adding the DHT11 / 22 sensor to the Cayenne dashboard using the Cayenne MQTT API. I realize this is probably not what you had in mind, but you can now read data from your DHT11 sensors, and send the values to Cayenne from the Raspberry Pi! I’m hoping you will give it a try, here is the post you can reference:

Hi Bestes,

Great, thank you so much, just wonder if with the MQTT API we could see the widgets in iOS?, I know for sure that the web page will be, but not sure in the app, because I was playing with the ESP8266 and the MQTT API does not shows the widget in iOS but in the web does.

Have a great evening.

You’re right, the apps do not have support for mqtt yet. It’s coming.

Another DHT11 request please!

Thanks,

And IFTTT support please.

Adding myself to the list. Did my best to use other examples for manually adding dht11, but I’m afraid that creating Arduino sketches is a bit above my head. Would be nice if the dht could just be added in the dashboard the way I added my actuators - that was pretty straightforward.

Hi, thank you for the great apps.
Connected like a charm, even do not ask a password :slight_smile:

Could you please send docs for put custom data from DHT22 to Cayenne?

Thank you.

This Works with NodeMcu with DHT22
You will have to remove all the / from the #include lines, I put them in so it displays here correctly. This is not my code, I pulled it out of another sketch after hours of pulling my hair out.

/#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space

/#include <ESP8266WiFi.h>
/#include “CayenneDefines.h”
/#include “BlynkSimpleEsp8266.h”
/#include “CayenneWiFiClient.h”
/#include <DHT.h>
/#define DHTTYPE DHT22
/#define DHTPIN 4 //NODEMCU D2
/#define VIRTUAL_PIN V1
/#define VIRTUAL_PIN V2

DHT dht(DHTPIN, DHTTYPE, 20);
float humidity, temp_c;

long lastTempUpdate = 0;

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “TOKEN”;

// Your network name and password.
char ssid = “YOUR SSID HERE”;
char password = “WIFI PASSWORD”;

IPAddress ip;

void setup()
{

Serial.begin(230400);
Cayenne.begin(token, ssid, password);
dht.begin();

}

// ==============( Void Loop ) ====================================

void loop() {
Cayenne.run();
unsigned long now = millis();
if ( now - lastTempUpdate > 60000 ) {

gettemperature();
Serial.print("Sending temperature:");
Serial.println(temp_c);
Serial.print("Sending humidity:");
Serial.println(humidity);
lastTempUpdate = now;

}

}

void gettemperature() {

humidity = dht.readHumidity();          // Read humidity (percent)
temp_c = dht.readTemperature();     // Read temperature as Farenheight


// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temp_c)) {
  Serial.println("Failed to read from DHT sensor!");
  return;
}
String TempC;
String Humid;
TempC = String(temp_c);
Humid = String(humidity);
Cayenne.virtualWrite(V1, temp_c);
Cayenne.virtualWrite(V2, humidity);

}

1 Like

Requesting support as well. Love Cayenne!!!