Git initial commit
This commit is contained in:
commit
c025d15a75
200
Analysis.R
Normal file
200
Analysis.R
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
library(gplots)
|
||||||
|
setwd("/home/pi/Desktop/SoilAirSensors/data/")
|
||||||
|
|
||||||
|
FlankLength = 30
|
||||||
|
Steps = 30
|
||||||
|
MinS = -1
|
||||||
|
MaxS = 1
|
||||||
|
|
||||||
|
CorCols = colorRampPalette(c('blue','grey','green'))(n=Steps)
|
||||||
|
CorBreaks = seq(from=MinS,to=MaxS,length.out=(Steps+1))
|
||||||
|
Date = paste(format(Sys.Date()-1,c("%Y","%-m","%-d")),collapse="-")
|
||||||
|
Data = read.table(paste("filter/soilair_",Date,".dat",sep=""),head=T)
|
||||||
|
pdf(file=paste("pdf/soilair_",Date,".pdf",sep=""))
|
||||||
|
|
||||||
|
MeanData = data.frame(
|
||||||
|
DailySecond = Data$DailySecond,
|
||||||
|
GPIO_C = rep(NA,nrow(Data)),
|
||||||
|
GPIO_PY = rep(NA,nrow(Data)),
|
||||||
|
Humidity = rep(NA,nrow(Data)),
|
||||||
|
Temperature = rep(NA,nrow(Data)),
|
||||||
|
Pressure = rep(NA,nrow(Data))
|
||||||
|
)
|
||||||
|
|
||||||
|
MedData = data.frame(
|
||||||
|
DailySecond = Data$DailySecond,
|
||||||
|
GPIO_C = rep(NA,nrow(Data)),
|
||||||
|
GPIO_PY = rep(NA,nrow(Data)),
|
||||||
|
Humidity = rep(NA,nrow(Data)),
|
||||||
|
Temperature = rep(NA,nrow(Data)),
|
||||||
|
Pressure = rep(NA,nrow(Data))
|
||||||
|
)
|
||||||
|
|
||||||
|
for(idx in seq(FlankLength,(nrow(Data)-FlankLength),FlankLength)){
|
||||||
|
MeanData$GPIO_C[idx] = mean(Data$GPIO_C[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MeanData$GPIO_PY[idx] = mean(Data$GPIO_PY[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MeanData$Humidity[idx] = mean(Data$Humidity[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MeanData$Temperature[idx] = mean(Data$Temperature[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MeanData$Pressure[idx] = mean(Data$Pressure[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
|
||||||
|
MedData$GPIO_C[idx] = median(Data$GPIO_C[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MedData$GPIO_PY[idx] = median(Data$GPIO_PY[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MedData$Humidity[idx] = median(Data$Humidity[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MedData$Temperature[idx] = median(Data$Temperature[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
MedData$Pressure[idx] = median(Data$Pressure[ (idx-FlankLength+1) : (idx+FlankLength)])
|
||||||
|
}
|
||||||
|
|
||||||
|
MeanData = na.omit(MeanData)
|
||||||
|
rownames(MeanData) = 1:nrow(MeanData)
|
||||||
|
MedData = na.omit(MedData)
|
||||||
|
rownames(MedData) = 1:nrow(MedData)
|
||||||
|
|
||||||
|
write.table(MeanData,file=paste("filter/soilair-mean_",Date,".dat",sep=""),col.names = T,row.names = F)
|
||||||
|
write.table(MedData,file=paste("filter/soilair-median_",Date,".dat",sep=""),col.names = T,row.names = F)
|
||||||
|
|
||||||
|
|
||||||
|
heatmap.2(
|
||||||
|
main="Pearson Correlation - Original",
|
||||||
|
cor(Data,method="pearson"),
|
||||||
|
Colv=F,
|
||||||
|
Rowv=F,
|
||||||
|
dendrogram="none",
|
||||||
|
breaks=CorBreaks,
|
||||||
|
col=CorCols
|
||||||
|
)
|
||||||
|
|
||||||
|
heatmap.2(
|
||||||
|
main=paste("Pearson Correlation - Mean of",FlankLength,"+1"),
|
||||||
|
cor(MeanData,method="pearson"),
|
||||||
|
Colv=F,
|
||||||
|
Rowv=F,
|
||||||
|
dendrogram="none",
|
||||||
|
breaks=CorBreaks,
|
||||||
|
col=CorCols
|
||||||
|
)
|
||||||
|
|
||||||
|
heatmap.2(
|
||||||
|
main=paste("Pearson Correlation - Median of",FlankLength,"+1"),
|
||||||
|
cor(MeanData,method="pearson"),
|
||||||
|
Colv=F,
|
||||||
|
Rowv=F,
|
||||||
|
dendrogram="none",
|
||||||
|
breaks=CorBreaks,
|
||||||
|
col=CorCols
|
||||||
|
)
|
||||||
|
|
||||||
|
###### PLOT DAILY SECOND; VIEW DATA ######
|
||||||
|
|
||||||
|
plot(GPIO_C~DailySecond,Data,main=paste("GPIO_C",Date),xlab="Daily Second [s]",ylab="Frequency [Hz]",pch=19,cex=0.2)
|
||||||
|
points(GPIO_C~DailySecond,MeanData,col="red",pch=19,cex=0.2)
|
||||||
|
points(GPIO_C~DailySecond,MedData,col="green",pch=19,cex=0.2)
|
||||||
|
abline(h=mean(Data$GPIO_C),col="red")
|
||||||
|
abline(h=median(Data$GPIO_C),col="green")
|
||||||
|
|
||||||
|
plot(GPIO_PY~DailySecond,Data,main=paste("GPIO_PY",Date),xlab="Daily Second [s]",ylab="Frequency [Hz]",pch=19,cex=0.2)
|
||||||
|
points(GPIO_PY~DailySecond,MeanData,col="red",pch=19,cex=0.2)
|
||||||
|
points(GPIO_PY~DailySecond,MedData,col="green",pch=19,cex=0.2)
|
||||||
|
abline(h=mean(Data$GPIO_PY),col="red")
|
||||||
|
abline(h=median(Data$GPIO_PY),col="green")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
plot(Humidity~DailySecond,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Humidity~DailySecond,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Humidity~DailySecond,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
plot(Temperature~DailySecond,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Temperature~DailySecond,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Temperature~DailySecond,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
plot(Pressure~DailySecond,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Pressure~DailySecond,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Pressure~DailySecond,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###### PLOT ENVIRONMENT AGAINST ENVIRONMENT; VIEW DATA ######
|
||||||
|
|
||||||
|
plot(Humidity~Temperature,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Humidity~Temperature,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Humidity~Temperature,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
plot(Temperature~Humidity,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Temperature~Humidity,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Temperature~Humidity,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
plot(Humidity~Pressure,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Humidity~Pressure,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Humidity~Pressure,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
plot(Pressure~Humidity,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Pressure~Humidity,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Pressure~Humidity,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
|
||||||
|
plot(Pressure~Temperature,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Pressure~Temperature,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Pressure~Temperature,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
plot(Temperature~Pressure,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(Temperature~Pressure,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(Temperature~Pressure,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
###### PLOT GPIO AGAINST ENVIRONMENT; VIEW DATA ######
|
||||||
|
|
||||||
|
plot(GPIO_C~Humidity,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(GPIO_C~Humidity,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(GPIO_C~Humidity,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
plot(GPIO_PY~Humidity,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(GPIO_PY~Humidity,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(GPIO_PY~Humidity,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
plot(GPIO_C~Temperature,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(GPIO_C~Temperature,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(GPIO_C~Temperature,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
plot(GPIO_PY~Temperature,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(GPIO_PY~Temperature,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(GPIO_PY~Temperature,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
plot(GPIO_C~Pressure,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(GPIO_C~Pressure,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(GPIO_C~Pressure,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
plot(GPIO_PY~Pressure,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
points(GPIO_PY~Pressure,MeanData,pch=19,cex=0.2,col="red")
|
||||||
|
points(GPIO_PY~Pressure,MedData,pch=19,cex=0.2,col="green")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###### PLOT GPIO AGAINST GPIO; VIEW DATA ######
|
||||||
|
|
||||||
|
plot(GPIO_PY~GPIO_C,Data,pch=19,cex=0.2,main=Date)
|
||||||
|
|
||||||
|
plot(GPIO_PY~GPIO_C,MedData,pch=19,cex=0.2,main=paste("Median",Date))
|
||||||
|
abline(lm(GPIO_PY~GPIO_C,MedData),col="red")
|
||||||
|
|
||||||
|
|
||||||
|
###### Missing Data Analysis ######
|
||||||
|
|
||||||
|
MissingTimePoint = c()
|
||||||
|
for(i in 2:nrow(Data)){
|
||||||
|
if(Data$DailySecond[i] - Data$DailySecond[i-1] != 1){
|
||||||
|
MissingTimePoint[length(MissingTimePoint)+1] = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plot(1:length(MissingTimePoint),MissingTimePoint,pch=19,cex=0.2)
|
||||||
|
MaxDiff = 0
|
||||||
|
for( i in 2:length(MissingTimePoint)){
|
||||||
|
MaxDiff = max(MaxDiff, MissingTimePoint[i] - MissingTimePoint[i-1] )
|
||||||
|
}
|
||||||
|
MisDist = rep(0,length(MissingTimePoint)-1)
|
||||||
|
for( i in 2:length(MissingTimePoint)){
|
||||||
|
MisDist[i-1] = MissingTimePoint[i] - MissingTimePoint[i-1]
|
||||||
|
}
|
||||||
|
hist(MisDist)
|
||||||
|
plot(1:length(MisDist),MisDist,type="b",pch=19,cex=0.2)
|
||||||
|
|
||||||
|
dev.off()
|
15
SoilAirMerge.R
Normal file
15
SoilAirMerge.R
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
setwd("/home/pi/Desktop/SoilAirSensors/data/")
|
||||||
|
Date = format(Sys.Date()-1,c("%Y","%-m","%-d"))
|
||||||
|
|
||||||
|
DataA = read.table(paste("raw/airdata_",Date[1],"-",Date[2],"-",Date[3],".dat",sep=""),head=T)
|
||||||
|
DataSC = read.table(paste("raw/soildata-c_",Date[1],"-",Date[2],"-",Date[3],".dat",sep=""),head=T)
|
||||||
|
colnames(DataSC)[2] = "GPIO_C"
|
||||||
|
DataSP = read.table(paste("raw/soildata-py_",Date[1],"-",Date[2],"-",Date[3],".dat",sep=""),head=T)
|
||||||
|
colnames(DataSP)[2] = "GPIO_PY"
|
||||||
|
|
||||||
|
Data = merge(DataSP,DataSC,by="DailySecond")
|
||||||
|
Data = merge(Data,DataA,by="DailySecond")
|
||||||
|
|
||||||
|
write.table(Data,file=paste("merge/soilairdata_",Date[1],"-",Date[2],"-",Date[3],".dat",sep=""),col.names = T,row.names = F,sep=" ")
|
||||||
|
SubData = subset(Data,select=c("DailySecond","GPIO_PY","GPIO_C","Humidity","Temperature","Pressure"))
|
||||||
|
write.table(SubData,file=paste("filter/soilair_",Date[1],"-",Date[2],"-",Date[3],".dat",sep=""),col.names = T,row.names = F,sep=" ")
|
59
airsensor.py
Normal file
59
airsensor.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
import time
|
||||||
|
import argparse
|
||||||
|
import board
|
||||||
|
import busio
|
||||||
|
import adafruit_bme280
|
||||||
|
|
||||||
|
def get_i2c_data(bme):
|
||||||
|
return "{:.2f}\t{:.1f}\t{:.2f}\t{:.1f}\t{:.2f}".format(bme.humidity,bme.temperature,bme.pressure,bme.altitude,bme.sea_level_pressure)
|
||||||
|
def dayseconds():
|
||||||
|
Now = time.localtime()
|
||||||
|
return Now.tm_hour*60*60 + Now.tm_min*60 + Now.tm_sec
|
||||||
|
def file_name(Prefix=""):
|
||||||
|
Start = time.localtime()
|
||||||
|
return Prefix+"airdata_{}-{}-{}.dat".format(Start.tm_year,Start.tm_mon,Start.tm_mday)
|
||||||
|
|
||||||
|
|
||||||
|
Parser = argparse.ArgumentParser(description="DataCollection of the bme280 Sensor from adafruit. Tmeperature, Humidity, Pressure and more is shown and stored at the same time")
|
||||||
|
Parser.add_argument("--prefix",metavar="PATH",help="Prefix for the OUPUT-FILE; usually a certain folder",type=str,required=False)
|
||||||
|
Args = Parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i2c = busio.I2C(board.SCL, board.SDA)
|
||||||
|
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
|
||||||
|
bme280.sea_level_pressure = 1029
|
||||||
|
|
||||||
|
Head = "DailySecond\tHumidity\tTemperature\tPressure\tAltitude\tSeaLevelPressure"
|
||||||
|
Units = "#[s]\t[%]\t[°C]\t[hPa]\t[m]"
|
||||||
|
Prefix = ""
|
||||||
|
Time = 0
|
||||||
|
TimeLast = 0
|
||||||
|
|
||||||
|
if Args.prefix:
|
||||||
|
Prefix = Args.prefix
|
||||||
|
if Prefix[-1] != "/":
|
||||||
|
Prefix += "/"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File = open(file_name(Prefix),"w",buffering=1)
|
||||||
|
File.write("#Starting on {}\n".format(time.ctime()))
|
||||||
|
File.write(Head+"\n")
|
||||||
|
File.write(Units+"\n")
|
||||||
|
print("#Starting on {}".format(time.ctime()))
|
||||||
|
print(Head)
|
||||||
|
print(Units)
|
||||||
|
|
||||||
|
Time = dayseconds()
|
||||||
|
while TimeLast <= Time:
|
||||||
|
Data = repr(Time) + "\t" + get_i2c_data(bme280)
|
||||||
|
File.write("{}\n".format(Data))
|
||||||
|
print(Data)
|
||||||
|
#print and write everything; AFTERWARDS reset; sothat nothing interrupts the tally function call at loop start
|
||||||
|
time.sleep(0.7)
|
||||||
|
TimeLast = Time
|
||||||
|
Time = dayseconds()
|
||||||
|
|
||||||
|
print("END")
|
2860
data/filter/soilair-mean_2018-12-26.dat
Normal file
2860
data/filter/soilair-mean_2018-12-26.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-mean_2018-12-27.dat
Normal file
2859
data/filter/soilair-mean_2018-12-27.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-mean_2018-12-28.dat
Normal file
2859
data/filter/soilair-mean_2018-12-28.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-mean_2018-12-29.dat
Normal file
2859
data/filter/soilair-mean_2018-12-29.dat
Normal file
File diff suppressed because it is too large
Load Diff
2811
data/filter/soilair-mean_2018-12-30.dat
Normal file
2811
data/filter/soilair-mean_2018-12-30.dat
Normal file
File diff suppressed because it is too large
Load Diff
2853
data/filter/soilair-mean_2018-12-31.dat
Normal file
2853
data/filter/soilair-mean_2018-12-31.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-mean_2019-1-1.dat
Normal file
2859
data/filter/soilair-mean_2019-1-1.dat
Normal file
File diff suppressed because it is too large
Load Diff
2858
data/filter/soilair-mean_2019-1-2.dat
Normal file
2858
data/filter/soilair-mean_2019-1-2.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-mean_2019-1-3.dat
Normal file
2859
data/filter/soilair-mean_2019-1-3.dat
Normal file
File diff suppressed because it is too large
Load Diff
2860
data/filter/soilair-median_2018-12-26.dat
Normal file
2860
data/filter/soilair-median_2018-12-26.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-median_2018-12-27.dat
Normal file
2859
data/filter/soilair-median_2018-12-27.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-median_2018-12-28.dat
Normal file
2859
data/filter/soilair-median_2018-12-28.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-median_2018-12-29.dat
Normal file
2859
data/filter/soilair-median_2018-12-29.dat
Normal file
File diff suppressed because it is too large
Load Diff
2811
data/filter/soilair-median_2018-12-30.dat
Normal file
2811
data/filter/soilair-median_2018-12-30.dat
Normal file
File diff suppressed because it is too large
Load Diff
2853
data/filter/soilair-median_2018-12-31.dat
Normal file
2853
data/filter/soilair-median_2018-12-31.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-median_2019-1-1.dat
Normal file
2859
data/filter/soilair-median_2019-1-1.dat
Normal file
File diff suppressed because it is too large
Load Diff
2858
data/filter/soilair-median_2019-1-2.dat
Normal file
2858
data/filter/soilair-median_2019-1-2.dat
Normal file
File diff suppressed because it is too large
Load Diff
2859
data/filter/soilair-median_2019-1-3.dat
Normal file
2859
data/filter/soilair-median_2019-1-3.dat
Normal file
File diff suppressed because it is too large
Load Diff
85801
data/filter/soilair_2018-12-26.dat
Normal file
85801
data/filter/soilair_2018-12-26.dat
Normal file
File diff suppressed because it is too large
Load Diff
85789
data/filter/soilair_2018-12-27.dat
Normal file
85789
data/filter/soilair_2018-12-27.dat
Normal file
File diff suppressed because it is too large
Load Diff
85782
data/filter/soilair_2018-12-28.dat
Normal file
85782
data/filter/soilair_2018-12-28.dat
Normal file
File diff suppressed because it is too large
Load Diff
85792
data/filter/soilair_2018-12-29.dat
Normal file
85792
data/filter/soilair_2018-12-29.dat
Normal file
File diff suppressed because it is too large
Load Diff
84334
data/filter/soilair_2018-12-30.dat
Normal file
84334
data/filter/soilair_2018-12-30.dat
Normal file
File diff suppressed because it is too large
Load Diff
85616
data/filter/soilair_2018-12-31.dat
Normal file
85616
data/filter/soilair_2018-12-31.dat
Normal file
File diff suppressed because it is too large
Load Diff
85774
data/filter/soilair_2019-1-1.dat
Normal file
85774
data/filter/soilair_2019-1-1.dat
Normal file
File diff suppressed because it is too large
Load Diff
85762
data/filter/soilair_2019-1-2.dat
Normal file
85762
data/filter/soilair_2019-1-2.dat
Normal file
File diff suppressed because it is too large
Load Diff
85774
data/filter/soilair_2019-1-3.dat
Normal file
85774
data/filter/soilair_2019-1-3.dat
Normal file
File diff suppressed because it is too large
Load Diff
85801
data/merge/soilairdata_2018-12-26.dat
Normal file
85801
data/merge/soilairdata_2018-12-26.dat
Normal file
File diff suppressed because it is too large
Load Diff
85789
data/merge/soilairdata_2018-12-27.dat
Normal file
85789
data/merge/soilairdata_2018-12-27.dat
Normal file
File diff suppressed because it is too large
Load Diff
85782
data/merge/soilairdata_2018-12-28.dat
Normal file
85782
data/merge/soilairdata_2018-12-28.dat
Normal file
File diff suppressed because it is too large
Load Diff
85792
data/merge/soilairdata_2018-12-29.dat
Normal file
85792
data/merge/soilairdata_2018-12-29.dat
Normal file
File diff suppressed because it is too large
Load Diff
84334
data/merge/soilairdata_2018-12-30.dat
Normal file
84334
data/merge/soilairdata_2018-12-30.dat
Normal file
File diff suppressed because it is too large
Load Diff
85616
data/merge/soilairdata_2018-12-31.dat
Normal file
85616
data/merge/soilairdata_2018-12-31.dat
Normal file
File diff suppressed because it is too large
Load Diff
85774
data/merge/soilairdata_2019-1-1.dat
Normal file
85774
data/merge/soilairdata_2019-1-1.dat
Normal file
File diff suppressed because it is too large
Load Diff
85762
data/merge/soilairdata_2019-1-2.dat
Normal file
85762
data/merge/soilairdata_2019-1-2.dat
Normal file
File diff suppressed because it is too large
Load Diff
85774
data/merge/soilairdata_2019-1-3.dat
Normal file
85774
data/merge/soilairdata_2019-1-3.dat
Normal file
File diff suppressed because it is too large
Load Diff
BIN
data/pdf/soilair_2018-12-26.pdf
Normal file
BIN
data/pdf/soilair_2018-12-26.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2018-12-27.pdf
Normal file
BIN
data/pdf/soilair_2018-12-27.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2018-12-28.pdf
Normal file
BIN
data/pdf/soilair_2018-12-28.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2018-12-29.pdf
Normal file
BIN
data/pdf/soilair_2018-12-29.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2018-12-30.pdf
Normal file
BIN
data/pdf/soilair_2018-12-30.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2018-12-31.pdf
Normal file
BIN
data/pdf/soilair_2018-12-31.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2019-1-1.pdf
Normal file
BIN
data/pdf/soilair_2019-1-1.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2019-1-2.pdf
Normal file
BIN
data/pdf/soilair_2019-1-2.pdf
Normal file
Binary file not shown.
BIN
data/pdf/soilair_2019-1-3.pdf
Normal file
BIN
data/pdf/soilair_2019-1-3.pdf
Normal file
Binary file not shown.
85953
data/raw/airdata_2018-12-26.dat
Normal file
85953
data/raw/airdata_2018-12-26.dat
Normal file
File diff suppressed because it is too large
Load Diff
85951
data/raw/airdata_2018-12-27.dat
Normal file
85951
data/raw/airdata_2018-12-27.dat
Normal file
File diff suppressed because it is too large
Load Diff
85946
data/raw/airdata_2018-12-28.dat
Normal file
85946
data/raw/airdata_2018-12-28.dat
Normal file
File diff suppressed because it is too large
Load Diff
85950
data/raw/airdata_2018-12-29.dat
Normal file
85950
data/raw/airdata_2018-12-29.dat
Normal file
File diff suppressed because it is too large
Load Diff
85920
data/raw/airdata_2018-12-30.dat
Normal file
85920
data/raw/airdata_2018-12-30.dat
Normal file
File diff suppressed because it is too large
Load Diff
85794
data/raw/airdata_2018-12-31.dat
Normal file
85794
data/raw/airdata_2018-12-31.dat
Normal file
File diff suppressed because it is too large
Load Diff
85954
data/raw/airdata_2019-1-1.dat
Normal file
85954
data/raw/airdata_2019-1-1.dat
Normal file
File diff suppressed because it is too large
Load Diff
85943
data/raw/airdata_2019-1-2.dat
Normal file
85943
data/raw/airdata_2019-1-2.dat
Normal file
File diff suppressed because it is too large
Load Diff
85955
data/raw/airdata_2019-1-3.dat
Normal file
85955
data/raw/airdata_2019-1-3.dat
Normal file
File diff suppressed because it is too large
Load Diff
86384
data/raw/soildata-c_2018-12-26.dat
Normal file
86384
data/raw/soildata-c_2018-12-26.dat
Normal file
File diff suppressed because it is too large
Load Diff
86386
data/raw/soildata-c_2018-12-27.dat
Normal file
86386
data/raw/soildata-c_2018-12-27.dat
Normal file
File diff suppressed because it is too large
Load Diff
86384
data/raw/soildata-c_2018-12-28.dat
Normal file
86384
data/raw/soildata-c_2018-12-28.dat
Normal file
File diff suppressed because it is too large
Load Diff
86385
data/raw/soildata-c_2018-12-29.dat
Normal file
86385
data/raw/soildata-c_2018-12-29.dat
Normal file
File diff suppressed because it is too large
Load Diff
84964
data/raw/soildata-c_2018-12-30.dat
Normal file
84964
data/raw/soildata-c_2018-12-30.dat
Normal file
File diff suppressed because it is too large
Load Diff
86384
data/raw/soildata-c_2018-12-31.dat
Normal file
86384
data/raw/soildata-c_2018-12-31.dat
Normal file
File diff suppressed because it is too large
Load Diff
86384
data/raw/soildata-c_2019-1-1.dat
Normal file
86384
data/raw/soildata-c_2019-1-1.dat
Normal file
File diff suppressed because it is too large
Load Diff
86385
data/raw/soildata-c_2019-1-2.dat
Normal file
86385
data/raw/soildata-c_2019-1-2.dat
Normal file
File diff suppressed because it is too large
Load Diff
86386
data/raw/soildata-c_2019-1-3.dat
Normal file
86386
data/raw/soildata-c_2019-1-3.dat
Normal file
File diff suppressed because it is too large
Load Diff
36424
data/raw/soildata-c_2019-1-4.dat
Normal file
36424
data/raw/soildata-c_2019-1-4.dat
Normal file
File diff suppressed because it is too large
Load Diff
86264
data/raw/soildata-py_2018-12-26.dat
Normal file
86264
data/raw/soildata-py_2018-12-26.dat
Normal file
File diff suppressed because it is too large
Load Diff
86255
data/raw/soildata-py_2018-12-27.dat
Normal file
86255
data/raw/soildata-py_2018-12-27.dat
Normal file
File diff suppressed because it is too large
Load Diff
86256
data/raw/soildata-py_2018-12-28.dat
Normal file
86256
data/raw/soildata-py_2018-12-28.dat
Normal file
File diff suppressed because it is too large
Load Diff
86259
data/raw/soildata-py_2018-12-29.dat
Normal file
86259
data/raw/soildata-py_2018-12-29.dat
Normal file
File diff suppressed because it is too large
Load Diff
84821
data/raw/soildata-py_2018-12-30.dat
Normal file
84821
data/raw/soildata-py_2018-12-30.dat
Normal file
File diff suppressed because it is too large
Load Diff
86127
data/raw/soildata-py_2018-12-31.dat
Normal file
86127
data/raw/soildata-py_2018-12-31.dat
Normal file
File diff suppressed because it is too large
Load Diff
86236
data/raw/soildata-py_2019-1-1.dat
Normal file
86236
data/raw/soildata-py_2019-1-1.dat
Normal file
File diff suppressed because it is too large
Load Diff
86232
data/raw/soildata-py_2019-1-2.dat
Normal file
86232
data/raw/soildata-py_2019-1-2.dat
Normal file
File diff suppressed because it is too large
Load Diff
86235
data/raw/soildata-py_2019-1-3.dat
Normal file
86235
data/raw/soildata-py_2019-1-3.dat
Normal file
File diff suppressed because it is too large
Load Diff
281
soilsensor.c
Normal file
281
soilsensor.c
Normal file
@ -0,0 +1,281 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <pigpio.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
2014-08-20
|
||||||
|
|
||||||
|
gcc -o freq_count_1 freq_count_1.c -lpigpio -lpthread
|
||||||
|
$ sudo ./freq_count_1 4 7 8
|
||||||
|
|
||||||
|
This program uses the gpioSetAlertFunc function to request
|
||||||
|
a callback (the same one) for each gpio to be monitored.
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
|
||||||
|
Monitor gpio 4 (default settings)
|
||||||
|
sudo ./freq_count_1 4
|
||||||
|
|
||||||
|
Monitor gpios 4 and 8 (default settings)
|
||||||
|
sudo ./freq_count_1 4 8
|
||||||
|
|
||||||
|
Monitor gpios 4 and 8, sample rate 2 microseconds
|
||||||
|
sudo ./freq_count_1 4 8 -s2
|
||||||
|
|
||||||
|
Monitor gpios 7 and 8, sample rate 4 microseconds, report every second
|
||||||
|
sudo ./freq_count_1 7 8 -s4 -r10
|
||||||
|
|
||||||
|
Monitor gpios 4,7, 8, 9, 10, 23 24, report five times a second
|
||||||
|
sudo ./freq_count_1 4 7 8 9 10 23 24 -r2
|
||||||
|
|
||||||
|
Monitor gpios 4, 7, 8, and 9, report once a second, sample rate 1us,
|
||||||
|
generate 2us edges (4us square wave, 250000 highs per second).
|
||||||
|
sudo ./freq_count_1 4 7 8 9 -r 10 -s 1 -p 2
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAX_GPIOS 32
|
||||||
|
|
||||||
|
#define OPT_P_MIN 1
|
||||||
|
#define OPT_P_MAX 1000
|
||||||
|
#define OPT_P_DEF 20
|
||||||
|
|
||||||
|
#define OPT_R_MIN 1
|
||||||
|
#define OPT_R_MAX 10
|
||||||
|
#define OPT_R_DEF 10
|
||||||
|
|
||||||
|
#define OPT_S_MIN 1
|
||||||
|
#define OPT_S_MAX 10
|
||||||
|
#define OPT_S_DEF 5
|
||||||
|
|
||||||
|
static char * Prefix = ".";
|
||||||
|
|
||||||
|
static volatile int g_pulse_count[MAX_GPIOS];
|
||||||
|
static volatile int g_reset_counts;
|
||||||
|
static uint32_t g_mask;
|
||||||
|
|
||||||
|
static int g_num_gpios;
|
||||||
|
static int g_gpio[MAX_GPIOS];
|
||||||
|
|
||||||
|
static int g_opt_p = OPT_P_DEF;
|
||||||
|
static int g_opt_r = OPT_R_DEF;
|
||||||
|
static int g_opt_s = OPT_S_DEF;
|
||||||
|
static int g_opt_t = 0;
|
||||||
|
|
||||||
|
void usage()
|
||||||
|
{
|
||||||
|
fprintf
|
||||||
|
(stderr,
|
||||||
|
"\n" \
|
||||||
|
"Usage: sudo ./freq_count_1 gpio ... [OPTION] ...\n" \
|
||||||
|
" -p value, sets pulses every p micros, %d-%d, TESTING only\n" \
|
||||||
|
" -r value, sets refresh period in deciseconds, %d-%d, default %d\n" \
|
||||||
|
" -s value, sets sampling rate in micros, %d-%d, default %d\n" \
|
||||||
|
" -f path, sets the prefix for output data" \
|
||||||
|
"\nEXAMPLE\n" \
|
||||||
|
"sudo ./freq_count_1 4 7 -r2 -s2\n" \
|
||||||
|
"Monitor gpios 4 and 7. Refresh every 0.2 seconds. Sample rate 2 micros.\n" \
|
||||||
|
"\n",
|
||||||
|
OPT_P_MIN, OPT_P_MAX,
|
||||||
|
OPT_R_MIN, OPT_R_MAX, OPT_R_DEF,
|
||||||
|
OPT_S_MIN, OPT_S_MAX, OPT_S_DEF
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fatal(int show_usage, char *fmt, ...)
|
||||||
|
{
|
||||||
|
char buf[128];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
fprintf(stderr, "%s\n", buf);
|
||||||
|
|
||||||
|
if (show_usage) usage();
|
||||||
|
|
||||||
|
fflush(stderr);
|
||||||
|
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int initOpts(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i, opt;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "p:r:s:f:")) != -1)
|
||||||
|
{
|
||||||
|
i = -1;
|
||||||
|
|
||||||
|
switch (opt)
|
||||||
|
{
|
||||||
|
case 'p':
|
||||||
|
i = atoi(optarg);
|
||||||
|
if ((i >= OPT_P_MIN) && (i <= OPT_P_MAX))
|
||||||
|
g_opt_p = i;
|
||||||
|
else fatal(1, "invalid -p option (%d)", i);
|
||||||
|
g_opt_t = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'r':
|
||||||
|
i = atoi(optarg);
|
||||||
|
if ((i >= OPT_R_MIN) && (i <= OPT_R_MAX))
|
||||||
|
g_opt_r = i;
|
||||||
|
else fatal(1, "invalid -r option (%d)", i);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
i = atoi(optarg);
|
||||||
|
if ((i >= OPT_S_MIN) && (i <= OPT_S_MAX))
|
||||||
|
g_opt_s = i;
|
||||||
|
else fatal(1, "invalid -s option (%d)", i);
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
Prefix = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: /* '?' */
|
||||||
|
usage();
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return optind;
|
||||||
|
}
|
||||||
|
|
||||||
|
void edges(int gpio, int level, uint32_t tick)
|
||||||
|
{
|
||||||
|
int g;
|
||||||
|
|
||||||
|
if (g_reset_counts)
|
||||||
|
{
|
||||||
|
g_reset_counts = 0;
|
||||||
|
for (g=0; g<MAX_GPIOS; g++) g_pulse_count[g] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* only record low to high edges */
|
||||||
|
if (level == 1) g_pulse_count[gpio]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i, rest, g, wave_id, mode,Time,TimeLast;
|
||||||
|
gpioPulse_t pulse[2];
|
||||||
|
int count[MAX_GPIOS];
|
||||||
|
char buf[0x100];
|
||||||
|
|
||||||
|
time_t now;
|
||||||
|
struct tm *tm;
|
||||||
|
|
||||||
|
|
||||||
|
/* command line parameters */
|
||||||
|
|
||||||
|
rest = initOpts(argc, argv);
|
||||||
|
|
||||||
|
/*File Write*/
|
||||||
|
now = time(0);
|
||||||
|
tm = localtime(&now);
|
||||||
|
snprintf(buf, sizeof(buf), "%s/soildata-c_%d-%d-%d.dat",Prefix,tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday);
|
||||||
|
FILE *f = fopen(buf, "w");
|
||||||
|
if (f == NULL)
|
||||||
|
{
|
||||||
|
printf("Error opening file!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
printf("%s\n",buf);
|
||||||
|
|
||||||
|
|
||||||
|
/* get the gpios to monitor */
|
||||||
|
|
||||||
|
g_num_gpios = 0;
|
||||||
|
|
||||||
|
for (i=rest; i<argc; i++)
|
||||||
|
{
|
||||||
|
g = atoi(argv[i]);
|
||||||
|
if ((g>=0) && (g<32))
|
||||||
|
{
|
||||||
|
g_gpio[g_num_gpios++] = g;
|
||||||
|
g_mask |= (1<<g);
|
||||||
|
}
|
||||||
|
else fatal(1, "%d is not a valid g_gpio number\n", g);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_num_gpios) fatal(1, "At least one gpio must be specified");
|
||||||
|
|
||||||
|
printf("#Monitoring gpios");
|
||||||
|
for (i=0; i<g_num_gpios; i++) printf(" %d", g_gpio[i]);
|
||||||
|
printf("\n#Sample rate %d micros, refresh rate %d deciseconds\n",
|
||||||
|
g_opt_s, g_opt_r);
|
||||||
|
|
||||||
|
gpioCfgClock(g_opt_s, 1, 1);
|
||||||
|
|
||||||
|
if (gpioInitialise()<0) return 1;
|
||||||
|
|
||||||
|
gpioWaveClear();
|
||||||
|
|
||||||
|
pulse[0].gpioOn = g_mask;
|
||||||
|
pulse[0].gpioOff = 0;
|
||||||
|
pulse[0].usDelay = g_opt_p;
|
||||||
|
|
||||||
|
pulse[1].gpioOn = 0;
|
||||||
|
pulse[1].gpioOff = g_mask;
|
||||||
|
pulse[1].usDelay = g_opt_p;
|
||||||
|
|
||||||
|
gpioWaveAddGeneric(2, pulse);
|
||||||
|
|
||||||
|
wave_id = gpioWaveCreate();
|
||||||
|
|
||||||
|
/* monitor g_gpio level changes */
|
||||||
|
|
||||||
|
for (i=0; i<g_num_gpios; i++) gpioSetAlertFunc(g_gpio[i], edges);
|
||||||
|
|
||||||
|
mode = PI_INPUT;
|
||||||
|
|
||||||
|
if (g_opt_t)
|
||||||
|
{
|
||||||
|
gpioWaveTxSend(wave_id, PI_WAVE_MODE_REPEAT);
|
||||||
|
mode = PI_OUTPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<g_num_gpios; i++) gpioSetMode(g_gpio[i], mode);
|
||||||
|
|
||||||
|
printf("DailySecond\tGPIO_%d",g_gpio[0]);
|
||||||
|
fprintf(f,"DailySecond\tGPIO_%d",g_gpio[0]);
|
||||||
|
for (i=1; i<g_num_gpios; i++)
|
||||||
|
{
|
||||||
|
printf("\tGPIO_%d",g_gpio[i]);
|
||||||
|
fprintf(f,"\tGPIO_%d",g_gpio[i]);
|
||||||
|
}
|
||||||
|
fprintf(f,"\n");
|
||||||
|
printf("\n");
|
||||||
|
gpioDelay(g_opt_r * 100000);
|
||||||
|
now = time(0);
|
||||||
|
tm = localtime(&now);
|
||||||
|
TimeLast = 0;
|
||||||
|
Time = tm->tm_hour*60*60 + tm->tm_min*60 + tm->tm_sec;
|
||||||
|
while (TimeLast <= Time)
|
||||||
|
{
|
||||||
|
for (i=0; i<g_num_gpios; i++) count[i] = g_pulse_count[g_gpio[i]];
|
||||||
|
|
||||||
|
printf("%d\t%d",Time,count[0]);
|
||||||
|
fprintf(f,"%d\t%d",Time,count[0]);
|
||||||
|
for (i=1; i<g_num_gpios; i++)
|
||||||
|
{
|
||||||
|
printf("\t%d",count[i]);
|
||||||
|
fprintf(f,"\t%d",count[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
fprintf(f,"\n");
|
||||||
|
g_reset_counts = 1;
|
||||||
|
gpioDelay(g_opt_r * 100000);
|
||||||
|
TimeLast = Time;
|
||||||
|
now = time(0);
|
||||||
|
tm = localtime(&now);
|
||||||
|
Time = tm->tm_hour*60*60 + tm->tm_min*60 + tm->tm_sec;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
gpioTerminate();
|
||||||
|
}
|
82
soilsensor.py
Normal file
82
soilsensor.py
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
import argparse
|
||||||
|
import time
|
||||||
|
import pigpio
|
||||||
|
|
||||||
|
def dayseconds():
|
||||||
|
Now = time.localtime()
|
||||||
|
return Now.tm_hour*60*60 + Now.tm_min*60 + Now.tm_sec
|
||||||
|
def file_name(Prefix=""):
|
||||||
|
Start = time.localtime()
|
||||||
|
print(Prefix)
|
||||||
|
return Prefix+"soildata-py_{}-{}-{}.dat".format(Start.tm_year,Start.tm_mon,Start.tm_mday)
|
||||||
|
|
||||||
|
|
||||||
|
Parser = argparse.ArgumentParser(description="DataCollection of the bme280 Sensor from adafruit. Tmeperature, Humidity, Pressure and more is shown and stored at the same time.")
|
||||||
|
Parser.add_argument("--prefix",metavar="PATH",help="Prefix for the OUPUT-FILE; usually a certain folder.",type=str,required=False)
|
||||||
|
Parser.add_argument("-p",metavar="N",help="Set Pulse to N µs, default p = 20µs.", default=[20], type=int,nargs=1,required=False)
|
||||||
|
Parser.add_argument("-s",metavar="N",help="Set sample rate to N deciseconds [10^-1 s]; default s = 10.",default=[10],type=int,nargs=1,required=False)
|
||||||
|
Parser.add_argument("-g",metavar="N",help="Listen to GPIO-Pin(s) N, where soil humidity sensors are connected.",nargs="+",type=int,required=True)
|
||||||
|
Args = Parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
Sensors = Args.g #Read from GPIO XX
|
||||||
|
Head = "DailySecond\t"+"\t".join("GPIO_"+str(Gpio) for Gpio in Sensors)
|
||||||
|
Units = "#[s]\t"+"\t".join("[Hz]" for Gpio in Sensors)
|
||||||
|
Prefix = ""
|
||||||
|
PulseMS = 10
|
||||||
|
PulseDelay = 20
|
||||||
|
PinMask = 0
|
||||||
|
Time = 0
|
||||||
|
TimeLast = 0
|
||||||
|
if Args.prefix:
|
||||||
|
Prefix = Args.prefix
|
||||||
|
if Prefix[-1] != "/":
|
||||||
|
Prefix += "/"
|
||||||
|
if Args.p:
|
||||||
|
PulseDelay = Args.p[0]
|
||||||
|
if Args.s:
|
||||||
|
PulseMS = Args.s[0]
|
||||||
|
for Pin in Sensors:
|
||||||
|
PinMask |= 1<<Pin
|
||||||
|
|
||||||
|
|
||||||
|
PI = pigpio.pi()
|
||||||
|
PI.wave_clear()
|
||||||
|
for Gpio in Sensors:
|
||||||
|
PI.set_mode(Gpio,pigpio.INPUT)
|
||||||
|
PulseGpio = [pigpio.pulse(PinMask,0,PulseDelay),pigpio.pulse(0,PinMask,PulseDelay)]
|
||||||
|
PI.wave_add_generic(PulseGpio)
|
||||||
|
WaveID = PI.wave_create()
|
||||||
|
#next function can have 3 parameter; third is user-defined callback function; if not defined, just count edges: CallBacks[X].tally() or .reset_tally()
|
||||||
|
CallBacks = [PI.callback(Gpio, pigpio.RISING_EDGE) for Gpio in Sensors]
|
||||||
|
|
||||||
|
File = open(file_name(Prefix),"w",buffering=1)
|
||||||
|
File.write("#Starting on {}\n".format(time.ctime()))
|
||||||
|
File.write(Head+"\n")
|
||||||
|
File.write(Units+"\n")
|
||||||
|
print("#Starting on {}".format(time.ctime()))
|
||||||
|
print(Head)
|
||||||
|
print(Units)
|
||||||
|
|
||||||
|
for Call in CallBacks:
|
||||||
|
Call.reset_tally()
|
||||||
|
time.sleep(0.1*PulseMS)
|
||||||
|
Time = dayseconds()
|
||||||
|
while TimeLast <= Time:
|
||||||
|
Time = dayseconds()
|
||||||
|
Data = repr(Time) + "\t" + "\t".join(str(Call.tally()) for Call in CallBacks)
|
||||||
|
File.write("{}\n".format(Data))
|
||||||
|
print(Data)
|
||||||
|
#print and write everything; AFTERWARDS reset; sothat nothing interrupts the tally function call at loop start
|
||||||
|
for Call in CallBacks:
|
||||||
|
Call.reset_tally()
|
||||||
|
time.sleep(0.1*PulseMS)
|
||||||
|
TimeLast = Time
|
||||||
|
Time = dayseconds()
|
||||||
|
|
||||||
|
PI.wave_delete(WaveID)
|
||||||
|
PI.stop()
|
||||||
|
i2c.deinit()
|
||||||
|
File.close()
|
||||||
|
print("END")
|
11
submit.bash
Normal file
11
submit.bash
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PRFX="/home/pi/Desktop/SoilAirSensors/data/raw/"
|
||||||
|
DATE=`date '+%Y-%-m-%-d' -d "yesterday"`
|
||||||
|
AIR_FILE=$PRFX"airdata_"$DATE".dat"
|
||||||
|
SOIL_FILE=$PRFX"soildata-py_"$DATE".dat"
|
||||||
|
PSWD=""
|
||||||
|
|
||||||
|
echo "sending "$AIR_FILE
|
||||||
|
sshpass -p '$PSWD' scp $AIR_FILE raspberrypi3bp:$PRFX
|
||||||
|
echo "sending "$SOIL_FILE
|
||||||
|
sshpass -p '$PSWD' scp $SOIL_FILE raspberrypi3bp:$PRFX
|
Loading…
Reference in New Issue
Block a user