Skip to content

[22] Environment sensor


Module with multiple integrated sensors for measuring environment conditions. It contains light, humidity and barometer sensors, allowing to monitor a variety of parameters.


Detection of:

  • Luminosity
  • Infrared
  • Color (RGB)
  • Air temperature (internal & external NTC)
  • Air humidity
  • Atmospheric pressure
  • Altitude

Totem Module 22

Code examples

Arduino projects: 22_sensor

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
/* 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
/* LED control */
// Turn LED on
// Turn LED off;
// Set LED to on
// Toggle LED state on / off
// Check if LED is on
bool isOn = module.led.isOn();



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 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.
saturation - 18-bit amount of red color [0:262143]

(saturation) module.getIR()

Get precise amount of infrared light hitting the sensor.
saturation - 18-bit amount of infrared light [0:262143]

(saturation) module.getLumen()

Get precise amount of light (luminosity) hitting the sensor.
saturation - 18-bit amount of light [0:262143]


Set light sensor gain.
gain - gain value [1,3,6,9,18]. Default: 18


(temperatureC) module.getTempC()

(temperatureF) module.getTempF()

(temperatureK) module.getTempK()

Get air temperature. Multiple units available.
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.
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.
resistance - thermistor resistance in Ohms. 0 - not connected


(humidity) module.getHumidity()

Get percentage of air humidity.
humidity - humidity [0:100]%


(pressurePa) module.getPressurePa()

(pressurehPa) module.getPressurehPa()

(pressureMbar) module.getPressureMbar()

(pressureBar) module.getPressureBar()

(pressurePsi) module.getPressurePsi()

Get atmospheric air pressure. Multiple units available.
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 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.
altitudeM - Meters (float) (100)m
altitudeFt - Foot (float) (328.084)ft
altitudeInch - Inches (float) (3937.01)inch


Set air pressure at sea level for altitude calculation.
pressure - pressure at sea level in Pascal units. Default: 101325Pa

LED control


Turn LED on.

Turn LED off.


Set LED to specific state (on / off).
state - state on / off [HIGH:LOW] or [true:false]


Toggle LED between on / off states.

(state) module.led.isOn()

Check if LED is on.
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 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