Phone Sensors Module

Phone Sensor Accelerometer&Gyroscope
Description

This module allows you to access the following inbuilt sensors of your Smartphone:

  • Accelerometer
  • Gyroscope
  • Proximity sensor
  • Magnetometer
  • Light meter
  • Sound meter
  • GPS Location
  • Temperature sensor
  • Barometer
Available in

Introduction

This phone sensor module allows you to access the following inbuilt sensors of your smartphone: Accelerometer, Gyroscope, Proximity sensor, Magnetometer, Light meter, Sound meter, GPS, Temperature sensor and Barometer.

Accelerometer

Senses the acceleration acting on your Smartphone in all three directions (X-axis, Y-axis, and Z-axis) in m/s2.

Dabble Phone Sensor Accelerometer & Gyroscope

Gyroscope

Senses the angular velocity in all three directions (X-axis, Y-axis, and Z-axis) in rad/s.

Magnetometer

Senses the magnetic field acting in all three directions (X-axis, Y-axis, and Z-axis) in µT. It can be used to move robots in a specific direction.

Dabble Phone Sensor Magnetometer Proximity Meter

Proximity sensor

Senses if there is an object near your Smartphone. If the object is nearby, 0.0000CM is displayed. Otherwise, a different number depending on the default setting of your phone is displayed.

Light meter

Senses the light falling on your Smartphone in Lux.

Dabble Phone Sensor Light Meter Sound Meter

Sound meter

Senses the intensity of nearby sound in dB. The module will ask you to provide audio record permission.

Dabble Phone Sensor Record Audio Permission

GPS

Shows the Longitude and Latitude of your current location. The module will ask you to provide location access permission.

Dabble Phone Sensor Sound Meter Location

Temperature sensor

Senses the temperature.

Phone Sensor Temperature Barometer

Barometer

Senses the pressure.

Arduino IDE Functions

Header

To include the Sensor  module in the Arduino program, you have to include the following header:

#define CUSTOM_SETTINGS

#define INCLUDE_SENSOR_MODULE

After defining the above mention headers, you have to include the dabble library:

#include <Dabble.h>

You can download the zip of Arduino Library for

  1. evive, Uno, Mega, and Nano – Dabble-Arduino 
  2. ESP32 – Dabble-ESP32

Enabling Bluetooth Communication

To enable Bluetooth communication, you have to initialize serial communication using the following code:

  1. For evive and Arduino Mega, Uno and Nano
    Dabble.begin(Baud_Rate);

    Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.

  2. For ESP32
    Dabble.begin("Bluetooth_Name");

    In place of Bluetooth_Name  enter name that you want to keep for Bluetooth of ESP32. Default name given in the library is “MyEsp32”. 

Refreshing the data

To refresh the data that the device has got from the mobile app, you have to use the following line of code:

Dabble.processInput();

Functions

FunctionReturn TypeBrief Description
Sensor.getAccelerometerXaxis()FloatReturns Accelerometer X value in m/s^2
Sensor.getAccelerometerYaxis()FloatReturns Accelerometer Y value in m/s^2
Sensor.getAccelerometerZaxis()FloatReturns Accelerometer Z value in m/s^2
Sensor.getGyroscopeXaxis()FloatReturns Gyroscope X value in rad/s
Sensor.getGyroscopeYaxis()FloatReturns Gyroscope Y value in rad/s
Sensor.getGyroscopeZaxis()FloatReturns Gyroscope Z value in rad/s
Sensor.getMagnetometerXaxis()FloatReturns Magnetometer X value in uT
Sensor.getMagnetometerYaxis()FloatReturns Magnetometer Y value in uT
Sensor.getMagnetometerZaxis()FloatReturns Magnetometer Z value in uT
Sensor.getProximityDistance()FloatReturns proximity sensor data. Returns 0 if the obstacle is ahead.
Sensor.getLightIntensity()FloatReturns the light sensor data in Lux
Sensor.getSoundDecibels()FloatReturns the sound sensor data in dB.
Sensor.getTemperature()FloatReturns the temperature in degree celcius
Sensor.getBarometerPressure()FloatReturns the barometer data in Pascals.
Sensor.getGPSlongitude()FloatReturns the Longitude data.
Sensor.getGPSlatitude()FloatReturns the Latitude data.

PictoBlox (Scratch) Blocks

You can get the phone sensors using a reporter blockget () reading”.

get sensor reading 2

In its drop-down, you will find various parameter related to phone sensors.

get sensor reading

evive Notes Icon
Note: When you are using this module with Arduino Uno, Mega, and Nano,  you have to set the Bluetooth baud rate to the baud rate of the Bluetooth module to have proper communication between the board and the module. To set the baud rate you have to use set bluetooth baud rate to () block.

set bluetooth baud rate to

Examples

Click here to view Arduino IDE Example for Phone Sensors Module

Example – Accelerometer

This program displays the accelerometer reading on the TFT display:

Example – Gyroscope

This program displays the gyroscope data on the TFT display of evive.

Example – Magnetometer

This program displays the magnetometer value on the TFT display.

Example – Proximity Sensor

The program turns ON the buzzer when there is an obstacle in front of the mobile.

Example – Sound Meter

This program displays the sound sensor reading on TFT display.

Example – Light Sensor

This example displays light sensor data on the TFT display of evive.

Example – GPS Location

This program displays the Latitude and Longitude of the GPS reading on the TFT display of evive.

Example – Temperature

This program displays the temperature sensor data on the TFT display.

Example – Barometer

This program displays the barometer reading (pressure) on the TFT display.

Click here to view PictoBlox (Scratch) Example for Phone Sensors Module

Example – Accelerometer

Displaying the values of Accelerometer parameters on TFT display.

accelerometer data display on screen

Example – Gyroscope

Displaying the values of Gyroscope parameters on TFT display.

gyroscope data display on screen

Example – Magnetometer

Displaying the values of Magnetometer parameters on TFT display.

magnetometer data display on screen

Example – Light Meter

Displaying the Light parameter on TFT display.

light data display on screen

Example – Proximity Meter

Sensing proximity and playing a tone on Buzzer accordingly.

proximity data display on screen

Example – GPS Location

Displaying the values of GPS parameters on TFT display.

GPS location data display on screen

Example – Sound Meter

Displaying the value of the sound parameter on the TFT display.

sound data display on screen

Example – Temperature

Displaying the value of the Temperature parameter on the TFT display.

temperature data display on screen

Example – Barometer

Displaying the value of the Barometer parameter on the TFT display.

Pressure data display on screen

Projects

Dabble-controlled-baby-mobile
DIY Dabble Controlled Baby Mobile

This project will show you how to make a DIY Dabble controlled baby mobile that will put a smile on any baby’s face!

All articles loaded
No more articles to load

This Post Has 3 Comments

  1. I tried to upload the code given to my Arduino Uno with all the necessary libraries included. However, an error message pops up, stating that an error occurred while compiling for the Uno board. It also states that it needs the 9th Analog pin (A9), which is not on the Uno. It also uses all 3 serial monitor available on a Mega, while the Uno only has one serial monitor. So I would like to ask, is this app is REALLY compatible with the Uno?

    1. It seems that the code you are trying to run is made for evive , hence you are getting this error with UNO. You can navigate to “Files>>Examples>>Dabble>>02.Uno Nano Mega>>08.Phone Sensor” in Arduino IDE to find examples appropriate for your UNO board.

Leave a Reply

Close Menu
×

Cart