From 99f06ded7cb102c17975b32cc23529371c631711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20M=C3=89R=C3=89?= <48981596+STMaximeM@users.noreply.github.com> Date: Tue, 2 Jul 2019 16:50:35 +0200 Subject: [PATCH] Update HTS221.c: minor corrections I've added unistd.h witch contain read and sleep, data is now 4 byte long and I've added a second '%' line 180 to tell the preprocessor to display a '%' --- C/HTS221.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/C/HTS221.c b/C/HTS221.c index c5e34bf..7d2c72f 100644 --- a/C/HTS221.c +++ b/C/HTS221.c @@ -5,6 +5,7 @@ // https://www.controleverything.com/content/Humidity?sku=HTS221_I2CS#tabs-0-product_tabset-2 #include +#include #include #include #include @@ -42,7 +43,7 @@ void main() //Read 1 byte of data from address(0x30) char reg[1] = {0x30}; write(file, reg, 1); - char data[1] = {0}; + char data[4] = {0}; if(read(file, data, 1) != 1) { printf("Erorr : Input/output Erorr \n"); @@ -176,8 +177,8 @@ void main() float fTemp = (cTemp * 1.8 ) + 32; // Output data to screen - printf("Relative humidity : %.2f %RH \n", humidity); + printf("Relative humidity : %.2f %%RH \n", humidity); printf("Temperature in Celsius : %.2f C \n", cTemp); printf("Temperature in Fahrenheit : %.2f F \n", fTemp); } -} \ No newline at end of file +}