fix(pkg/logfile,sensor): implement pressure as measured value
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -50,10 +51,12 @@ func (s *BME280) Read() ([]types.MeasuredValue, error) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// p, err := sensor.ReadPressurePa(bsbmp.ACCURACY_STANDARD)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
pressureValue, err := sensor.ReadPressurePa(bsbmp.ACCURACY_STANDARD)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
pressureValueRound := math.Round(float64(pressureValue)/10*0.25) * 10 / 0.25
|
||||
|
||||
_, humidityValue, err := sensor.ReadHumidityRH(bsbmp.ACCURACY_STANDARD)
|
||||
if err != nil {
|
||||
@ -68,6 +71,13 @@ func (s *BME280) Read() ([]types.MeasuredValue, error) {
|
||||
HumidityTillDate: time.Now(),
|
||||
SensorID: s.SensorID,
|
||||
},
|
||||
&types.Pressure{
|
||||
PressureID: uuid.NewV4().String(),
|
||||
PressureValue: pressureValueRound,
|
||||
PressureFromDate: time.Now(),
|
||||
PressureTillDate: time.Now(),
|
||||
SensorID: s.SensorID,
|
||||
},
|
||||
&types.Temperature{
|
||||
TemperatureID: uuid.NewV4().String(),
|
||||
TemperatureValue: float64(temperatureValue),
|
||||
|
Reference in New Issue
Block a user