A smart phone has many sensors built into the device such as accelerometer, gyroscope, GPS, light sensor, temperature, pressure, proximity, camera and many more. Magicblocks mobile app brings the inbuilt sensors and the capabilities of the mobile phone to the solution development environment of Magicblocks.io. This enables to get sensor data from the phone and use the phone as an input or an output device.
This app is used to send sensor values obtained from the sensors in your phone to a specific MQTT client. It is important to note that although there are many sensors in the app there should be specific sensors in your phone. The type of sensors in your phone varies from the brand and version of your phone. It is important to first identify the sensors inbuilt in your phone first.
Getting Started
To get started go to the app and click settings (Upper Left hand corner). Enter the necessary details in the given spaces. If you want to publish data to a specific MQTT broker enter the hostname and the port of it. It is also important to specify the publish and subscribe topic. There are also other options that you can try out according to your needs. When operating this app the phone should have a stable internet connection at all times.
Sensors
QR/Bar Code ScannerScans a QR code with your camera and send the data. It is important to give the app access to your camera
The format the data is sent:
{qr:{format:QR_CODE,content:}}
Accelerometer
An accelerometer is an electromechanical sensor used to measure acceleration forces. Units – X-axis ,Y-axis, Z-axis values measured in m/s2
The format the data is sent-{accelerometer:{x:2.84,y:0.44,z:10.02}}
Gyroscope
Gyro sensors, also known as angular rate sensors or angular velocity sensors, are devices that sense angular velocity.
Units – X-axis ,Y-axis, Z-axis values measured in rad/s
The format the data is sent-{gyroscope:{x:0.0,y:0.0,z:0.0}}
Proximity Sensor
A proximity sensor is a non-contact sensor that detects the presence of an object (often referred to as the “target”) when the target enters the sensor's field. Units – distance measured in cm
The format the data is sent:{proximity:{x:5.0}}
Light
This sensor gives the brightness of the area Units in lx
The format the data is sent:{{light:{illuminance:7.0}}
Temperature
Provides the temperature in the room. Units in celcius
The format the data is sent-{temperature:{temperature:7.0}}
Pressure
Measures the room pressure Units in hPa
The format the data is sent:
{pressure:{pressure:1009.56}}
Location
Give access to the app to access location. It gives the latitude and longitude location of the device in degrees and also the altitude of the current location in meters
The format the data is sent:
{gps:{alt:0.0,lon:80.06,lat:6.72}}
Settings
Go to settings on the top right corner. These are the settings that you should change to make your custom application. There are some required fields as well as optional fields that you should fill to get the app working.
Hostname – You should enter the name of your broker in this field. There are some free MQTT brokers we recommend you to use. They are,
broker.hivemq.com
mqtt.eclipse.org
*This is a required field.
Port- This is also a required field. It is best practice for you to leave the port default(1883)
Username- This is an optional requirement. It is good to add username for more security.
Password – This is an optional requirement. It is good to add username for more security.
ClientID - This is an optional requirement. If left blank the application will generate a clientID for the user.
Publish Topic – The user should specify the topic to which he/she is sending data to.
Subscribe Topic – The user should specify the topic to which the application should listen to receive data.
Data Push Interval – The rate at which data should be published.
QoS – For more information on MQTT QoS visit the official website of your MQTT broker.
After specifying the required field click save and go to the home page. Slide the slider to connect to the MQTT broker. If all goes well you will see ‘connected’ on the screen