Code Monkey home page Code Monkey logo

rajeshiitk / secureye Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.34 MB

Nextjs web application that provides an admin panel for managing IoT devices, allows users to control various devices such as lights, air conditioners, and fans remotely using ESP8266 nodeMCU server,gate automation based on camera feedback and streaming live video feeds

Home Page: https://secureye-lime.vercel.app

JavaScript 0.30% CSS 0.20% TypeScript 99.50%
home-automation nextjs object-detection socket-io tensorflowjs webrtc esp8266-webserver tailwind typescript dht11 gate-controller temperature-humidity-monitoring

secureye's Introduction

NOTE: Please be advised that the main branch exclusively contains the code for object detection only. This decision is made with the intention of deploying the main branch on a serverless architecture. Additionally, the administration panel necessitates WebSocket functionality, inherently unsuitable for deployment on a serverless platform. Consequently, for access to the complete codebase including the admin dashboard and video streaming capabilities, kindly refer to the dev-only branch.

Secureye

Secureye is Nextjs web application that provides an admin panel for managing IoT devices and streaming live video feeds. It allows users to control various devices such as lights, air conditioners, and fans remotely using ESP8266 nodeMCU server, as well as view live video streams from surveillance cameras.

Features

  • Device Control: Control lights, air conditioners, and fans remotely from the admin panel.
  • Live Video Streaming: View live video streams from surveillance cameras in real-time using WebRTC and web socket.
  • Sensor Data Monitoring: Monitor temperature and humidity sensor data in the admin panel.
  • Responsive Design: User interface designed to be responsive and accessible across devices.
  • Real-time object detection using the COCO-SSD model.
  • Recording video and taking photo and toggle camera.

Technologies Used

  • Next.js: Framework for building React applications with server-side rendering and routing.
  • Socket.IO: Library for real-time web applications enabling bidirectional communication between clients and servers.
  • TensorFlow.js: Machine learning framework for JavaScript applications.
  • Tailwind CSS: Utility-first CSS framework for quickly building custom designs.
  • Axios: Promise-based HTTP client for making API requests.

Architecture Design

Architecture

Getting Started

  1. Clone the repository:

    git clone https://github.com/rajeshiitk/secureye.git
  2. Install dependencies:

    cd secureye
    npm install
  3. Environment Variables

  • NEXT_PUBLIC_NODEMCU_URL: URL for controlling NodeMCU
  • NEXT_PUBLIC_SITE_URL: URL of Application
  • NEXT_PUBLIC_SERVER_BASE_URL: Base URL for server which manage temperature data
  1. Run the development server:

    npm run dev

Usage

UI Design

Admin Admin Settings Main Settings
Admin Admin settings Main Settings
Admin Desktop Admin Desktop settings
Admin Admin settings

Basic NodeMU server Setup

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <Servo.h>
#include <DHT.h>
#define DHTPIN D2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);


Servo myservo;


// Replace with your network credentials
const char* ssid = "<wifi name>";
const char* password = "<password>";


const int output = D2;
const int FAN_PIN = D6;
const int LED_PIN = D7;



String sliderValue = "0";
String fanSpeedValue = "0";
String ledstatus ="off";


const char* PARAM_INPUT = "value";


// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

void setup(){
  pinMode(LED_PIN, OUTPUT);
  pinMode(FAN_PIN, OUTPUT);


  myservo.attach(D3);

  // Serial port for debugging purposes
Serial.begin(9600);

  analogWrite(output, sliderValue.toInt());
  analogWrite(FAN_PIN, fanSpeedValue.toInt());
  // Connect to WiFi
  WiFi.begin(ssid, password);

  // while wifi not connected yet, print '.'
  // then after it connected, get out of the loop
  while (WiFi.status() != WL_CONNECTED) {
     delay(500);
     Serial.print("connecting !.");
  }
  //print a new line, then print WiFi connected and the IP address
  Serial.println("");
  Serial.println("WiFi connected");
  // Print the IP address
  Serial.println(WiFi.localIP());


  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/plain", "seems okay");
  });

  // Send a GET request to <ESP_IP>/slider?value=<inputMessage>
  server.on("/fan", HTTP_GET, [] (AsyncWebServerRequest *request) {
    String inputMessage;

    // GET input1 value on <ESP_IP>/slider?value=<inputMessage>
    if (request->hasParam("speed")) {
      inputMessage = request->getParam("speed")->value();
      fanSpeedValue = inputMessage;
      // analogWrite(fanSpeed, fanSpeedValue.toInt());
        analogWrite(FAN_PIN, fanSpeedValue.toInt());
    }
    else {
      inputMessage = "No message sent";
    }
    Serial.println(inputMessage);

    request->send(200, "text/plain", "Ok");
  });

server.on("/light", HTTP_GET, [] (AsyncWebServerRequest *request) {
    String inputMessage;

    // GET input1 value on <ESP_IP>/slider?value=<inputMessage>
    if (request->hasParam("status")) {
      inputMessage = request->getParam("status")->value();
      ledstatus = inputMessage;
      // analogWrite(fanSpeed, fanSpeedValue.toInt());
      if(ledstatus == "on"){
         digitalWrite(LED_PIN, HIGH);
         }
      else{
          digitalWrite(LED_PIN, LOW);    // Turn LED off
      }
    }
    else {
      inputMessage = "No message sent";
    }
    Serial.println(inputMessage);

    request->send(200, "text/plain", "Ok");
  });

  server.on("/open", HTTP_GET, [] (AsyncWebServerRequest *request) {

    String inputMessage;
    myservo.write(180);

    request->send(200, "text/plain", "Opened");
  });
  server.on("/close", HTTP_GET, [] (AsyncWebServerRequest *request) {
    String inputMessage;
    myservo.write(-180);


    request->send(200, "text/plain", "Closed");
  });
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");

  // Start server
  server.begin();
}

void loop() {
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  //  float t = 23;
  // float h = 34;
  Serial.print("Temperature = ");
  Serial.println(t);
  Serial.print("Humidity = ");
  Serial.println(h);

  if (WiFi.status() == WL_CONNECTED) {
     WiFiClient client;
     HTTPClient http;
    String url = "<YOUR SERVER ADDRESS>/api/sensor?temperature=" + String(t) + "&humidity=" + String(h);
    http.begin(client, url);
    int httpCode = http.GET();
    if (httpCode > 0) {
      Serial.printf("[HTTP] GET... code: %d\n", httpCode);
    } else {
      Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
    }
    http.end();
  }

  delay(5000);
}

secureye's People

Contributors

rajeshiitk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.