In addition to the Core API enabling you to work with sensors via I2C or other means, there is a list of specific sensors made available to you to use with an easy-to-use interface.
This consists of well-known sensors. Feel free to request additional, or changes to existing.
Consider the BMP280 Temperature/Pressure Sensor
You could communicate with it using JavaScript I2C, or, instead, something much easier!
// create an instance of the sensor - addr automatically set to 0x40// (takes 50ms to return)letsensor=newSI7021()// get temperature in celsius// (takes 20ms to return)sensor.GetTemperatureCelsius()// get temperature in fahrenheit// (takes 20ms to return)sensor.GetTemperatureFahrenheit()// get humidity as a percent// (takes 20ms to return)sensor.GetHumidityPct()
// Create an instance of the sensor - addr either 0x76 or 0x77// (takes 120ms to return)letsensor=newBME280(addr)// Get temperature in Celsius// (takes 1ms to return)sensor.GetTemperatureCelsius()// Get temperature in Fahrenheit// (takes 1ms to return)sensor.GetTemperatureFahrenheit()// Get pressure in hPa// (takes 1ms to return)sensor.GetPressureHectoPascals()// Get pressure in millibar// (takes 1ms to return)sensor.GetPressureMilliBars()// Get altitude in Meters (estimated from sea level nominal pressure at 1013.25 hPa)// (takes 1ms to return)sensor.GetAltitudeMeters()// Get altitude in Feet (estimated from sea level nominal pressure at 1013.25 hPa)// (takes 1ms to return)sensor.GetAltitudeFeet()// Get humidity in percent// (takes 1ms to return)sensor.GetHumidityPct()
// Create an instance of the sensor - addr either 0x76 or 0x77// (takes 105ms to return)letsensor=newBMP280(addr)// Get temperature in Celsius// (takes 1ms to return)sensor.GetTemperatureCelsius()// Get temperature in Fahrenheit// (takes 1ms to return)sensor.GetTemperatureFahrenheit()// Get pressure in hPa// (takes 1ms to return)sensor.GetPressureHectoPascals()// Get pressure in millibar// (takes 1ms to return)sensor.GetPressureMilliBars()// Get altitude in Meters (estimated from sea level nominal pressure at 1013.25 hPa)// (takes 1ms to return)sensor.GetAltitudeMeters()// Get altitude in Feet (estimated from sea level nominal pressure at 1013.25 hPa)// (takes 1ms to return)sensor.GetAltitudeFeet()
// Create an instance of the sensor - addr either 0x23 or 0x5C// (takes 1ms to return)letsensor=newBH1750(addr)// Tell the sensor the current temperature so it can account for the effect on its measurement.// Default sensor temperature is 20C / 68F.// (takes 0ms to return)sensor.SetTemperatureCelsius(temp)// Tell the sensor the current temperature so it can account for the effect on its measurement.// Default sensor temperature is 20C / 68F.// (takes 0ms to return)sensor.SetTemperatureFahrenheit(temp)// Take a low-resolution lux measurement (resolution 4 lux)// (takes 40ms to return)sensor.GetLuxLowRes()// Take a high-resolution lux measurement (resolution 1 lux)// (takes 200ms to return)sensor.GetLuxHighRes()// Take a high2-resolution lux measurement (resolution 0.5 lux)// (takes 200ms to return)sensor.GetLuxHigh2Res()
// Create an instance of the sensor - addr automatically set to 0x30// (takes 25ms to return)letsensor=newMMC56x3()// Get field strength along X-Axis in MicroTesla (uT)// (takes 15ms to return)sensor.GetMagXMicroTeslas()// Get field strength along Y-Axis in MicroTesla (uT)// (takes 15ms to return)sensor.GetMagYMicroTeslas()// Get field strength along Z-Axis in MicroTesla (uT)// (takes 15ms to return)sensor.GetMagZMicroTeslas()