![](/media/cache/profiles/9f0876a200701e5fdece2e58aa965574.jpg.50x50_q85.jpg)
Hello World program for HYT temp & humidity sensor
Hello Word program for HYT temp & humidity sensor library. MCU perform polling and then sends data to PC via serial interface once a second.
Connection
Remember to use pull-up resisrors to communicate with sensor by I2C
main.cpp
- Committer:
- Ksenia
- Date:
- 2016-09-14
- Revision:
- 0:cd8ba9e5f346
File content as of revision 0:cd8ba9e5f346:
#include "mbed.h" #include "HYT.h" Serial pc(USBTX, USBRX); Ticker timeKeeping; // for SLSTK3400A board HYT SENSOR (PD6, PD7); // sda, scl // for WIZwiki-W7500P board //HYT SENSOR (D14, D15); // sda, scl // for ATSAMD21-XPRO board //HYT SENSOR (PA08, PA09); // sda, scl // HYT sensor polling cycle void dataUpdate(void) { SENSOR.MRCommand(); wait_ms(100); SENSOR.DFCommand(); } void secondsCallback(void) { pc.printf("Humidity level: %.1f\r\n%", SENSOR.humidity); pc.printf("Temperature level: %.1f\r\n%", SENSOR.temperature); pc.printf("-------------------------------\r\n%", SENSOR.temperature); } int main() { timeKeeping.attach(&secondsCallback, 1.0f); while(1) { dataUpdate(); } }