Пример #1
0
int dht_read(int pin, int* temp, int* humid) {
    // DHT sensors that come mounted on a PCB generally have
    // pull-up resistors on the data pin.  It is recommended
    // to provide an external pull-up resistor otherwise...
    int16_t t = 0;
    int16_t h = 0;
                 
    gpio_set_pullup(pin, false, false);

    if (!dht_read_data(pin, &h, &t)) return -1;
    printf("Humidity: %d%% Temp: %dC\n", h, t);
    *temp = t;
    *humid = h;
    return 0;
}
Пример #2
0
void dhtMeasurementTask(void *pvParameters)
{
    int16_t temperature = 0;
    int16_t humidity = 0;

    // DHT sensors that come mounted on a PCB generally have
    // pull-up resistors on the data pin.  It is recommended
    // to provide an external pull-up resistor otherwise...
    gpio_set_pullup(dht_gpio, false, false);

    while(1) {
        if (dht_read_data(dht_gpio, &humidity, &temperature)) {
            printf("Humidity: %d%% Temp: %dC\n", 
                    humidity / 10, 
                    temperature / 10);
        } else {
            printf("Could not read data from sensor\n");
        }

        // Three second delay...
        vTaskDelay(3000 / portTICK_RATE_MS);
    }
}
Пример #3
0
int8_t dht_read(struct dht *self, int8_t *temperature, int8_t *humidity) {
	return dht_read_data(self, temperature, humidity);
}