Wemos D1 mini & Wemos DHT shield


#1

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


#2

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


#3

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

I don’t get it working with the Wemos DHT shield.


#4

can you post the code.


#5

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”);
}


#6

Hello, any ideas?


#7

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


#8

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


#9

Are you able to get reading from the shield?


#10

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


#11

try with wemos. it should work.


#12

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


#13

I used this:

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

and it is working!

Thank you.