add save energie
This commit is contained in:
parent
afde635051
commit
c56142ccec
|
@ -38,7 +38,7 @@
|
|||
|
||||
#define SICSLOWPAN_CONF_FRAG 1
|
||||
|
||||
#define LOOP_INTERVAL (3 * CLOCK_SECOND)
|
||||
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
|
||||
|
||||
/* Save energy */
|
||||
//#define RDC_CONF_PT_YIELD_OFF
|
||||
|
|
|
@ -32,8 +32,8 @@ char soillight_s[8];
|
|||
|
||||
I2CSoilMoistureSensor sensor;
|
||||
|
||||
|
||||
#define LED_PIN 4
|
||||
|
||||
}
|
||||
|
||||
void setup (void)
|
||||
|
@ -63,25 +63,39 @@ void setup (void)
|
|||
}
|
||||
|
||||
// at project-conf.h
|
||||
// LOOP_INTERVAL (10 * CLOCK_SECOND)
|
||||
// LOOP_INTERVAL (1 * CLOCK_SECOND)
|
||||
#define MEASURE_INTERVALL 10
|
||||
|
||||
void loop (void)
|
||||
{
|
||||
|
||||
static int count=0;
|
||||
|
||||
count ++;
|
||||
switch(count){
|
||||
case 1 :
|
||||
sensor.startMeasureLight();
|
||||
|
||||
break;
|
||||
case 4 :
|
||||
if(!sensor.isBusy()){ // available since FW 2.3
|
||||
// measure the sensors
|
||||
soilcap = sensor.getCapacitance(); //read capacitance register
|
||||
soiltemp = sensor.getTemperature()/(float)10; //temperature register
|
||||
soillight = sensor.getLight(0); //request light measurement, read light register
|
||||
sensor.startMeasureLight();
|
||||
|
||||
sensor.sleep(); // available since FW 2.3
|
||||
// convert to string
|
||||
dtostrf(soilcap , 0, 2, soilcap_s );
|
||||
dtostrf(soiltemp , 0, 2, soiltemp_s );
|
||||
dtostrf(soillight , 0, 2, soillight_s );
|
||||
|
||||
// sensor.sleep(); // available since FW 2.3
|
||||
|
||||
// Debug Print
|
||||
printf("Temp: %s",soiltemp_s);
|
||||
printf("\t\tSoil: %s",soilcap_s);
|
||||
printf("\t\tLight: %s\n",soillight_s);
|
||||
}
|
||||
break;
|
||||
case (MEASURE_INTERVALL+1) :
|
||||
count = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue