Akshet Patel
Published

Augmented Reality with Internet of Things (IoT)

Control AC Appliances using Augmented Reality Buttons over the Internet from anywhere in the world.

BeginnerFull instructions provided6 hours2,693
Augmented Reality with Internet of Things (IoT)

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Unity
Unity
Vuforia
VS Code
Microsoft VS Code
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram to Wire the NodeMCU development board

Code

ARwithIoT_Script.cs

C#
Just paste the code in VS Code and drag and drop the file in Unity3D Engine.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
using UnityEngine.Networking;

public class ARwithIoT_Script : MonoBehaviour
{
    public VirtualButtonBehaviour VB_ON;
    public VirtualButtonBehaviour VB_OFF;
    public string URL_ON;
    public string URL_OFF;

    IEnumerator GetRequest(string uri)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
        {
            // Request and wait for the desired page.
            yield return webRequest.SendWebRequest();

        }
    }

    void Start()
    {
        VB_ON.RegisterOnButtonPressed(OnButtonPressed_on);

        VB_OFF.RegisterOnButtonPressed(OnButtonPressed_off);
       
    }


    public void OnButtonPressed_on(VirtualButtonBehaviour VB_ON)
    {
        StartCoroutine(GetRequest(URL_ON));
        Debug.Log("LED IS ON");
    }

    public void OnButtonPressed_off(VirtualButtonBehaviour VB_OFF)
    {
        StartCoroutine(GetRequest(URL_OFF));
        Debug.Log("LED IS OFF");
    }

}

AR_with_IoT.ino

C/C++
Paste the code in the Arduino IDE and upload the code to your NodeMCU development board.
#define BLYNK_PRINT Serial
#define relay D0
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "your_authentication_token";
char ssid[] = "your_ssid_name";
char pass[] = "your_ssid_password";
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  digitalWrite(relay,pinValue);
    if(pinValue==1)
  {
    Serial.println("ON");
  }
  if(pinValue==0)
  {
    Serial.println("OFF");
  }
}
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(relay, OUTPUT);
}

void loop()
{
  Blynk.run();
}

Credits

Akshet Patel
3 projects • 6 followers
I am a senior at Manipal University Jaipur, working towards a Bachelor of Technology focused in Mechatronics Engineering.

Comments