Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ****************************************************************************
- * *
- * Name : DHT11 Temperature and humidity digital sensor *
- * (cheap version of Sensirion SHT11) *
- * Author : saper_2 / nolin11 *
- * *
- * Checkout dht11.c for complete author & license inforamtion about this *
- * *
- **************************************************************************** */
- #ifndef _DHT11_DRIVER_H_
- #define _DHT11_DRIVER_H_
- struct DHT11_DATA {
- uint8_t rh; // integral part of RH
- uint8_t rhd; // decimal part of RH
- uint8_t temp; // integral part of temperature
- uint8_t tempd; // decimal part of temperature
- uint8_t csm; // checksum
- };
- // data line need a pull-up (4-10k - 5k1 is recomended)
- #define DHT_PORT PORTD
- #define DHT_PIN PIND
- #define DHT_DDR DDRD
- #define DHT_PN 3
- #define DHT_DATA_INT_SOURCE_NOT_USED 0
- #define DHT_DATA_INT_SOURCE_INT0 0
- #define DHT_DATA_INT_SOURCE_INT1 1
- #define DHT_DATA_INT_SOURCE DHT_DATA_INT_SOURCE_NOT_USED
- #define dht_data_in DHT_DDR &= ~(1<<DHT_PN);
- #define dht_data_out DHT_DDR |= (1<<DHT_PN);
- #define dht_data_hi DHT_PORT |= 1<<DHT_PN; dht_data_in;
- #define dht_data_lo DHT_PORT &= ~(1<<DHT_PN); dht_data_out;
- #define dht_get_data ((DHT_PIN & (1<<DHT_PN)) == (1<<DHT_PN))
- // init ports, interrupts, etc...
- void dht11_init(void);
- #define DHT11_READ_OK 0
- #define DHT11_READ_ERROR_CSM 1
- #define DHT11_READ_ERROR_START 2
- #define DHT11_READ_ERROR_ACK 3
- #define DHT11_READ_ERROR_ACK2 4
- #define DHT11_READ_ERROR_TIME 5
- #define DHT11_READ_ERROR_TIME2 6
- uint8_t dht11_read(uint8_t* data);
- //uint8_t dht11_read(void);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement