[22] Environment sensor
Description
Module with multiple integrated sensors for measuring environment conditions. It contains light, humidity and barometer sensors, allowing to monitor a variety of parameters.
Features:
Detection of:
- Luminosity
- Infrared
- Color (RGB)
- Air temperature (internal & external NTC)
- Air humidity
- Atmospheric pressure
- Altitude
Code examples
Arduino projects: 22_sensor
#include <TotemModule22.h>
TotemModule22 module;
Function usage (click to expand)
/* Light */
// Get amount of red color "1561"
int colorR = module.getColorR();
// Get amount of green color "156581"
int colorG = module.getColorG();
// Get amount of green color "215017"
int colorB = module.getColorB();
// Get amount of infrared light
int getIR = module.getIR();
// Get luminosity
int getLumen = module.getLumen();
// Set light sensor gain
module.setLightSensorGain(18);
/* Temperature */
// Get air temperature Celsius
float tempC = module.getTempC();
// Get air temperature Fahrenheit
float tempF = module.getTempF();
// Get air temperature Kelvin
float tempK = module.getTempK();
/* NTC temperature */
// Get NTC sensor air temperature Celsius
float ntcTempC = module.getNtcC();
// Get NTC sensor air temperature Fahrenheit
float ntcTempF = module.getNtcF();
// Get NTC sensor air temperature Kelvin
float ntcTempK = module.getNtcK();
// Get NTC sensor resistance
int ntcR = module.getNtcResistance();
/* Humidity */
// Get air humidity
int humidity = module.getHumidity();
/* Pressure */
// Get air pressure Pascal
float pressurePa = module.getPressurePa();
// Get air pressure Hectopascal
float pressurehPa = module.getPressurehPa();
// Get air pressure Millibar
float pressureMbar = module.getPressureMbar();
// Get air pressure Bar
float pressureBar = module.getPressureBar();
// Get air pressure Pound per Square Inch
float pressurePsi = module.getPressurePsi();
/* Altitude */
// Get altitude Meters
float altitudeM = module.getAltitudeMeter();
// Get altitude Foot
float altitudeFt = module.getAltitudeFoot();
// Get altitude Inches
float altitudeInch = module.getAltitudeInch();
// Set sea level air pressure
module.setAltitudeSeaLevel(101325);
/* LED control */
// Turn LED on
module.led.on();
// Turn LED off
module.led.off();
// Set LED to on
module.led.set(HIGH);
// Toggle LED state on / off
module.led.toggle();
// Check if LED is on
bool isOn = module.led.isOn();
Functions
Light
Light sensor is able to read amount of detected light and its color saturation. If you trying to get precise measurements, turn of on-board red LED which may induce some red shade into sensor. Use function module.led.off()
for that.
saturation
module.getColorR()
¶
saturation
module.getColorG()
¶
saturation
module.getColorB() ¶-
Get precise amount of specified color. Higher value means more color in light is detected.
Returns:
saturation
- 18-bit amount of red color [0
:262143
] saturation
module.getIR() ¶-
Get precise amount of infrared light hitting the sensor.
Returns:
saturation
- 18-bit amount of infrared light [0
:262143
] saturation
module.getLumen() ¶-
Get precise amount of light (luminosity) hitting the sensor.
Returns:
saturation
- 18-bit amount of light [0
:262143
] module.setLightSensorGain(
gain
) ¶-
Set light sensor gain.
Parameter:
gain
- gain value [1
,3
,6
,9
,18
]. Default:18
Temperature
temperatureC
module.getTempC()
¶
temperatureF
module.getTempF()
¶
temperatureK
module.getTempK() ¶-
Get air temperature. Multiple units available.
Returns:
temperatureC
- Celsius (float) (24.75
)C
temperatureF
- Fahrenheit (float) (76.55
)F
temperatureK
- Kelvin (float) (297.9
)K
NTC temperature
Module supports external Thermistor. It should be soldered or connected to NTC pins. Once connected, module will start measurements automatically.
temperatureC
module.getNtcC()
¶
temperatureF
module.getNtcF()
¶
temperatureK
module.getNtcK() ¶-
Get NTC sensor temperature. Multiple units available.
Returns:
temperatureC
- Celsius (float) (24.75
)C
temperatureF
- Fahrenheit (float) (76.55
)F
temperatureK
- Kelvin (float) (297.9
)K resistance
module.getNtcResistance() ¶-
Get NTC sensor resistance in (Ohms). Module use it to compute air temperature.
Returns:
resistance
- thermistor resistance in Ohms.0
- not connected
Humidity
humidity
module.getHumidity() ¶-
Get percentage of air humidity.
Returns:
humidity
- humidity [0
:100
]%
Pressure
pressurePa
module.getPressurePa()
¶
pressurehPa
module.getPressurehPa()
¶
pressureMbar
module.getPressureMbar()
¶
pressureBar
module.getPressureBar()
¶
pressurePsi
module.getPressurePsi() ¶-
Get atmospheric air pressure. Multiple units available.
Returns:
pressurePa
- Pascal (float) (90000
)Pa
pressurehPa
- Hectopascal (float) (900
)hPa
pressureMbar
- Millibar (float) (900
)mbar
pressureBar
- Bar (float) (0.9
)bar
pressurePsi
- Pound per Square Inch (float) (13.05
)psi
Altitude
Altitude calculation (altimeter) works by comparing current air pressure to a reference point (sea level). Sea level air pressure vary between locations and weather. For precise measurements - set it with function setSeaLevel()
. Default setting is 101325
Pascals (1013.25 mbar).
altitudeM
module.getAltitudeMeter()
¶
altitudeFt
module.getAltitudeFoot()
¶
altitudeInch
module.getAltitudeInch() ¶-
Get sensor altitude above sea level. Multiple units available.
Returns:
altitudeM
- Meters (float) (100
)m
altitudeFt
- Foot (float) (328.084
)ft
altitudeInch
- Inches (float) (3937.01
)inch module.setAltitudeSeaLevel(
pressure
) ¶-
Set air pressure at sea level for altitude calculation.
Parameter:
pressure
- pressure at sea level in Pascal units. Default:101325
Pa
LED control
module.led.on() ¶
-
Turn LED on.
module.led.off() ¶
-
Turn LED off.
module.led.set(
state
) ¶-
Set LED to specific state (on / off).
Parameter:
state
- state on / off [HIGH
:LOW
] or [true
:false
] module.led.toggle() ¶
-
Toggle LED between on / off states.
state
module.led.isOn() ¶-
Check if LED is on.
Returns:
state
- LED is on [true
:false
] or [HIGH
:LOW
].
Low level commands
These are low level TotemBUS commands accepted by module. Is not required when using objective API described above.
Command list
Command | Parameters | Description |
---|---|---|
color |
Returns:(int ) |
Get RGB HEX color |
color/R |
Returns:(int ) |
Get precise red color |
color/G |
Returns:(int ) |
Get precise blue color |
color/B |
Returns:(int ) |
Get precise green color |
light/IR |
Returns:(int ) |
Get infrared amount |
light/lumen |
Returns:(int ) |
Get lumen amount |
light/gain |
(byte ) |
Set sensor gain |
nfc |
Returns:(int ) |
Get external NTC temperature Celsius |
nfc/C |
Returns:(int ) |
Get external NTC temperature Celsius |
nfc/F |
Returns:(int ) |
Get external NTC temperature Fahrenheit |
nfc/K |
Returns:(int ) |
Get external NTC temperature Kelvin |
nfc/R |
Returns:(int ) |
Get external NTC resistance (Ohms) |
temperature |
Returns:(int ) |
Get temperature Celsius |
temperature/C |
Returns:(int ) |
Get temperature Celsius |
temperature/F |
Returns:(int ) |
Get temperature Fahrenheit |
temperature/K |
Returns:(int ) |
Get temperature Kelvin |
humidity |
Returns:(int ) |
Get humidity (%) |
pressure |
Returns:(int ) |
Get pressure Millibar |
pressure/mbar |
Returns:(int ) |
Get pressure Millibar |
pressure/Pa |
Returns:(int ) |
Get pressure Pascal |
pressure/hPa |
Returns:(int ) |
Get pressure Hectopascal |
pressure/psi |
Returns:(int ) |
Get pressure Pound per square inch |
altitude |
Returns:(int ) |
Get altitude meters |
altitude/m |
Returns:(int ) |
Get altitude meters |
altitude/ft |
Returns:(int ) |
Get altitude foot |
altitude/seaLevel |
(int ) |
Set sea level pressure (Pascal) |
led |
(bool ) |
Set LED on/off |