bugfix RH03 sensor
This commit is contained in:
parent
310234e0dc
commit
7b46026b52
|
@ -141,7 +141,7 @@ info_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_
|
|||
|
||||
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
||||
// jSON Format
|
||||
index += sprintf(message + index,"{\n \"version\" : \"V0.4\",\n");
|
||||
index += sprintf(message + index,"{\n \"version\" : \"V0.4.1\",\n");
|
||||
index += sprintf(message + index," \"name\" : \"6lowpan-climate\"\n");
|
||||
index += sprintf(message + index,"}\n");
|
||||
|
||||
|
@ -691,7 +691,9 @@ hw_init()
|
|||
ds1820_temp();
|
||||
#endif
|
||||
#if REST_RES_DHT11
|
||||
//DHT_INIT();
|
||||
DHT_Read_Data(&dht11_temp, &dht11_hum);
|
||||
// DHT_Read_Data(&dht11_temp, &dht11_hum);
|
||||
#endif
|
||||
}
|
||||
#define MESURE_INTERVAL (20 * CLOCK_SECOND)
|
||||
|
@ -801,6 +803,7 @@ PROCESS_THREAD(rest_server_example, ev, data)
|
|||
PRINTF("Periodic\n");
|
||||
etimer_reset(&ds_periodic_timer);
|
||||
#if REST_RES_DHT11
|
||||
// DHT_Read_Data(&dht11_temp, &dht11_hum);
|
||||
DHT_Read_Data(&dht11_temp, &dht11_hum);
|
||||
#endif
|
||||
#if REST_RES_DS1820
|
||||
|
|
|
@ -46,22 +46,15 @@ uint8_t DHT_Read_Data(uint16_t *temperature, uint16_t *humidity){
|
|||
sreg = SREG; /* Save status register before disabling interrupts. */
|
||||
cli(); /* Disable interrupts. */
|
||||
|
||||
//Prepare the bus
|
||||
PIN_INIT();
|
||||
//Set pin Output
|
||||
//Pin High
|
||||
DHT_DRIVE();
|
||||
// mdelay(250); //Wait for 250mS
|
||||
mdelay(100); //Wait for 100mS
|
||||
|
||||
//Send Request Signal
|
||||
//Pin Low
|
||||
OUTP_0(); //20ms Low
|
||||
#if DHT11
|
||||
mdelay(20);
|
||||
#else
|
||||
udelay(500);
|
||||
#endif
|
||||
//Pin High
|
||||
OUTP_1();
|
||||
udelay(40); //40us High
|
||||
|
@ -74,6 +67,9 @@ uint8_t DHT_Read_Data(uint16_t *temperature, uint16_t *humidity){
|
|||
//Repeat for each Transistions
|
||||
for (i=0; i<MAXTIMINGS; i++) {
|
||||
//While state is the same count microseconds
|
||||
// led1_on();
|
||||
// led1_off();
|
||||
|
||||
while (laststate==DHT_INP()) {
|
||||
udelay(1);
|
||||
counter++;
|
||||
|
@ -90,17 +86,14 @@ uint8_t DHT_Read_Data(uint16_t *temperature, uint16_t *humidity){
|
|||
//Shift data[] value 1 position left
|
||||
//Example. 01010100 if we shift it left one time it will be
|
||||
//10101000
|
||||
// led1_on();
|
||||
|
||||
data[j/8]<<=1;
|
||||
if (counter >= 15) { //If it was high for more than 40uS
|
||||
// led1_off();
|
||||
// led1_on();
|
||||
data[j/8]|=1; //it means it is bit '1' so make a logic
|
||||
// led1_on();
|
||||
// led1_off();
|
||||
} //OR with the value (save it)
|
||||
j++; //making an OR by 1 to this value 10101000
|
||||
// led1_off();
|
||||
|
||||
} //we will have the resault 10101001
|
||||
//1 in 8-bit binary is 00000001
|
||||
//j/8 changes table record every 8 bits which means a byte has been saved
|
||||
|
|
Loading…
Reference in a new issue