add save energie
This commit is contained in:
parent
afde635051
commit
c56142ccec
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#define SICSLOWPAN_CONF_FRAG 1
|
#define SICSLOWPAN_CONF_FRAG 1
|
||||||
|
|
||||||
#define LOOP_INTERVAL (3 * CLOCK_SECOND)
|
#define LOOP_INTERVAL (1 * CLOCK_SECOND)
|
||||||
|
|
||||||
/* Save energy */
|
/* Save energy */
|
||||||
//#define RDC_CONF_PT_YIELD_OFF
|
//#define RDC_CONF_PT_YIELD_OFF
|
||||||
|
|
|
@ -32,8 +32,8 @@ char soillight_s[8];
|
||||||
|
|
||||||
I2CSoilMoistureSensor sensor;
|
I2CSoilMoistureSensor sensor;
|
||||||
|
|
||||||
|
|
||||||
#define LED_PIN 4
|
#define LED_PIN 4
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup (void)
|
void setup (void)
|
||||||
|
@ -63,25 +63,39 @@ void setup (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// at project-conf.h
|
// at project-conf.h
|
||||||
// LOOP_INTERVAL (10 * CLOCK_SECOND)
|
// LOOP_INTERVAL (1 * CLOCK_SECOND)
|
||||||
|
#define MEASURE_INTERVALL 10
|
||||||
|
|
||||||
void loop (void)
|
void loop (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!sensor.isBusy()){ // available since FW 2.3
|
static int count=0;
|
||||||
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();
|
|
||||||
|
|
||||||
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
|
count ++;
|
||||||
|
switch(count){
|
||||||
// Debug Print
|
case 1 :
|
||||||
printf("Temp: %s",soiltemp_s);
|
sensor.startMeasureLight();
|
||||||
printf("\t\tSoil: %s",soilcap_s);
|
|
||||||
printf("\t\tLight: %s\n",soillight_s);
|
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.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 );
|
||||||
|
// 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