Random Stuff We Make!
Published © GPL3+

The Sorcerous Glove

A smart IoT glove.

IntermediateFull instructions provided6 hours1,662

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×2
SparkFun Triple Axis Accelerometer and Gyro Breakout - MPU-6050
SparkFun Triple Axis Accelerometer and Gyro Breakout - MPU-6050
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Buzzer
Buzzer
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×2
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
thread

Story

Read more

Schematics

Schematics

Door Circuit

Schematics

Glove Circuit

Code

Door Code

Arduino
This code is for the Node mcu attached on the door with servo. Upload Via Arduino IDE
//DOOR NODE MCU 

#include <ESP8266WiFi.h>
#include <Servo.h>


Servo myservo; 
byte ledPin = 2;
char ssid[] = "Wemos_AP";           // SSID of your AP
char pass[] = "Wemos_comm";         // password of your AP

IPAddress server(192,168,4,15);     // IP address of the AP
WiFiClient client;

void setup() {
  myservo.attach(14);
  myservo.write(0);
  pinMode(D2,OUTPUT);
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);           // connects to the WiFi AP
  Serial.println();
  Serial.println("Connection to the AP");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.println("Connected");
  Serial.println("station_bare_01.ino");
  Serial.print("LocalIP:"); Serial.println(WiFi.localIP());
  Serial.println("MAC:" + WiFi.macAddress());
  Serial.print("Gateway:"); Serial.println(WiFi.gatewayIP());
  Serial.print("AP MAC:"); Serial.println(WiFi.BSSIDstr());
  pinMode(ledPin, OUTPUT);
}

void loop() {

  client.connect(server, 80);
  
 
 String ans  = "high";
 String ans1 = "low";
 String ans2 = "dooropen";
 String ans3 = "alarm";
 String answer = client.readStringUntil('\r');
  Serial.println("   ");
  Serial.write("   ");
  
 if(answer.equals(ans))
  {
  
   Serial.write('1'); //bulb on
 
  }

  if(answer.equals(ans1))
  {
   //Serial.println(answer);
//   Serial.clear();
   Serial.write('0'); //buld off
  //digitalWrite(D5,LOW);
  }
  if(answer.equals(ans2))
  {  Serial.println(answer);
   for (int i=0;i<180;i++)
      {
        myservo.write(i);
        delay(10);
      }
    for (int i=180;i>0;i--)
      {
        myservo.write(i);
        delay(10);
     }   
  }
  if(answer.equals(ans3))
  {
  //alarm
  Serial.println(answer);
  digitalWrite(D2,HIGH);
  delay(1000);
  digitalWrite(D2,LOW);
  delay(400);
  digitalWrite(D2,HIGH);
  delay(1000);
  digitalWrite(D2,LOW);
  delay(400);
  digitalWrite(D2,HIGH);
  delay(1000);
  digitalWrite(D2,LOW);
  delay(400);
  digitalWrite(D2,HIGH);
  delay(1000);
  digitalWrite(D2,LOW);
  delay(400);
  digitalWrite(D2,HIGH);
  delay(1000);
  digitalWrite(D2,LOW);
  delay(400);
  digitalWrite(D2,HIGH);
  delay(1000);
  digitalWrite(D2,LOW);
  delay(400);
  digitalWrite(D2,HIGH);
  delay(1000);
  digitalWrite(D2,LOW);
  delay(400);
  }
  
  client.flush();
 
}

Glove Code

Arduino
This code is for the glove circuit
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
#include <ESP8266WiFi.h>

Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);

WiFiServer server(80);
IPAddress IP(192,168,4,15);
IPAddress mask = (255, 255, 255, 0);

