30 lines
601 B
C
30 lines
601 B
C
|
#ifndef _SOILMOISTURE_H_
|
||
|
#define _SOILMOISTURE_H_
|
||
|
|
||
|
#define SM1_ADS_CHANNEL 1
|
||
|
|
||
|
#define READINTERVAL_SM 100
|
||
|
|
||
|
unsigned long last_read_sm=0;
|
||
|
|
||
|
|
||
|
#define SM_SIZE 16
|
||
|
uint8_t sm_mean_pos=0;
|
||
|
uint16_t sm_mean[SM_SIZE];
|
||
|
|
||
|
|
||
|
void sm_loop(unsigned long loopmillis) {
|
||
|
if (loopmillis>=last_read_sm+READINTERVAL_SM) {
|
||
|
last_read_sm=loopmillis;
|
||
|
|
||
|
uint16_t value = ADS.readADC(SM1_ADS_CHANNEL);
|
||
|
sm_mean[sm_mean_pos]=value;
|
||
|
sm_mean_pos++;
|
||
|
sm_mean_pos%=SM_SIZE;
|
||
|
|
||
|
//Serial.print(getMean(sm_mean,SM_SIZE)); Serial.print("\t "); Serial.println(value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
#endif
|