47 #define STATUS_REG_W 0x06
49 #define STATUS_REG_R 0x07
51 #define MEASURE_TEMP 0x03
53 #define MEASURE_HUMI 0x05
59 #define SHT_MEASURING_HUMID 1
60 #define SHT_MEASURING_TEMP 2
62 #if !defined SHT_DAT_GPIO || !defined SHT_SCK_GPIO
63 #error You need to define SHT_DAT_GPIO and SHT_SCK_GPIO
67 #define DATA_SET gpio_setup_input(SHT_DAT_GPIO)
68 #define DATA_CLR gpio_setup_output(SHT_DAT_GPIO)
70 #define DATA_IN gpio_get(SHT_DAT_GPIO)
74 #define SCK_SET gpio_set(SHT_SCK_GPIO)
75 #define SCK_CLR gpio_clear(SHT_SCK_GPIO)
101 for (i = 0x80; i > 0; i /= 2) {
122 for (i = 0x80; i > 0; i /= 2) {
124 if (
DATA_IN) { val = (val | i); }
171 for (i = 0; i < 9; i++) {
213 for (i = 0; i < 6665535; i++)
if (
DATA_IN == 0) {
break; }
258 const float C1 = -4.0;
259 const float C2 = 0.0405;
260 const float C3 = -0.0000028;
261 const float T1 = 0.01;
262 const float T2 = 0.00008;
272 t_C = t * 0.01 - 39.66;
273 rh_lin = C3 * rh * rh + C2 * rh +
C1;
274 rh_true = (t_C - 25) * (T1 + T2 * rh) + rh_lin;
275 if (rh_true > 100) { rh_true = 100; }
276 if (rh_true < 0.1) { rh_true = 0.1; }
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void humid_sht_init(void)
#define SHT_MEASURING_HUMID
void humid_sht_periodic(void)
#define DATA_SET
set data pin to input
Some architecture independent helper functions for GPIOs.
#define DATA_CLR
set data pin to output
uint8_t s_write_byte(uint8_t value)
uint8_t s_write_statusreg(uint8_t *p_value)
uint8_t s_read_measure(uint16_t *p_value, uint8_t *p_checksum)
void gpio_clear(uint32_t port, uint16_t pin)
Clear a gpio output to low level.
#define SCK_SET
set clock pin to high
uint8_t s_read_byte(uint8_t ack)
uint8_t s_start_measure(uint8_t mode)
#define SHT_MEASURING_TEMP
uint8_t humid_sht_reset(void)
#define DefaultChannel
SITL.
void calc_sht(uint16_t hum, uint16_t tem, float *fhum, float *ftem)
bool_t humid_sht_available
uint8_t s_read_statusreg(uint8_t *p_value, uint8_t *p_checksum)
Common code for AP and FBW telemetry.
void gpio_setup_input(uint32_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs.
#define SCK_CLR
set clock pin to low
void s_connectionreset(void)
uint8_t s_measure(uint16_t *p_value, uint8_t *p_checksum, uint8_t mode)
#define DATA_IN
get data pin
void gpio_setup_output(uint32_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.