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