Hello
Iam using DHT22 sensor with arduino it works fine but this morning it returns just the -999 values for both Temprature and Humidity
Please does anybody have ana idea about that problem ?
Hello
Iam using DHT22 sensor with arduino it works fine but this morning it returns just the -999 values for both Temprature and Humidity
Please does anybody have ana idea about that problem ?
post your code!
The value -999 indicates there is an error.
Which version of the library are you using?
here's my code :
/**
* Example code for using a microchip mrf24j40 module to send and receive
* packets using plain 802.15.4
* Requirements: 3 pins for spi, 3 pins for reset, chip select and interrupt
* notifications
* This example file is considered to be in the public domain
* Originally written by Karl Palsson, karlp@tweak.net.au, March 2011
*/
#include <SPI.h>
#include <mrf24j.h>
#include <dht.h>
dht DHT;
#define DHT22_PIN 7
const int pin_reset = 6;
const int pin_cs = 52; // default CS pin on ATmega8/168/328
const int pin_interrupt = 5; // default interrupt pin on ATmega8/168/328
Mrf24j mrf(pin_reset, pin_cs, pin_interrupt);
long last_time;
long tx_interval = 1000;
void setup() {
SPI.setBitOrder(MSBFIRST) ;
SPI.setDataMode(SPI_MODE0);
SPI.begin();
Serial.begin(115200);
mrf.reset();
mrf.init();
mrf.set_pan(0x1234);
// This is _our_ address
mrf.address16_write(0x6002);
// uncomment if you want to receive any packet on this channel
mrf.set_promiscuous(true);
//uncomment if you want to enable PA/LNA external control
//mrf.set_palna(true);
// uncomment if you want to buffer all PHY Payload
mrf.set_bufferPHY(true);
attachInterrupt(pin_interrupt, interrupt_routine, CHANGE); // interrupt 0 equivalent to pin 2(INT0) on ATmega8/168/328
last_time = millis();
interrupts();
}
void interrupt_routine() {
mrf.interrupt_handler(); // mrf24 object interrupt routine
}
int H;
String str;
char HH[3];
void loop() {
mrf.check_flags(&handle_rx, &handle_tx);
unsigned long current_time = millis();
if (current_time - last_time > tx_interval) {
last_time = current_time;
uint32_t start = micros();
int chk = DHT.read22(DHT22_PIN);
uint32_t stop = micros();
// // DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.print(DHT.temperature, 1);
Serial.print(",\t");
Serial.print(stop - start);
Serial.println();
H=int(DHT.humidity);
str=String(H);
str.toCharArray(HH,3);
Serial.print(HH);
Serial.println();
Serial.println("txxxing...");
mrf.send16(0x6001, HH);
}
}
void handle_rx() {
Serial.print("received a packet ");Serial.print(mrf.get_rxinfo()->frame_length, DEC);Serial.println(" bytes long");
if(mrf.get_bufferPHY()){
Serial.println("Packet data (PHY Payload):");
for (int i = 0; i < mrf.get_rxinfo()->frame_length; i++) {
Serial.print(mrf.get_rxbuf()[i]);
}
}
Serial.println("\r\nASCII data (relevant data):");
for (int i = 0; i < mrf.rx_datalength(); i++) {
Serial.write(mrf.get_rxinfo()->rx_data[i]);
}
Serial.print("\r\nLQI/RSSI=");
Serial.print(mrf.get_rxinfo()->lqi, DEC);
Serial.print("/");
Serial.println(mrf.get_rxinfo()->rssi, DEC);
}
void handle_tx() {
if (mrf.get_txinfo()->tx_ok) {
Serial.println("TX went ok, got ack \n");
} else {
Serial.print("TX failed after \n ");Serial.print(mrf.get_txinfo()->retries);Serial.println(" retries\n");
}
}
Iam using DHTlib VERSION: 0.1.13
What is the value of the pullup resistor on the dht data pin?
I don't know how to get the value of the pullup resistor
digital multimeter, even a $5 one is good enough these days
or
read the color code on the resistor?
It was a leading question. I half expected a reply of "I don't have a pullup resistor". But, I guess there are many answers to any question.
So, let me ask, do you have a pullup resistor on the DHT data line?