Case 2.5 for Samsung IoT.
main.cpp
- Committer:
- kirborg
- Date:
- 2021-11-23
- Revision:
- 107:6057ba53c368
- Parent:
- 105:ed03c03b353e
File content as of revision 107:6057ba53c368:
#include "mbed.h"
#include "Sht31.h"
DigitalOut led1(LED1);
//sda, scl
Sht31 temp_sensor(I2C_SDA, I2C_SCL);
Thread thread, thread1;
bool alarm = false;
int extreme_humidity = 40;
void blink()
{
while (true)
{
led1 = !led1;
wait_ms (alarm ? 100 : 1000);
}
}
void sensor_thread()
{
float h;
while (true) {
h = temp_sensor.readHumidity();
printf(" %f\n\r", h);
wait_ms (1000);
if (h >= extreme_humidity)
{
printf("ALARM ALARM ALARM \n\r");
alarm = true;
}
else
{
alarm = false;
}
}
}
int main()
{
thread.start(sensor_thread);
thread1.start(blink);
}