From 7b46026b5200a943238bffa6875afb010047af0b Mon Sep 17 00:00:00 2001 From: harald42 Date: Tue, 12 Nov 2013 13:27:13 +0100 Subject: [PATCH] bugfix RH03 sensor --- examples/osd/climate/er-example-server.c | 5 ++++- platform/osd-merkur/dev/dht11.c | 23 ++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/examples/osd/climate/er-example-server.c b/examples/osd/climate/er-example-server.c index d4a3042f7..7ece0598b 100644 --- a/examples/osd/climate/er-example-server.c +++ b/examples/osd/climate/er-example-server.c @@ -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 diff --git a/platform/osd-merkur/dev/dht11.c b/platform/osd-merkur/dev/dht11.c index 8ab1d28cd..c163feb6b 100644 --- a/platform/osd-merkur/dev/dht11.c +++ b/platform/osd-merkur/dev/dht11.c @@ -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 + mdelay(20); //Pin High OUTP_1(); udelay(40); //40us High @@ -74,7 +67,10 @@ uint8_t DHT_Read_Data(uint16_t *temperature, uint16_t *humidity){ //Repeat for each Transistions for (i=0; i254) break; @@ -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