mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
Moisture: Add C Src and Example
Changed from GroveMoisture. Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
@ -114,6 +114,7 @@ add_example (ttp223)
|
||||
add_example (loudness)
|
||||
add_example (tsl2561)
|
||||
add_example (collision)
|
||||
add_example (moisture)
|
||||
|
||||
# Custom examples
|
||||
add_custom_example (nmea_gps_i2c-example-c nmea_gps_i2c.c nmea_gps)
|
||||
|
25
examples/c/moisture.c
Normal file
25
examples/c/moisture.c
Normal file
@ -0,0 +1,25 @@
|
||||
//Modified: Abhishek Malik <abhishek.malik@intel.com>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "moisture.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
moisture_context dev = moisture_init(14);
|
||||
int val;
|
||||
while(1){
|
||||
if(moisture_get_moisture(dev, &val) != UPM_SUCCESS){
|
||||
printf("Failed to get any values from the sensor\n");
|
||||
}
|
||||
printf("Moisture Value: %d\n", val);
|
||||
upm_delay(1);
|
||||
}
|
||||
moisture_close(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user