Augmented Reality and Mixed Reality are the future of human interaction with the real world. Augmented Reality is a technology that allows projecting live images, videos, or media in the real-world environment along with the real objects visible through a camera or holographic wearable. The technology allows interacting with the real-world environment while manipulating it through computer-generated graphical elements and virtual interfaces. It is a way of modifying the view of the real-world environment by a computer.
In this project, Augmented Reality is used to monitor the sensor data supplied through an IoT board. The IoT board used in the project is Particle Photon. The Photon is installed in a remote place with various sensors (DHT 11 Temperature and Humidity Sensor, LDR Sensor, IR Proximity Sensor, and IR Sensor) interfaced to it. The board is connected to the cloud server and sends sensor data over the air to an Augmented Reality App. The app projects the sensor data as the camera of the Android phone focus on a target image.
Fig. 1: Image showing Augmented Reality App displaying Sensor Data
Particle Photon is an Arduino compatible IoT board. For writing the program code for any Photon, the developer needs to create an account on the Particle website and register the Photon board with his user account. The program code then can be written on Web IDE at the Particle’s website and transferred to a registered IOT board over the internet. If the selected Particleboard, Photon here, is switched on and connected to the cloud service of the Particle, the code is burnt to the selected board over the air via an internet connection, and the board starts operating according to the transferred code.
The Augmented Reality App used in the project is built using Vuforia Augmented Reality Software Development Kit and the Unity Editor. The development platform allows compiling a readily available database, upload target images, and creates UI elements on the Unity Editor. The user interface can be easily linked with the downloaded database by dragging and dropping UI elements. The application can then be linked with the data logging URL of the Photon board to capture real-time data. The platform allows compiling the project to a cross-platform mobile application for use on any smartphone.
Components Required –
IoT board circuit:
1. Particle Photon.
2. DHT11 sensor.
3. LDR sensor.
4. Any Wi-Fi connection.
5. IR sensor
6. BC547 transistor
7. 1K ohm resistor
8. 5 mm LED
9. Proximity sensor.
Mobile Side:
1. Any android phone
Block Diagram –
Fig. 2: Block Diagram of Particle Photon based Augmented Reality Sensor Data Monitor
Circuit Connections –
In the project, the circuit is built by interfacing various sensors to the Particle Photon. The circuit has the following components interfaced to the Photon in the manner mentioned below –
DHT-11 Temperature and Humidity Sensor – The DHT -11 sensor reads the ambient temperature and humidity and relays the data to the microcontroller as digital data. The data pin of temperature and humidity sensor DHT11 is connected to pin A0 of the Particle Photon, and VCC and ground are connected to the common VCC and ground.
LDR Sensor – The LDR is used to sense the intensity of light. The sensor is connected to the A1 pin of Particle Photon. The sensor is connected to a potential divider circuit. The LDR provides an analog voltage, which is converted to digital reading by the inbuilt ADC.
IR Sensor – The IR sensor is used to detect any obstacle. The sensor is connected to the A2 pin of Particle Photon. The sensor is connected to a potential divider circuit. The IR sensor provides an analog voltage, which is converted to digital reading by the inbuilt ADC.
IR Proximity Sensor – The IR proximity sensor detects the distance from an obstacle. The sensor module has three pins – VCC, Ground, and Output. The VCC and Ground are connected to the common VCC and Ground. The output pin of the sensor module is connected to the D0 pin of the Particle Photon. The sensor’s output is an analog voltage, which varies from 3.1 V at 10 cm to 0.4 V at 80 cm distance.
Power Supply – In the circuit, Photon and other ICs need a 5V regulated DC for their operation. An 18V battery is used as the primary source of power. The supply from the battery is regulated to 5V and 12V using 7805 and 7812 ICs. The pin 1 of both the voltage regulator ICs is connected to the battery’s anode, and pin 2 of both ICs is connected to ground. The respective voltage outputs are drawn from pin 3 of the respective voltage regulator ICs. A LED along with a 10K Ω pull-up resistor is also connected between common ground and output pin to get a visual hint of supply continuity.
How the circuit works –
Once the program code is transferred to Particle Photon, it starts operating according to it. The Particle Photon should be connected to any internet hotspot via Wi-Fi. The Arduino compatible code on Photon reads the data from sensors. Four sensors interfaced with the board – DHT 11 Temperature and Humidity Sensor, LDR sensor, IR sensor, and IR Proximity sensor.
DHT11 Temperature and Humidity Sensor is a digital sensor with a built-in capacitive humidity sensor and Thermistor. It relays real-time temperature and humidity readings every 2 seconds. The sensor operates on a 3.5 to 5.5 V supply and can read temperature between 0° C and 50° C and relative humidity between 20% and 95%. The DHT 11 Sensor sends data in the digital form to a controller pin on a one-wire protocol, which must be implemented on the firmware side. First, the data pin is configured to input, and a start signal is sent to it. The start signal comprises a LOW for 18 milliseconds followed by a HIGH for 20 to 40 microseconds followed by a LOW again for 80 microseconds and a HIGH for 80 microseconds. After sending the start signal, the pin is configured to the digital output, and 40-bit data comprising the temperature and humidity reading is latched out. The first two bytes of the 5-byte data are an integer and decimal part of reading for relative humidity, respectively. The third and fourth bytes are an integer and decimal part of reading for temperature, and the last one is checksum byte. The one-wire protocol is implemented on the firmware using an open-source library available for Photon.
The other sensors output an analog voltage at the respective controller pins. The analog voltage is read and digitized using a built-in ADC channel. The analogRead() function is used to read analog voltage at the controller pin.
The values from sensors are read and stored in different variables. Then, wrapped in formatted strings are passed to the data logging URL of Photon using the Particle library’s publication () method. The library is automatically imported and compiled by the Particle’s Web IDE and need not be imported explicitly.
The Augmented Reality App is linked to the data logging URL. It fetches the URL data and displays it on the buttons in the UI of the App. The buttons are projected once the camera is focused on the target image.
Check out the photon code to learn how the Arduino compatible code reads data from sensors and publish it on the linked data logging URL. Also, check out how the AR app is created using the Vuforia SDK and linked with the registered Photon board.
Programming Guide –
The AR app has been created using the Vuforia SDK and involves using the Unity Editor. The Augmented Reality app development using Vuforia SDK involves the following steps –
– Open Vuforia Developer Portal and register an account.
– Verify email ID and log in to the registered user account.
– Tap “Develop” from the navigation bar and click on “Target Manager”.
– Click on “Add Database” and enter a unique database name in the pop-up window. Keep “device” option selected and click “Create”
button.
– Click on the database name from the list of databases from the refreshed page and click on “Add Target” button. Select “Single Image” and browse the target image from the computer. Now the target image will be uploaded and shown on the list of targets.
– Click on “Download Database” button and select the “Unity Editor” as the pop-up window’s development platform. Click on “Download”
button. The database will be compiled and downloaded on the computer.
– Click on “Downloads” in the navigation bar and download Vuforia SDK for Unity.
– Click on “Develop” in the navigation bar and tap “License Manager”. Click on “Add License Key”. Enter an application name, select mobile from devices, select starter under license key, and click on “Next” button. Confirm to create the license key. On refreshing the page, the newly create license key will be displayed in the list. – Click on the license key name and copy the license key from the web page.=
– Open Unity Editor SDK. Create a New project and save it to a folder on the computer.
– In the Unity Editor SDK, “ARCamera” must be selected under “Hierarchy” on the left sidebar. Click on “Assets”-> “Import Package” ->
“Custom Package” and browse the Vuforia Package. Once the package is imported, again follow “Assets”-> “Import Package” -> “Custom
Package” and browse target image. Similarly, import the database earlier downloaded.
– Copy the license key and paste to “App License Key” under “Vuforia Behaviour” in the sidebar. Check “Load <database_name> database”
and “Activate” under “Database Load Behaviour”.
– Select “Image Target” under “Hierarchy” on the left sidebar and select the database name under “Image Target Behaviour” on the right sidebar. The target image will be displayed on the plane.
– Right-click in the “Hierarchy” window and select “UI” -> “Canvas”. Select “World Space” under “Render Mode” in the “Canvas” option in the
right sidebar and click twice on “Canvas” under Hierarchy” on the left sidebar.
– Under “Rect Transform” on the right sidebar, enter an appropriate position, rotation, and scale values and then click on “Add Component”.
Select “Image”. Click on the target image from the database and set “Texture Mode” to “Sprite.” Click on “Apply” and drag the image from
Database under “Project” to “Source Image” under “Canvas Renderer”. Change color and transparency level.
– Click on “Canvas” in the “Hierarchy” window and right-click and select “UI” -> “Button”. Change position, scale, color, and transparency settings
. Right Click on “Button” and Click “UI” -> “Text” to add text on the button. Select transform, font, and paragraph properties as desired. Add one more text to the button.
– Duplicate button by right click on it under the “Hierarchy” window and select “Duplicate”. Create five more buttons and change the text on them.
– Right-click in the “Hierarchy” window and click “Create Empty”. Rename the folder to “Code Container” and add scripts from the database to
the folder.
– Drag and Drop buttons and texts from “Image Target” in the “Hierarchy” window to the database on the right sidebar.
– Log in to Particle’s Web IDE and click on Dashboard Icon and click on “Logs”. Click on the log URL icon. Copy and paste URL to “Photon
Particle URL” under “Read Stream” in the right sidebar of database selected.
– Compile the project to create apk file.
The Photon code is as follows –
First of all, the library for the DHT sensor is imported. The particle’s Web IDE automatically adds the library. A constant is defined to denote the pin to which the DHT 11 sensor is interfaced, and a constant is defined to denote a variant of the DHT sensor. Variables to hold the value of temperature, humidity, light intensity, motion, and UV range are declared. Variables are declared to denote pins to which sensors are interfaced, and they are set to digital LOW by default to make them input pins. An object of a DHT type is declared.
The setup() function is called in which pin connected to Infrared proximity sensor is declared input pin using pinMode() function. The DHT sensor is initialized by calling begin() method on the DHT object. The setup() function is run only once at the start of the code.
The loop() iterates infinitely. In the loop() function, the data from the DHT sensor is fetched using getTempCelcius() and getHumidity() methods on the DHT object. The LDR sensor data is fetched by calling analogRead() method and converted to light intensity using standard formulae. The value from the IR sensor is read and converted to a distance measurement. A custom function pirSensor() is called to detect motion from the proximity sensor. The data from different sensors is stored in variables, wrapped in proper strings, and sent to the data logging URL using publish() method on Particle object.
Note: The completes Photon code for Augmented Reality based Sensor Data Display can be found in the code section.
You can find the link below to download the rar file of the Android app.
https://github.com/ EngineersGarage/Software/raw/ master/AR_Data.rar
You may also like:
Project Source Code
###
//Program to // based on; https://www.openhomeautomation.net/cloud-data-logger-particle-photon/ // ome useful stuff: http://jflasher.github.io/spark-helper/ // This #include statement was automatically added by the Particle IDE. #include "Adafruit_DHT/Adafruit_DHT.h" // This #include statement was automatically added by the Particle IDE. // DHT parameters #define DHTPIN A0 #define DHTTYPE DHT11 // Variables int temperature; int humidity; int light; int motion; int ultraviolet; int t = 100; // time int light_sensor_pin = A1; int pir = D0; int pirState = LOW; int uv = A2; // DHT sensor DHT dht(DHTPIN, DHTTYPE); void setup() { // Start DHT sensor pinMode(D7,OUTPUT); pinMode(pir,INPUT); dht.begin(); } void loop() { digitalWrite(D7,HIGH); // Humidity measurement temperature = dht.getTempCelcius(); // Humidity measurement humidity = dht.getHumidity(); // Light level measurement float light_measurement = analogRead(light_sensor_pin); light = (int)(light_measurement/4096*100); int uvValue=analogRead(uv); ultraviolet = (uvValue*100)/1023; // Publish data Particle.publish("temperature", String(temperature));// + " °C"); delay(t); Particle.publish("humidity", String(humidity));// + "%"); delay(t); Particle.publish("light", String(light));// + "%"); delay(t); pirSensor(); // motion sensor information delay(t); Particle.publish("ultraviolet", String(ultraviolet)); delay(t); digitalWrite(D7,LOW); delay(t); } void pirSensor() { motion = digitalRead(pir); // read input value Particle.publish("motion", "1"); // or 1 - We only want to print on the output change, not state if(motion==false) Particle.publish("motion", "0"); // or 0 - Serial.println("Motion ended!"); }
###
Circuit Diagrams
Filed Under: Electronic Projects, IoT
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.