mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +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:
@ -142,7 +142,7 @@ add_example (adc121c021)
|
||||
add_example (ds1307)
|
||||
add_example (a110x)
|
||||
add_example (gp2y0a)
|
||||
add_example (grovemoisture)
|
||||
add_example (moisture)
|
||||
add_example (groveehr)
|
||||
add_example (ta12200)
|
||||
add_example (grovelinefinder)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include "grovemoisture.hpp"
|
||||
#include "moisture.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -43,8 +43,8 @@ int main ()
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
// Instantiate a Grove Moisture sensor on analog pin A0
|
||||
upm::GroveMoisture* moisture = new upm::GroveMoisture(0);
|
||||
// Instantiate a Moisture sensor on analog pin A0
|
||||
upm::Moisture* moisture = new upm::Moisture(0);
|
||||
|
||||
// Values (approximate):
|
||||
// 0-300, sensor in air or dry soil
|
@ -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;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ add_example(GroveLEDSample grove)
|
||||
add_example(LightSample light)
|
||||
add_example(GroveLineFinderSample grovelinefinder)
|
||||
add_example(GroveMDSample grovemd)
|
||||
add_example(GroveMoistureSample grovemoisture)
|
||||
add_example(MoistureSample moisture)
|
||||
add_example(GroveMQ3 gas)
|
||||
add_example(GroveMQ9 gas)
|
||||
add_example(O2Example o2)
|
||||
|
@ -22,10 +22,10 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveMoistureSample {
|
||||
public class MoistureSample {
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grovemoisture.GroveMoisture gm = new upm_grovemoisture.GroveMoisture(1);
|
||||
upm_moisture.Moisture gm = new upm_moisture.Moisture(1);
|
||||
|
||||
while (true) {
|
||||
int moisture_val = gm.value();
|
@ -23,10 +23,10 @@
|
||||
*/
|
||||
|
||||
//Load Grove Moisture module
|
||||
var grove_moisture = require('jsupm_grovemoisture');
|
||||
var moisture = require('jsupm_moisture');
|
||||
|
||||
// Instantiate a Grove Moisture sensor on analog pin A0
|
||||
var myMoistureObj = new grove_moisture.GroveMoisture(0);
|
||||
var myMoistureObj = new moisture.Moisture(0);
|
||||
|
||||
// Values (approximate):
|
||||
// 0-300, sensor in air or dry soil
|
@ -22,10 +22,10 @@
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import time, sys, signal, atexit
|
||||
import pyupm_grovemoisture as upmMoisture
|
||||
import pyupm_moisture as upmMoisture
|
||||
|
||||
# Instantiate a Grove Moisture sensor on analog pin A0
|
||||
myMoisture = upmMoisture.GroveMoisture(0)
|
||||
myMoisture = upmMoisture.Moisture(0)
|
||||
|
||||
|
||||
## Exit handlers ##
|
Reference in New Issue
Block a user