Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Saksham Bhutani
Published © GPL3+

Octopod: Smart IoT Home/Industry Automation Project

Octopod, a uniquely shaped full automation system that allows you to monitor your industry and keep security with AI and smart RFID locks.

AdvancedFull instructions provided10 hours24,866

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Arduino MKR WiFi 1010
Arduino MKR WiFi 1010
Either this or any other Wifi ESP8266/ ESP32 This was not available in my country, So I went with NodeMCU ESP8266
×1
MAX32630FTHR
Maxim Integrated MAX32630FTHR
You can choose between MAX32620FTHR, Arduino 1010 or any ESP8266 Board. with this board you will need external WiFi Module or a Esp8266 chip for Interent
×1
Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
You can use normal Raspi 2/3 too!
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1
SparkFun Soil Moisture Sensor (with Screw Terminals)
SparkFun Soil Moisture Sensor (with Screw Terminals)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
Optional
×1
RFID reader (generic)
×1
Relay (generic)
2 channel preferably
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Camera Module
Raspberry Pi Camera Module
×1
Servos (Tower Pro MG996R)
×1
Buzzer
Buzzer
×2
HC-05 Bluetooth Module
HC-05 Bluetooth Module
Optional
×1
LED (generic)
LED (generic)
×4
Wall Adapter/ Power Bank
×2
Memory Card
more than 4 Gb and preferably Class 10 (Required for Raspberry Pi OS)
×1

Software apps and online services

Blynk
Blynk
OpenCV
OpenCV

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
3D Printer (generic)
3D Printer (generic)
Optional
Hand Tools
Needle Nose Pliers, Scissors,Cutter etc

Story

Read more

Custom parts and enclosures

Octopod_Basic

This is the basic design that you can use if you want to make the enclosure out of Cardboard/ Wood like me!

Octopod_Enclosure

Proper Enclosure that you can 3D Print!

Schematics

Main_Octopod

Pin configuration might be different with Arduino MKR 1010

Door_Lock

Without Bluetooth
For Bluetooth connect Rx (HC-05) --> Tx (Arduino)
Tx (HC-05) --> Rx (Arduino)
and 5v to 5v
Ground to Ground

MAX32620FTHR to ESP8266

ESP MAX
AO - - - - - - - - - - - - GPIO2
A1 - - - - - - - - - - - - - GPIO1

Soil Sensor MAX
analog sensor - - - GPIO3

Gas Sensor (MQ2) MAX
sensor - - - - - - - - - - - GPIO4

PIR Sensor MAX
sensor - - - - - - - - - - - -GPIO0

Relay MAX
1 - - - - - - - - - - - - - - - - - M0
2 - - - - - - - - - - - - - - - - - M1

Code

octopod.ino

Arduino
This is the main code for Arduino MKR 1010 (NodeMCU in my case)
If you are using MAX32620FTHR, download libraries for it. Then change the board in board settings. Also change the pin as given bellow
ESP MAX
AO - - - - - - - - - - - - GPIO2
A1 - - - - - - - - - - - - - GPIO1

Soil Sensor MAX
analog sensor - - - GPIO3

Gas Sensor (MQ2) MAX
sensor - - - - - - - - - - - GPIO4

PIR Sensor MAX
sensor - - - - - - - - - - - -GPIO0

Relay MAX
1 - - - - - - - - - - - - - - - - - M0
2 - - - - - - - - - - - - - - - - - M1
/***************************************************************************
                OCTOPOD: A SMART HOME AUTOMATION PROJECT
                         MADE BY SAKSHAM  
       
Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest
Download latest DHT Sensor library here:
    https://github.com/adafruit/DHT-sensor-library
***************************************************************************/

#include <ESP8266WiFi.h>          //Include ESP8266 Wifi Library
#include <BlynkSimpleEsp8266.h>   //Include Blynk Library
#include <DHT.h>                  //Include DHT sensor library

#define BLYNK_PRINT Serial

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Your Blynk Auth Key";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Your WiFi SSID";
char pass[] = "Your WiFi Password";

#define DHTPIN 2          // What digital pin temperature and humidity sensor is connected to
#define soilPin 4         // What digital pin soil moisture sensor is connected to
#define gasPin A0         // What analog  pin gas sensor is connected to
#define pirPin 12         // What digital pin soil moisture sensor is connected to
 
int pirValue;             // Place to store read PIR Value
int soilValue;            // Place to store read Soil Moisture Value
int PIRpinValue;          // Place to store the value sent by Blynk App Pin V0
int SOILpinValue;         // Place to store the value sent by Blynk App Pin V1

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.


BLYNK_WRITE(V0)             //VO pin from Blynk app tells if Motion Detection is ON
{
 PIRpinValue = param.asInt();    
} 

BLYNK_WRITE(V1)             //V1 pin from Blynk app tells if Soil Moisture is ON
{
 SOILpinValue = param.asInt();    
} 


