Hello! I’ve been using PietteTech_DHT library for my DHT22 before with great success, nothing weird, no problems. I’ve been trying the whole day to get it to work with a new Photon I bought and a DHT11, but to no avail. I only get readings when I remove the whole “if (!DHT.acquiring())” wrapper, but then it’s ofc broken and only publishes -5 degrees. i use Firmware and bootloader version 7.0. Greatly appreciate all help:) This is just one of mye example codes. Been trying to get Adafruits library to work as well but I have problems with the header file. Been trying so much now it’s too much to write.
Heres the code(sorry in advance lol):
// This #include statement was automatically added by the Particle IDE.
#include "PietteTech_DHT.h"
int temperature;
int humidity;
int blue = D3;
int LOOP_DELAY = 10000; // time is in ms
#define DHTTYPE DHT11 // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN D2 // Digital pin for communications
#define DHT_SAMPLE_INTERVAL 2000 // Sample every two seconds
void dht_wrapper();
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);
unsigned int DHTnextSampleTime;
bool bDHTstarted;
int n;
void setup() {
pinMode(blue, OUTPUT);
DHTnextSampleTime = 0;
}
void dht_wrapper() {
DHT.isrCallback();
}
void loop() {
if (millis() > DHTnextSampleTime) {
if (!bDHTstarted) {
DHT.acquire();
bDHTstarted = true;
}
if (!DHT.acquiring()) {
// get DHT status
int result = DHT.getStatus();
int humidity = DHT.getHumidity();
int tempc = DHT.getCelsius();
digitalWrite(blue, HIGH);
Particle.publish("Humidity", String(humidity));
Particle.publish("Temperature", String(tempc));
delay(250);
digitalWrite(blue, LOW);
n++;
bDHTstarted = false;
DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL;
}
}
delay(LOOP_DELAY);
}