Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Amaan Javed
Published

M5STACK Touch Less Entry

On hand gesture, you can open the door without touching the handle M5STACK AND NODEMCU USED.

IntermediateFull instructions provided1 hour1,808
M5STACK Touch Less Entry

Things used in this project

Story

Read more

Code

NodeMCU (on board com)

Arduino
//////////////////AMAAN JAVED////////////////////
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <Servo.h>
Servo myservo;
const char *ssid = "ESPdoor";
const char *password = "12345678";

ESP8266WebServer server(80);

void handleRoot() {
  server.send(200, "text/html", "<h1>You are connected</h1>");
}

void ope(){
  myservo.write(90); 
  delay(10000);
  myservo.write(0); 
}
void setup() {
  delay(1000);
   myservo.write(0); 
  Serial.begin(115200);
  Serial.println();
  Serial.print("Configuring access point...");
  WiFi.softAP(ssid, password);
  myservo.attach(5);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.on("/", handleRoot);
  server.on("/ope", ope);
  server.begin();
  Serial.println("HTTP server started");
}
void loop() {
  Serial.println("Waiting for the link");
  server.handleClient();
}
//////////////////AMAAN JAVED////////////////////

M5STACK

Arduino
//////////////////AMAAN JAVED////////////////////
#define M5STACK_MPU6050 
#include <M5Stack.h>
#include <WiFi.h>
#include <HTTPClient.h>
float pitch = 0.0F;
float roll  = 0.0F;
float yaw   = 0.0F;
const char* ssid ="ESPdoor";
const char* password ="12345678";
void setup(){
  M5.begin();  
  M5.Power.begin();   
  M5.IMU.Init();
  for(uint8_t t = 4; t > 0; t--) {
        Serial.printf("[SETUP] WAIT %d...\n", t);
        Serial.flush();
        delay(1000);
    }
      WiFi.mode(WIFI_STA);
      WiFi.disconnect(true);
    WiFi.begin(ssid,password);
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    M5.Lcd.print(".");
 
    delay(15000);
    M5.Lcd.println("Connected");
  }
}
void loop() {
   
  M5.IMU.getAhrsData(&pitch,&roll,&yaw);
  if((WiFi.status() == WL_CONNECTED)) {

        HTTPClient http;      
  
  if(roll >= 40){
  M5.Lcd.print("[HTTP] begin...\n");
        
        http.begin("http://192.168.4.1/ope"); 
        M5.Lcd.fillScreen(GREEN);      
        int httpCode = http.GET();

        http.end();
    
    }    
    else{
       M5.Lcd.fillScreen(RED);
      }
  }
    
  delay(1);
}//////AMAAN JAVED/////////////

Credits

Amaan Javed
19 projects • 4 followers
Student

Comments