void sendSensor()
{
  int h = dht.readHumidity();
  int t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!"); // to check if sensor is not sending any false values
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);  // send humidity to pin V5
  Blynk.virtualWrite(V6, t);  // send temperature to pin V7
}

void getPirValue(void)
{
  pirValue = digitalRead(pirPin);
  if (pirValue)      //digital pin of PIR gives high value on human detection
  { 
    Serial.println("Motion detected");
    Blynk.notify("Motion detected");  
  }
}

void getSoilValue(void)
{
  soilValue = digitalRead(soilPin);
  if (soilValue == HIGH)     //digital pin of soil sensor give low value when humidity is less
  { 
    Serial.println("Water Plants");
    Blynk.notify("Water Plants");  
  }
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  dht.begin(); // Begins DHT reading
  
  Blynk.tweet("OCTOPOD IS ONLINE!  "); // Tweating on your Twitter Handle that you project is online
  
  pinMode(pirPin,INPUT);    // Defining that Pir Pin is meant to take Input Only
  pinMode(soilPin,INPUT);   // Defining that Soil Sensor Pin is meant to take Input Only
  
  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
  
  if (PIRpinValue == HIGH)   //VO pin from Blynk app tells if Motion Detection is ON
      {
        getPirValue();
      }
      
  if (SOILpinValue == HIGH)  //V1 pin from Blynk app tells if Soil Moisture is ON
      {
        getSoilValue();
      }
   
}

octopod_door.ino

Arduino
Code for Automatic Door Lock Control (NO BLUETOOTH VERSION)
/***********************************************************************************************************
                                   OCTOPOD: A SMART HOME AUTOMATION PROJECT
                                           MADE BY SAKSHAM
                                         ARDUINO RFID DOOR LOCK CODE
Library Required - MFRC522                                         

************************************************************************************************************/
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
 
#define SS_PIN 10
#define RST_PIN 9
#define LED_G 5 //define green LED pin
#define LED_R 4 //define red LED
#define BUZZER 2 //buzzer pin
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
Servo myServo; //define servo name
 
void setup() 
{
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  myServo.attach(3); //servo pin
  myServo.write(0); //servo start position
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  noTone(BUZZER);
  Serial.println("Put your card to the reader...");
  Serial.println();

}
void loop() 
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "XX XX XX XX") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    Serial.println();
    delay(500);
    digitalWrite(LED_G, HIGH);
    tone(BUZZER, 500);
    delay(300);
    noTone(BUZZER);
    myServo.write(180);
    delay(5000);
    myServo.write(0);
    digitalWrite(LED_G, LOW);
  }
 
 else   {
    Serial.println(" Access denied");
    digitalWrite(LED_R, HIGH);
    tone(BUZZER, 300);
    delay(1000);
    digitalWrite(LED_R, LOW);
    noTone(BUZZER);
  }
} 

octopod_door_bluetooth.ino

Arduino
Code for Automatic Door Lock Control (Bluetooth Version)
/***********************************************************************************************************
                                   OCTOPOD: A SMART HOME AUTOMATION PROJECT
                                            MADE BY SAKSHAM
                                         ARDUINO RFID DOOR LOCK CODE
Library Required - MFRC522                                         

************************************************************************************************************/
#include <SoftwareSerial.h>
SoftwareSerial BTserial(0, 1); // RX | TX
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>

#define SS_PIN 10
#define RST_PIN 9
#define LED_G 5 //define green LED pin
#define LED_R 4 //define red LED
#define BUZZER 2 //buzzer pin
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
Servo myServo; //define servo name


void setup()
{
  BTserial.begin(9600); // Initiate a serial communication
  BTserial.println("Waiting for connections...");
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  myServo.attach(3); //servo pin
  myServo.write(0); //servo start position
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  noTone(BUZZER);
  BTserial.println("Put your card to the reader...");
  BTserial.println();

}
void loop()
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    return;
  }
  //Show UID on serial monitor
  BTserial.print("UID tag :");
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
    BTserial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    BTserial.print(mfrc522.uid.uidByte[i], HEX);
    content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  BTserial.println();
  BTserial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "33 3E A7 E5" || content.substring(1) == "E5 36 6B 49") //change here the UID of the card/cards that you want to give access
  {
    BTserial.println("Authorized access");
    BTserial.println();
    delay(500);
    digitalWrite(LED_G, HIGH);
    tone(BUZZER, 500);
    delay(300);
    noTone(BUZZER);
    myServo.write(180);
    delay(5000);
    myServo.write(0);
    digitalWrite(LED_G, LOW);
  }

  else   {
    BTserial.println(" Access denied");
    digitalWrite(LED_R, HIGH);
    tone(BUZZER, 300);
    delay(1000);
    digitalWrite(LED_R, LOW);
    noTone(BUZZER);
  }
}

Credits

Saksham Bhutani
3 projects • 41 followers
I am a 19 year old who loves tech and making new things!
Thanks to Adrian.

Comments