Wemos D1 mini & Wemos DHT shield

Hello, I try to setup my Wemos D1 mini with a Wemos DHT shield (temp/hum). Is there a sample project with these components? I am a little bit lost with all that different libraries for all that different sensors.

It get it working with Wemos D1 mini and a DS18B20, at least.

Greetings

first connect your wemos using this Adding a New Device using MQTT
and for DSB18B20 Converting Cayenne Arduino LIbrary sketches to Cayenne MQTT Arduino - #2 by rsiegel

1 Like

Thank you.
But that is already working. Withe the DSB18B20.

I donā€™t get it working with the Wemos DHT shield.

can you post the code.

This works for the DSB18B20.
But how can I address the DHT12 shield?
I have to include the #include <WEMOS_DHT12.h> library.
But I donā€™t now how to read the values and send it to cayenne.

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS D4

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

// WiFi network info.
char ssid = ā€œ";
char wifiPassword[] = "
**ā€;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = ā€œ*";
char password[] = "
ā€;
char clientID = ā€œ***********ā€;

unsigned long lastMillis = 0;

void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);

sensors.begin();
}

void loop() {
Cayenne.loop();
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
sensors.requestTemperatures();
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
//Cayenne.virtualWrite(0, millis());
// Some examples of other functions you can use to send data.
Cayenne.celsiusWrite(1, sensors.getTempCByIndex(0));
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(ā€œChannel %u, value %sā€, request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(ā€œError messageā€);
}

Hello, any ideas?

i have not worked with this shield and if you have any documentation about it we can try to solve the problem.

If you have the time, it would be cool to have a look here:

Are you able to get reading from the shield?

No. Sorry.
I tried a more easy setup.
Raspberry Pi 3 and the shield, but I donā€™t get it running.

try with wemos. it should work.

Hello Shramik, I used the WEMOS sketch and it works. I can read the values in the serial output.

#include <WEMOS_DHT12.h>

DHT12 dht12;

void setup() {

Serial.begin(115200);

}

void loop() {

if(dht12.get()==0){
Serial.print("Temperature in Celsius : ");
Serial.println(dht12.cTemp);
Serial.print("Temperature in Fahrenheit : ");
Serial.println(dht12.fTemp);
Serial.print("Relative Humidity : ");
Serial.println(dht12.humidity);
Serial.println();
}
delay(1000);

}

But how can I pass the variables to Cayenne?

Greetings

I used this:

Cayenne.celsiusWrite(1, dht12.cTemp);
Cayenne.virtualWrite(2, dht12.fTemp);
Cayenne.virtualWrite(3, dht12.humidity);

and it is working!

Thank you.

2 Likes