int ledPin = 2;
int flag = 0;
void displaySensorDetails(void)
{
  sensor_t sensor;
  accel.getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" m/s^2");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" m/s^2");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" m/s^2");  
  Serial.println("------------------------------------");
  Serial.println("");
  delay(500);
}
void displayDataRate(void)
{
  Serial.print  ("Data Rate:    "); 
  
  switch(accel.getDataRate())
  {
    case ADXL345_DATARATE_3200_HZ:
      Serial.print  ("3200 "); 
      break;
    case ADXL345_DATARATE_1600_HZ:
      Serial.print  ("1600 "); 
      break;
    case ADXL345_DATARATE_800_HZ:
      Serial.print  ("800 "); 
      break;
    case ADXL345_DATARATE_400_HZ:
      Serial.print  ("400 "); 
      break;
    case ADXL345_DATARATE_200_HZ:
      Serial.print  ("200 "); 
      break;
    case ADXL345_DATARATE_100_HZ:
      Serial.print  ("100 "); 
      break;
    case ADXL345_DATARATE_50_HZ:
      Serial.print  ("50 "); 
      break;
    case ADXL345_DATARATE_25_HZ:
      Serial.print  ("25 "); 
      break;
    case ADXL345_DATARATE_12_5_HZ:
      Serial.print  ("12.5 "); 
      break;
    case ADXL345_DATARATE_6_25HZ:
      Serial.print  ("6.25 "); 
      break;
    case ADXL345_DATARATE_3_13_HZ:
      Serial.print  ("3.13 "); 
      break;
    case ADXL345_DATARATE_1_56_HZ:
      Serial.print  ("1.56 "); 
      break;
    case ADXL345_DATARATE_0_78_HZ:
      Serial.print  ("0.78 "); 
      break;
    case ADXL345_DATARATE_0_39_HZ:
      Serial.print  ("0.39 "); 
      break;
    case ADXL345_DATARATE_0_20_HZ:
      Serial.print  ("0.20 "); 
      break;
    case ADXL345_DATARATE_0_10_HZ:
      Serial.print  ("0.10 "); 
      break;
    default:
      Serial.print  ("???? "); 
      break;
  }  
  Serial.println(" Hz");  
}
void displayRange(void)
{
  Serial.print  ("Range:         +/- "); 
  
  switch(accel.getRange())
  {
    case ADXL345_RANGE_16_G:
      Serial.print  ("16 "); 
      break;
    case ADXL345_RANGE_8_G:
      Serial.print  ("8 "); 
      break;
    case ADXL345_RANGE_4_G:
      Serial.print  ("4 "); 
      break;
    case ADXL345_RANGE_2_G:
      Serial.print  ("2 "); 
      break;
    default:
      Serial.print  ("?? "); 
      break;
  }  
  Serial.println(" g");  
}
void setup() 
{


#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif
  Serial.begin(9600);
  Serial.println("Accelerometer Test"); Serial.println("");
  
  /* Initialise the sensor */
  if(!accel.begin())
  {
    /* There was a problem detecting the ADXL345 ... check your connections */
    Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");
    while(1);
  }

  
  accel.setRange(ADXL345_RANGE_16_G);

  displaySensorDetails();
  
 
  displayDataRate();
  displayRange();
  Serial.println("");

  WiFi.mode(WIFI_AP);
  WiFi.softAP("Wemos_AP", "Wemos_comm");
  WiFi.softAPConfig(IP, IP, mask);
  server.begin();
  pinMode(D5, INPUT);
  Serial.println();
  Serial.println("accesspoint_bare_01.ino");
  Serial.println("Server started.");
  Serial.print("IP: ");     Serial.println(WiFi.softAPIP());
  Serial.print("MAC:");     Serial.println(WiFi.softAPmacAddress());
}

void loop() {
    sensors_event_t event; 
  accel.getEvent(&event);

  WiFiClient client = server.available();
  if (!client) {return;}
  
  

  int flex = analogRead(A0);// flex sensor
  
  
  Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print("  ");
  Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print("  ");Serial.println(flex);
 
if ((flex >800 || flex<550) && flag==0)
{
Serial.println(client.println("high\r"));
Serial.println("BULB ON");
flag=1;
delay(2000);
}
flex = analogRead(A0);
if ((flex >800 || flex<550) && flag==1)
{
Serial.println(client.println("low\r"));
Serial.println("BULB OFF");
flag=0;
delay(2000);
}

if(event.acceleration.y > 8 || event.acceleration.y < -8)
{
Serial.println(client.println("dooropen\r"));
Serial.println("door");
}
if(event.acceleration.x > 8 || event.acceleration.x < -8)
{
Serial.println(client.println("alarm\r"));
Serial.println("alarm");}
if(event.acceleration.z > 0 || event.acceleration.z <0)
{
Serial.println(client.println("\r"));
}
}

Credits

Random Stuff We Make!

Random Stuff We Make!

15 projects • 50 followers
We at RSWM! try to bring Fiction to Reality through projects which are Interactive, Creative & way too simpler in terms of making.

Comments

Add projectSign up / Login