Sensors
Connect to different sensors to read data.
Functions
IMU and Environmental Sensors
Sensor Objects
mpu9250 | Connect to MPU-9250 sensor on Arduino hardware I2C bus |
lsm9ds1 | Connect to LSM9DS1 sensor on Arduino hardware I2C bus |
mpu6050 | Connect to MPU-6050 sensor on Arduino hardware I2C bus |
lsm303c | Connect to LSM303C sensor Arduino hardware I2C bus (Since R2021a) |
lsm6ds3 | Connect to LSM6DS3 sensor on Arduino hardware I2C bus (Since R2021a) |
lsm6ds3h | Connect to LSM6DS3H sensor on Arduino hardware I2C bus (Since R2021a) |
lsm6dsl | Connection to LSM6DSL sensor on Arduino hardware I2C bus (Since R2021a) |
lsm6dsm | Connect to LSM6DSM sensor on Arduino hardware I2C bus (Since R2021a) |
lsm6dso | Connect to LSM6DSO sensor on Arduino hardware I2C bus (Since R2021a) |
lsm6dsr | Connect to LSM6DSR sensor on Arduino hardware I2C bus (Since R2021a) |
hts221 | Connect to HTS221 sensor on Arduino hardware I2C bus (Since R2021a) |
lps22hb | Connect to LPS22HB sensor on Arduino hardware I2C bus (Since R2021a) |
adxl345 | Connect to ADXL345, ADXL343, ADXL344, or ADXL346 sensor on Arduino hardware I2C bus (Since R2022a) |
icm20948 | Connect to ICM-20948 sensor on Arduino hardware I2C bus (Since R2022a) |
bmp280 | Connect to BMP280 sensor on Arduino hardware I2C bus (Since R2022b) |
lis3dh | Connect to LIS3DH sensor on Arduino hardware I2C bus (Since R2022b) |
bmi160 | Connect to BMI160 sensor on Arduino hardware I2C bus (Since R2023a) |
adis16505 | Connect to ADIS16505 sensor on Arduino hardware SPI bus (Since R2024a) |
Sensor Functions
flush | Flush the host buffer |
info | Read information related to sensor |
read | Read real-time sensor data at a specified rate |
readAcceleration | Read one sample of acceleration from sensor |
readAngularVelocity | Read one sample of angular velocity from sensor |
readMagneticField | Read one sample of magnetic field from sensor |
readTemperature | Read one sample of temperature from sensor (Since R2021a) |
readHumidity | Read one sample of relative humidity data from the sensor (Since R2021a) |
readPressure | Read one sample of barometric air pressure data from the sensor (Since R2021a) |
readVoltage | Read voltage from ADC pins on sensor (Since R2023a) |
release | Release the sensor object |
stop | Stop data collection from sensor object (Since R2020a) |
BNO055 Sensor
bno055 | Connect to BNO055 sensor on Arduino hardware I2C bus (Since R2020a) |
flush | Flush the host buffer for BNO055 sensor |
info | Read output data rate and bandwidth setting of BNO055 sensor |
read | Read acceleration, angular velocity, magnetic field, time, and overrun data from BNO055 sensor |
readAcceleration | Read one sample of acceleration from BNO055 sensor |
readAngularVelocity | Read one sample of angular velocity from BNO055 sensor |
readCalibrationStatus | Read calibration status of BNO055 sensor |
readMagneticField | Read one sample of magnetic field strength from BNO055 sensor |
readOrientation | Read orientation data from BNO055 sensor |
release | Release the BNO055 object |
GPS
gpsdev | Connect to GPS receiver on Arduino hardware (Since R2020a) |
flush | Flush the host buffer (Since R2020a) |
info | Read Update Rate, GPS Lock information and number of satellites in View for the GPS receiver (Since R2020a) |
read | Read data from GPS (Since R2020a) |
release | Release the GPS object (Since R2020a) |
stop | Stop data collection from GPS module (Since R2020a) |
writeBytes | Write raw data to GPS module (Since R2020a) |
APDS9960
apds9960 | Connect to APDS9960 sensor on Arduino hardware using I2C bus (Since R2021b) |
readColor | Reads clear light and RGB components through APDS9960 sensor (Since R2021b) |
readGesture | Read gesture through APDS9960 sensor (Since R2021b) |
readProximity | Read the proximity from APDS9960 sensor (Since R2021b) |
Ultrasonic Sensor
ultrasonic | Connection to ultrasonic sensor on Arduino hardware |
readDistance | Distance to object in front of ultrasonic sensor |
readEchoTime | Read echo time of ultrasound waves |
Topics
- Read and Plot Real-Time Data from BNO055 Sensor in NDOF Mode
This example shows you how to read and plot calibrated data from a Bosch Sensortec BNO055 a 9-axis absolute orientation sensor in real time.
- Calibrate BNO055 Sensors
Steps to calibrate the BNO055 sensors.
- Limitations
Limitations when using sensors and GPS receiver.
- Calculate Pitch and Roll on Arduino Using IMU Sensor (Simulink)
This example shows how to read the acceleration and angular velocity data from IMU sensor mounted on Arduino® hardware and calculate the pitch and roll angles.
- Measure LSM9DS1 Sensor Outputs Using Nano 33 BLE Sense
Read data from a LSM9DS1 sensor using Bluetooth®.
Troubleshooting
Troubleshoot sensors.
Featured Examples
Estimating Orientation Using Inertial Sensor Fusion and MPU-9250
Get data from an InvenSense MPU-9250 IMU sensor, and to use the 6-axis and 9-axis fusion algorithms in the sensor data to compute orientation of the device.
Wireless Data Streaming Using BNO055 and Bluetooth and Estimating Orientation Using Sensor Fusion
Get data from a Bosch BNO055 IMU sensor through HC-05 Bluetooth® module and to use the 9-axis AHRS fusion algorithm on the sensor data to compute orientation of the device. The example creates a figure which gets updated as you move the device.
Plot Position Using GPS Connected to Arduino Hardware
Get the geographic location using the GPS module connected on Arduino hardware and plot the location in a map.
IoT-Based Automatic Cooling Fan Control Using ThingSpeak and Arduino Hardware
Create a ThingSpeak™ channel and use the MATLAB® functions to collect the temperature data from a BMP280 sensor connected to your Arduino® board, and then use MATLAB Analysis in ThingSpeak to trigger the automatic control of a CPU cooling fan kept in the room and then monitor the usage of the fan by calculating the runtime. This example also shows you how to set up an email alert if the fan turns on, by using MATLAB functions in ThingSpeak.
IoT-Based Temperature Monitoring Using ThingSpeak and Arduino Hardware
Create a ThingSpeak™ channel and use MATLAB® functions to collect the temperature data from a BMP280 sensor connected to your Arduino® board, and then use MATLAB Analysis in ThingSpeak to analyze the maximum and minimum temperature. This example also shows you how to set up an email alert if the room temperature exceeds a threshold value, by using MATLAB functions in ThingSpeak.
Classify and Count Fruits Using Arduino Nano 33 BLE Sense, ThingSpeak, and Machine Learning
Collect RGB values of three types of fruits using the APDS9960 sensor embedded in an Arduino® Nano 33 BLE board and use the MATLAB® Classification Learner app to train a machine learning model with the RGB values to classify the fruits. This example also shows how to use the ThingSpeak™ platform for tracking the number of fruits in a box and setting up an email alert if the number of any one of the three types of fruits drops to zero.
Identify Shapes Using Machine Learning on Arduino Nano 33 BLE Sense Hardware
Use MATLAB® Support Package for Arduino® Hardware to identify shapes using a machine learning algorithm. This example uses the Arduino Nano 33 BLE Sense hardware board with an onboard LSM9DS1 inertial measurement unit (IMU) sensor.
Human Activity Recognition Using ESP32 Board and LSM9DS1 IMU Sensor
Classify and predict one of three different physical human activities: Sitting, Standing and Walking based on data acquired using an ESP32 board and an LSM9DS1 sensor. This example uses Classification Learner app to train a machine learning model with the sensor data. To access all the files for this example, click Open Live Script and download the attached files.
Perform Predictive Maintenance on Rotating Device Using ESP32 Board, ThingSpeak, and Machine Learning
Predict and monitor the health of a rotating device using machine learning algorithm. You can use this example for predictive maintenance of any rotating device or piece of equipment so that you can fix them before they fail.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)