oop/2026-04-29/temphum/src/main.c (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#include "eval.c"
#include "gpio.c"
#include <stdio.h>
// pull low (at least 1ms)
// wait 20-40us
// sensor pulls low (80us)
// wait 80us
// data transmission:
//
// sensor pulls low (50us)
// data bit:
// 0 (26-28us)
// 1 (70us)
//
// 40 bits: (two's complement is used)
// 16 bits - RH (*10)
// 16 bits - T (*10 )
// 8 bits - checksum
int main() {
if (syn() != 0) {
printf("ERROR: couldn't send activation signal");
}
if (synack() != 0) {
printf("ERROR: couldn't check for sensor confirmation of activation");
}
if (read_data() != 0) {
printf("ERROR: couldn't read data");
}
if (eval_data() != 0) {
printf("ERROR: couldn't read data");
}
if (read_data() != 0) {
printf("ERROR: couldn't read data");
}
}
|