Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Melroy van den Berg
AIR Quality Meter
Commits
551916a6
Commit
551916a6
authored
May 12, 2019
by
Melroy van den Berg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments
parent
7595b0db
Pipeline
#1073
passed with stages
in 14 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
src/controller.cc
src/controller.cc
+19
-3
No files found.
src/controller.cc
View file @
551916a6
...
@@ -80,7 +80,9 @@ int Controller::OpenI2C() {
...
@@ -80,7 +80,9 @@ int Controller::OpenI2C() {
return
i2c_fd
;
return
i2c_fd
;
}
}
/**
* \brief Initialize Temp/Humid/Pressure sensor
*/
void
Controller
::
InitTempSensor
(
int
i2c_fd
)
{
void
Controller
::
InitTempSensor
(
int
i2c_fd
)
{
bme280_settings
settings
;
bme280_settings
settings
;
// Set indoor settings
// Set indoor settings
...
@@ -107,10 +109,16 @@ void Controller::InitTempSensor(int i2c_fd) {
...
@@ -107,10 +109,16 @@ void Controller::InitTempSensor(int i2c_fd) {
SetAbsoluteHumidity
();
SetAbsoluteHumidity
();
}
}
/**
* \brief Initialize CO2 sensor
*/
void
Controller
::
InitCO2Sensor
()
{
void
Controller
::
InitCO2Sensor
()
{
this
->
mhz19b
=
new
MHZ19B
();
this
->
mhz19b
=
new
MHZ19B
();
}
}
/**
* \brief Initialize fine dust sensor
*/
void
Controller
::
InitDustSensor
()
{
void
Controller
::
InitDustSensor
()
{
this
->
pmsa
=
new
PMSA003
();
this
->
pmsa
=
new
PMSA003
();
if
(
!
pmsa
->
Init
())
{
if
(
!
pmsa
->
Init
())
{
...
@@ -119,6 +127,9 @@ void Controller::InitDustSensor() {
...
@@ -119,6 +127,9 @@ void Controller::InitDustSensor() {
// Wait 30 secs from sleep mode, before stable
// Wait 30 secs from sleep mode, before stable
}
}
/**
* \brief Initialize TVOC Gas sensor
*/
void
Controller
::
InitGasSensor
(
int
i2c_fd
)
{
void
Controller
::
InitGasSensor
(
int
i2c_fd
)
{
this
->
sgp
=
new
SGP30
(
i2c_fd
);
this
->
sgp
=
new
SGP30
(
i2c_fd
);
// Select the sensor on the bus
// Select the sensor on the bus
...
@@ -139,8 +150,13 @@ void Controller::InitGasSensor(int i2c_fd) {
...
@@ -139,8 +150,13 @@ void Controller::InitGasSensor(int i2c_fd) {
// TODO: first 20 seconds after init, returns fixed values (so should be ignored)
// TODO: first 20 seconds after init, returns fixed values (so should be ignored)
}
}
/**
* \brief Get a single temperature/humidity reading, calculate absolute humidity and store it
*/
void
Controller
::
SetAbsoluteHumidity
()
{
void
Controller
::
SetAbsoluteHumidity
()
{
// TODO: Select sensor on I2C bus?
if
(
!
bme
->
Select
())
{
throw
std
::
runtime_error
(
"Could not select the temp/humid/pressure sensor!
\n
"
);
}
bme
->
SetSensorMode
(
BME280_FORCED_MODE
);
bme
->
SetSensorMode
(
BME280_FORCED_MODE
);
// 1/60Hz = 60000 ms
// 1/60Hz = 60000 ms
...
@@ -227,7 +243,7 @@ bool Controller::GasReading() {
...
@@ -227,7 +243,7 @@ bool Controller::GasReading() {
if
(
!
sgp
->
Select
())
{
if
(
!
sgp
->
Select
())
{
throw
std
::
runtime_error
(
"Could not select the gas sensor!
\n
"
);
throw
std
::
runtime_error
(
"Could not select the gas sensor!
\n
"
);
}
}
int
counter
=
0
;
int
counter
=
0
;
while
(
counter
<
40
)
{
while
(
counter
<
40
)
{
// Do measurement
// Do measurement
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment