commit
933e31f281
@ -0,0 +1,17 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: clone
|
||||
|
||||
steps:
|
||||
- name: Test
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go env -w GO111MODULE=on
|
||||
- go env -w GOPROXY=https://goproxy.cn,direct
|
||||
- go test -v ./...
|
||||
- name: Benchmark
|
||||
image: golang:1.18
|
||||
commands:
|
||||
- go env -w GO111MODULE=on
|
||||
- go env -w GOPROXY=https://goproxy.cn,direct
|
||||
- go test -bench=. -benchmem
|
@ -0,0 +1,10 @@
|
||||
.env
|
||||
.git
|
||||
.svn
|
||||
.idea
|
||||
.vscode
|
||||
*.log
|
||||
gomod.sh
|
||||
*_test.go
|
||||
mod.sh
|
||||
/vendor/
|
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 李光春
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,17 @@
|
||||
<h1>
|
||||
<a href="https://www.dtapp.net/">Golang mq135</a>
|
||||
</h1>
|
||||
|
||||
📦 Golang mq135
|
||||
|
||||
[comment]: <> (go)
|
||||
[![godoc](https://pkg.go.dev/badge/go.dtapp.net/mq135?status.svg)](https://pkg.go.dev/go.dtapp.net/mq135)
|
||||
[![goproxy.cn](https://goproxy.cn/stats/go.dtapp.net/mq135/badges/download-count.svg)](https://goproxy.cn/stats/go.dtapp.net/mq135)
|
||||
[![goreportcard.com](https://goreportcard.com/badge/go.dtapp.net/mq135)](https://goreportcard.com/report/go.dtapp.net/mq135)
|
||||
[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/go.dtapp.net%2Fmq135)
|
||||
|
||||
#### 安装
|
||||
|
||||
```shell
|
||||
go get -v -u go.dtapp.net/mq135@v1.0.0
|
||||
```
|
@ -0,0 +1,36 @@
|
||||
package mq135
|
||||
|
||||
// 根据传感器电阻计算CO2 ppm的参数
|
||||
var (
|
||||
PARA float64 = 116.6020682
|
||||
PARB float64 = 2.769034857
|
||||
)
|
||||
|
||||
// 建模温度和湿度相关性的参数
|
||||
var (
|
||||
CORA float64 = .00035
|
||||
CORB float64 = .02718
|
||||
CORC float64 = 1.39538
|
||||
CORD float64 = .0018
|
||||
CORE float64 = -.003333333
|
||||
CORF float64 = -.001923077
|
||||
CORG float64 = 1.130128205
|
||||
)
|
||||
|
||||
// 用于校准目的的大气CO2水平
|
||||
var (
|
||||
ATMOCO2 float64 = 414.47 // Global CO2 Aug 2021
|
||||
)
|
||||
|
||||
// GetCorrectionFactor 获取校正系数以校正温度和湿度
|
||||
func GetCorrectionFactor(t float64, h float64) float64 {
|
||||
if t < 20 {
|
||||
return CORA*t*t - CORB*t + CORC - (h-33.)*CORD
|
||||
} else {
|
||||
return CORE*t + CORF*h + CORG
|
||||
}
|
||||
}
|
||||
|
||||
func GetCorrectedResistance(r float64, t float64, h float64) float64 {
|
||||
return r / GetCorrectionFactor(t, h)
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package mq135
|
||||
|
||||
const (
|
||||
Version = "1.0.0"
|
||||
)
|
Loading…
Reference in new issue