Industrielle Fertigung
Industrielles Internet der Dinge | Industrielle Materialien | Gerätewartung und Reparatur | Industrielle Programmierung |
home  MfgRobots >> Industrielle Fertigung >  >> Manufacturing Technology >> Herstellungsprozess

Octopod:Smart IoT Home/Industry Automation Project

Komponenten und Verbrauchsmaterialien

Arduino UNO
× 1
Arduino MKR WiFi 1010
Entweder dieses oder ein anderes Wifi ESP8266/ ESP32Dies war in meinem Land nicht verfügbar, also habe ich mich für NodeMCU entschieden ESP8266
× 1
Maxim Integrated MAX32630FTHR
Sie können zwischen MAX32620FTHR, Arduino 1010 oder jedem ESP8266 Board wählen. Bei diesem Board benötigen Sie externes WLAN Modul oder ein Esp8266-Chip für Internet
× 1
Raspberry Pi Zero Wireless
Sie können auch normales Raspi 2/3 verwenden!
× 1
DHT11 Temperatur- und Feuchtigkeitssensor (4 Pins)
× 1
Seeed Grove - Gassensor (MQ2)
× 1
SparkFun Bodenfeuchtesensor (mit Schraubklemmen)
× 1
PIR-Bewegungssensor (generisch)
Optional
× 1
RFID-Lesegerät (generisch)
× 1
Relais (generisch)
2 Kanäle vorzugsweise
× 1
RGB diffundierte gemeinsame Kathode
× 1
Raspberry Pi Kameramodul
× 1
Servos (Tower Pro MG996R)
× 1
Summer
× 2
HC-05 Bluetooth-Modul
Optional
× 1
LED (generisch)
× 4
Wandadapter/Powerbank
× 2
Speicherkarte
mehr als 4 GB und vorzugsweise Klasse 10 (erforderlich für Raspberry Pi OS)
× 1

Notwendige Werkzeuge und Maschinen

Heißklebepistole (generisch)
3D-Drucker (generisch)
Optional
Handwerkzeuge
Nadelzange, Schere, Cutter usw.

Apps und Onlinedienste

Blynk
OpenCV

Über dieses Projekt

Es gibt viele IoT-Automatisierungsprojekte, aber glauben Sie mir, es gibt nichts Vergleichbares! Octopod wird mit NodeMCU hergestellt (MAX32620FTHR oder Arduino MKR 1010), Arduino Uno, und Raspberry Pi 3 . Octopod ermöglicht es Ihnen, Ihr Zuhause smart zu machen. Octopod sendet Ihnen eine Vielzahl von Daten wie Temperatur , Luftfeuchtigkeit, und Gasqualität in Ihrem Zuhause/Büro/Industrie. Octopod sendet Ihnen eine Benachrichtigung wenn es irgendeine Art von Bewegung erkennt drinnen und sagt Ihnen, wann Sie Ihre Pflanzen gießen müssen . Sie können auch Ihre Geräte steuern durch einen Blynk Anwendung auf Ihrem Smartphone. Octopod ermöglicht sogar echtes Stimmungslicht!

Octopod ist mit einer winzig kleinen Kamera ausgestattet , die Ihnen einen Live-Feed sendet . Diese Kamera verwendet auch künstliche Intelligenz um Menschen in seinem Blickfeld zu erkennen und schickt dir ihre Bilder . Darüber hinaus verfügt es über ein RFID Türverriegelung System ! Genial, oder?

Wie funktioniert alles?

Die NodeMCU ist mit einer Reihe von Sensoren, einem Relaismodul und RGB-LEDs verbunden. Es ist über WLAN mit der Blynk-App auf einem Smartphone verbunden, die alle Daten sendet und Ihnen ermöglicht, Ihr Zuhause zu steuern.

Raspberry Pi ist auch mit WLAN verbunden, sodass Sie den Live-Feed über die Pi-Kamera sehen können. Wir haben auch OpenCV-Bibliotheken auf dem Pi installiert und den Pi so konfiguriert, dass er alle Menschen in seinem Blickfeld erkennt und Ihnen ihre Bilder per E-Mail zusendet.

Die intelligente Türeinheit verwendet ein RFID-Modul. Wird das erlaubte RFID in seine Reichweite gebracht, öffnet es automatisch die Tür.

SCHRITT 1:Hauptoktopod codieren

Ich habe in fast jeder Zeile Kommentare hinzugefügt, damit Sie nicht nur kopieren, sondern auch verstehen. Hier erzähle ich Ihnen kurz und bündig, was bei der Ausführung des Codes tatsächlich passiert!

  • Einschließlich der Bibliotheken:

Dieser Code verwendet 2 Hauptbibliotheken, die Blynk-Bibliothek, um den Code mit der Blynk-Anwendung kompatibel zu machen, und die andere Bibliothek ist die DHT11-Temperaturbibliothek, die die Rohdaten des Sensors in Temperatur und Luftfeuchtigkeit umwandelt. Um diese Bibliotheken herunterzuladen, gehen Sie einfach zu den angegebenen Links im Code und laden Sie sie herunter. Dann gehen Sie zu Arduino IDE Sketch → Bibliothek einschließen → ZIP-Bibliothek hinzufügen und Ihre heruntergeladenen Bibliotheken auswählen.

#include //Blynk Library einschließen#include //Blynk Library einschließen#include //DHT-Sensorbibliothek einbinden#define BLYNK_PRINT Serial 

Dies ist ein Blynk-Code, mit dem Sie Ihren Nodemcu mit dem Internet verbinden und ihn dann bei Ihrer App authentifizieren können.

// Sie sollten Auth Token in der Blynk App erhalten.// Gehen Sie zu den Projekteinstellungen (nut icon).char auth[] ="Your Auth Key";// Ihre WLAN-Zugangsdaten.// Set Passwort zu "" für offene Netzwerke.char ssid[] ="Ihre WLAN-SSID";char pass[] ="Ihr WLAN-Pass"; 
  • Definieren von Pins und Ganzzahlen:

In diesem Segment definieren wir die Pins unserer verschiedenen Sensoren. Sie können sie nach Ihrer Überzeugung ändern. Wir definieren auch einige Ganzzahlen, die wir im Laufe unseres Codes verwenden.

#define DHTPIN 2 // An welchen digitalen Pin-Temperatur- und Feuchtigkeitssensor angeschlossen ist#define SoilPin 4 // An welchen digitalen Pin-Bodenfeuchtigkeitssensor angeschlossen ist#define gasPin A0 // An welchen analogen Pin-Gassensor angeschlossen to#define pirPin 12 // Welcher digitaler Pin-Bodenfeuchtesensor ist mit int pirValue verbunden; // Platz zum Speichern von gelesenem PIR Valueint groundValue; // Speicherort lesen Soil Moisture Valueint PIRpinValue; // Platz um den von Blynk App gesendeten Wert zu speichern Pin V0int SOILpinValue; // Ort, um den von Blynk App Pin V1 gesendeten Wert zu speichern 
  • BLYNK_WRITE() :

Mit diesem Code teilen wir der Blynk-App mit, dass sie Pin V0 und Pin V1 verwenden kann, um den Code mitzuteilen, wenn die Bewegungserkennung und der Bodenfeuchtigkeitstest eingeschaltet sind.

BLYNK_WRITE (V0) // VO-Pin aus der Blynk-App sagt, ob die Bewegungserkennung eingeschaltet ist { PIRpinValue =param.asInt (); } BLYNK_WRITE (V1) // V1-Pin aus der Blynk-App sagt, ob die Bodenfeuchtigkeit eingeschaltet ist { SOILpinValue =param.asInt (); } 
  • SendSensor() ungültig machen:

Dieser Code nimmt die Daten von DHT11, macht sie nutzbar und sendet sie dann an Pin V5 bzw. V6.

void sendSensor () {int h =dht.readHumidity (); int t =dht.readTemperature(); // oder dht.readTemperature (true) für Fahrenheit if (isnan (h) || isnan (t)) { Serial.println ( "Fehler beim Lesen vom DHT-Sensor!"); // um zu überprüfen, ob der Sensor keine falschen Werte sendet return; } // Sie können jederzeit einen beliebigen Wert senden. // Bitte senden Sie nicht mehr als 10 Werte pro Sekunde. Blynk.virtualWrite(V5, h); // Feuchtigkeit an Pin V5 senden Blynk.virtualWrite (V6, t); // Temperatur an Pin V7 senden} 
  • void getPirValue() &void getSoilValue() :

Liest den Digitalwert von den Sensoren und führt dann eine if-sonst-Bedingung aus, um den Zustand des Sensors zu überprüfen. Wenn sich der Sensor im erforderlichen Status befindet, sendet er eine Benachrichtigung von der Blynk-App.

void getPirValue(void){pirValue =digitalRead(pirPin); if (pirValue) // digitaler Pin von PIR gibt einen hohen Wert bei der menschlichen Erkennung {Serial.println ("Bewegung erkannt"); Blynk.notify("Bewegung erkannt"); }}void getSoilValue (void) { Bodenwert =digitalRead (soilPin); if (soilValue ==HIGH) // digitaler Pin des Bodensensors gibt einen niedrigen Wert, wenn die Luftfeuchtigkeit geringer ist {Serial.println ("Wasserpflanzen"); Blynk.notify("Wasserpflanzen"); }} 
  • Einrichtung ungültig() :

Im Setup machen wir ein paar Dinge, die nur einmal gemacht werden sollen. Zum Beispiel:Starten der seriellen Kommunikation mit einer festen Baudrate, Autorisieren Sie diesen Code für die Blynk-Anwendung, beginnen Sie mit den Dht-Sensormesswerten, twittern Sie dann an Ihren Twitter-Handle, dass Ihr Smart Home-Projekt online ist, und teilen Sie dem Knoten dann mit, dass Pir Pin und Bodensensor Pin ist nur für Eingaben gedacht.

void setup () {// Debug-Konsole Serial.begin (9600); Blynk.begin(auth, ssid, pass); // Sie können auch den Server angeben://Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442); //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442); dht.begin(); // Beginnt DHT mit dem Lesen von Blynk.tweet("OCTOPOD IS ONLINE! "); // Tweating auf Ihrem Twitter Handle, das Sie projizieren, ist online pinMode(pirPin,INPUT); // Definieren, dass Pir Pin nur Eingaben annehmen soll pinMode(soilPin,INPUT); // Definieren, dass der Bodensensor-Pin nur Eingaben annehmen soll // Richten Sie eine Funktion ein, die jede Sekunde aufgerufen wird timer.setInterval(1000L, sendSensor);} 
  • void loop() :

In der Schleife schreiben wir Dinge, die immer wieder zu tun sind. Hier stellen wir sicher, dass der Code, den wir vor dem Setup geschrieben haben, ausgeführt wird. Dann schreiben wir 2 If-Else-Anweisungen, die die Zustände von Pin V0 und Pin V1 überprüfen und dann die Werte von den Sensoren entsprechend übernehmen.

void loop(){ Blynk.run(); Timer.run(); if (PIRpinValue ==HIGH) // VO-Pin aus der Blynk-App sagt, ob die Bewegungserkennung eingeschaltet ist {getPirValue (); aufrechtzuerhalten. Wenn (SOILpinValue ==HIGH) // V1-Pin aus der Blynk-App sagt, ob die Bodenfeuchtigkeit eingeschaltet ist {getSoilValue (); } } 

SCHRITT 2:Codierung des RFID Smart Lock

Um ehrlich zu sein, ist dies ein einfacher und einfacher Code, der nicht viel erklärt werden muss. Aber ich werde Ihnen noch in aller Kürze sagen, was dies bewirkt. Es gibt zwei Versionen des Codes, eine ist, wenn Sie die Türeinheitsbox mit Bluetooth verbinden möchten, damit Sie über den seriellen Anschluss benachrichtigt werden, wenn Ihre Tür geöffnet ist. Andere sendet an seriell, damit es angezeigt werden kann, wenn Sie Ihr Arduino an Ihren Computer anschließen. Ich bevorzuge jedoch die einfache ohne Bluetooth-Version. Also los geht's!

  • Gehen Sie zu Sketch → Bibliothek einschließen → Bibliothek verwalten → Geben Sie MFRC522 in die Suchleiste ein und installieren Sie die Bibliothek. Gehen Sie dann zu Datei → Beispiele → Benutzerdefinierte Bibliotheken → MFRC522 → dumpInfo Sketch. Am Anfang können Sie lesen, wie man Pins verbindet (Oder beziehen Sie sich auf das Bild). Führen Sie dann den Code aus und öffnen Sie den seriellen Monitor und bringen Sie eine Ihrer Rfid-Karte vor das MFRC522-Modul und warten Sie 5 Sekunden. Dann notieren Sie sich die Karten-UID auf ähnliche Weise notieren Sie die UIDs Ihrer anderen Karten und Schlüsselanhänger.
  • Laden Sie dann den gewünschten Code herunter. Öffnen Sie den Code und gehen Sie zu dieser Zeile. Fügen Sie hier anstelle dieser X die UID der Karte hinzu, die Sie zum Öffnen der Tür verwenden möchten. Jetzt bist du bereit, lade einfach den Code hoch.
if (content.substring(1) =="XX XX XX XX") {} 

In diesem Code gibt es zwei Hauptdinge, die wir tun, nämlich den If-Else-Teil des Codes. Wenn wir dem Arduino sagen, dass, wenn die UID der Karte mit der erwähnten UID übereinstimmt, den Servo bewegen (so dass sich die Tür öffnet) und einige LEDs blinken und einige Geräusche mit dem Summer machen. Andernfalls, wenn die UIDs nicht dazu führen, dass einige LEDs blinken und einige Geräusche mit dem Summer erzeugt werden.

SCHRITT 3:Raspberry Pi Human Detection AI Setup

In diesem geführten Schritt lernen wir, wie man eine intelligente Sicherheitskamera herstellt. Die Kamera sendet Ihnen eine E-Mail, wenn sie das Objekt erkennt. Wenn Sie sich im selben WLAN-Netzwerk befinden, können Sie auf das Live-Filmmaterial der Kamera zugreifen, indem Sie die IP-Adresse Ihres Raspberry Pi eingeben. Ich zeige Ihnen, wie Sie die Smart Camera von Grund auf neu erstellen. Auf geht's!

Anforderungen:

1. OpenCV (Open Source Computer Vision Library)

2. Raspberry Pi 3B

3. Raspberry Pi Kamera V2

Annahmen:

1. Raspberry Pi 3 mit installiertem Raspbian Stretch. Wenn Sie das Betriebssystem Raspbian Stretch noch nicht haben, müssen Sie Ihr Betriebssystem aktualisieren, um die neuen Funktionen von Raspbian Stretch nutzen zu können.

Um Ihren Raspberry Pi 3 auf Raspbian Stretch zu aktualisieren, können Sie ihn hier herunterladen und diesen Upgrade-Anweisungen folgen (oder diesen für die NOOBS-Route, die für Anfänger empfohlen wird).

Hinweis:Wenn Sie Ihren Raspberry Pi 3 von Raspbian Jessie auf Raspbian Stretch aktualisieren, können Probleme auftreten. Fahren Sie auf eigene Gefahr fort und konsultieren Sie die Raspberry Pi-Foren, um Hilfe zu erhalten. Wichtig:Ich empfehle Ihnen, mit einer Neuinstallation von Raspbian Stretch fortzufahren! Ein Upgrade von Raspbian Jessie wird nicht empfohlen.

2. Physischer Zugriff auf Ihren Raspberry Pi 3, damit Sie ein Terminal öffnen und Befehle ausführen könnenFernzugriff über SSH oder VNC. Ich werde den Großteil dieses Tutorials über SSH durchführen, aber solange Sie Zugriff auf ein Terminal haben, können Sie es problemlos mitverfolgen.

  • Schritt 1:ANBRINGEN DER KAMERA AN RASPBERRY PI 3

1. Öffnen Sie Ihr Raspberry Pi-Kameramodul. Beachten Sie, dass die Kamera durch statische Elektrizität beschädigt werden kann. Bevor Sie die Kamera aus der grauen antistatischen Tasche nehmen, vergewissern Sie sich, dass Sie sich entladen haben, indem Sie einen geerdeten Gegenstand berühren (z. B. einen Kühler oder ein PC-Gehäuse).

2. Installieren Sie das Raspberry Pi-Kameramodul, indem Sie das Kabel in den Raspberry Pi einstecken. Das Kabel wird in den Anschluss zwischen den Ethernet- und HDMI-Ports eingesteckt, wobei die silbernen Stecker zum HDMI-Port zeigen.

3. Starten Sie Ihren Raspberry Pi.

4. Führen Sie an der Eingabeaufforderung "sudo raspi-config" aus. Wenn die Option "Kamera" nicht aufgeführt ist, müssen Sie einige Befehle ausführen, um Ihren Raspberry Pi zu aktualisieren. Führen Sie "sudo apt-get update" und "sudo apt-get upgrade" aus

5. Führen Sie "sudo raspi-config" erneut aus - Sie sollten jetzt die Option "Kamera" sehen.

BEFEHL-

$ sudo raspi-config 

6. Navigieren Sie zur Option "Kamera" und aktivieren Sie sie (Ausschau in Schnittstellenoption). Wählen Sie „Fertig stellen“ und starten Sie Ihren Raspberry Pi neu oder geben Sie einfach Folgendes ein:

$ sudo reboot 
  • Schritt 2:OFFENE CV-INSTALLATION

Wenn Sie OpenCV zum ersten Mal installieren oder gerade erst mit Rasbian Stretch beginnen. Dies ist das perfekte Tutorial für Sie.

Schritt 1:Dateisystem erweitern

Verwenden Sie eine brandneue Installation von Raspbian Stretch? In diesem Fall sollten Sie als Erstes Ihr Dateisystem erweitern, um den gesamten verfügbaren Speicherplatz auf Ihrer Micro-SD-Karte einzuschließen:

BEFEHL-

$ sudo raspi-config 

Wählen Sie dann den Menüpunkt „Erweiterte Optionen“ und wählen Sie anschließend „Dateisystem erweitern“. Sobald Sie dazu aufgefordert werden, sollten Sie die erste Option auswählen, „A1. Erweitern Sie das Dateisystem, drücken Sie die Eingabetaste auf Ihrer Tastatur, den Pfeil nach unten zur Schaltfläche "" und starten Sie dann Ihren Pi neu. Wenn Sie eine 8-GB-Karte verwenden, verwenden Sie möglicherweise fast 50% des verfügbaren Speicherplatzes. Löschen Sie also sowohl die LibreOffice- als auch die Wolfram-Engine, um Speicherplatz auf Ihrem PI freizugeben:

BEFEHL-

$ sudo apt-get purge wolfram-engine $ sudo apt-get purge libreoffice* $ sudo apt-get clean$ sudo apt-get autoremove 

Nachdem Sie die Wolfram Engine und LibreOffice entfernt haben, können Sie fast 1 GB zurückgewinnen!

Schritt #2: Installationsabhängigkeiten

Dies ist nicht das erste Mal, dass ich bespreche, wie man OpenCV auf dem Raspberry Pi installiert, daher werde ich diese Anleitung kurz halten, damit Sie den Installationsprozess durcharbeiten können:Ich habe auch die Zeit angegeben es dauert, jeden Befehl auszuführen (einige hängen von Ihrer Internetgeschwindigkeit ab), damit Sie Ihre OpenCV + Raspberry Pi 3 Installation entsprechend planen können (OpenCV selbst dauert ungefähr 4 Stunden zum Kompilieren – mehr dazu später). Der erste Schritt besteht darin, alle vorhandenen Pakete zu aktualisieren und zu aktualisieren:

BEFEHL-

$ sudo apt-get update &&sudo apt-get upgrade  

Wir müssen dann einige Entwicklertools installieren, darunter CMake, das uns bei der Konfiguration des OpenCV-Build-Prozesses hilft:Raspbian Stretch:Installiere OpenCV 3 + Python auf deinem Raspberry Pi

BEFEHL-

$ sudo apt-get install build-essential cmake pkg-config 

Als nächstes müssen wir einige Bild-E/A-Pakete installieren, die es uns ermöglichen, verschiedene Bilddateiformate von der Festplatte zu laden. Beispiele für solche Dateiformate sind JPEG, PNG, TIFF usw.:Raspbian Stretch

BEFEHL-

$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev 

Genauso wie wir Bild-E/A-Pakete benötigen, benötigen wir auch Video-E/A-Pakete. Diese Bibliotheken ermöglichen es uns, verschiedene Videodateiformate von der Festplatte zu lesen und direkt mit Videostreams zu arbeiten

BEFEHL-

$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev $ sudo apt-get install libxvidcore-dev libx264-dev 

Die OpenCV-Bibliothek enthält ein Untermodul namens highgui, das verwendet wird, um Bilder auf unserem Bildschirm anzuzeigen und grundlegende GUIs zu erstellen. Um das Highgui-Modul zu kompilieren, müssen wir die GTK-Entwicklungsbibliothek installieren:Raspbian Stretch:OpenCV 3 + Python auf Ihrem Raspberry Pi installieren

BEFEHL-

$ sudo apt-get install libgtk2.0-dev libgtk-3-dev 

Viele Operationen innerhalb von OpenCV (nämlich Matrixoperationen) können durch die Installation einiger zusätzlicher Abhängigkeiten weiter optimiert werden:

BEFEHL-

$ sudo apt-get install libatlas-base-dev gfortran 

Diese Optimierungsbibliotheken sind besonders wichtig für ressourcenbeschränkte Geräte wie den Raspberry Pi. Zuletzt installieren wir sowohl die Python 2.7- als auch die Python 3-Header-Dateien, damit wir OpenCV mit Python-Bindungen kompilieren können:Raspbian Stretch

BEFEHL-

$ sudo apt-get install python2.7-dev python3-dev  

Wenn Sie mit einer Neuinstallation des Betriebssystems arbeiten, ist es möglich, dass diese Versionen von Python bereits die neueste Version haben (Sie sehen eine Terminalmeldung, die dies angibt). Wenn Sie diesen Schritt überspringen, stellen Sie möglicherweise einen Fehler fest, der damit zusammenhängt, dass die Header-Datei Python.h nicht gefunden wird, wenn make zum Kompilieren von OpenCV ausgeführt wird. Schritt 3:Laden Sie den OpenCV-Quellcode herunter

Schritt 3:Laden Sie den OpenCV herunter Quellcode

Nachdem wir nun unsere Abhängigkeiten installiert haben, holen wir uns das 3.3.0-Archiv von OpenCV aus dem offiziellen OpenCV-Repository. Diese Version enthält das dnn-Modul, das wir in einem früheren Beitrag besprochen haben, in dem wir Deep Learning mit OpenCV durchgeführt haben (Hinweis:Wenn zukünftige Versionen von openCV veröffentlicht werden, können Sie 3.3.0 durch die neueste Versionsnummer ersetzen):

BEFEHL-

$ cd ~ $ wget -O opencv.zip   https://github.com/Itseez/opencv/archive/3.3.0.zi...>> p$ opencv.zip entpacken

Wir möchten die vollständige Installation von OpenCV 3 (um zum Beispiel Zugriff auf Funktionen wie SIFT und SURF zu haben), also müssen wir auch das opencv_contrib-Repository greifen:Raspbian Stretch:Install OpenCV 3 + Python on your Raspberry Pi

BEFEHL-

$ wget -O opencv_contrib.zip   https://github.com/Itseez/opencv_contrib/archive/...>>3.3.0$ opencv_contrib.zip entpacken 

Möglicherweise müssen Sie den obigen Befehl während des Kopierens und Einfügens mithilfe der Schaltfläche "<=>" erweitern. Die .zip-Datei in der Datei 3.3.0.zip scheint in einigen Browsern abgeschnitten zu sein. Die vollständige URL des OpenCV 3.3.0-Archivs lautet:https://github.com/Itseez/opencv_contrib/archive/... Hinweis:Stellen Sie sicher, dass Ihre Versionen von opencv und opencv_contrib identisch sind (in diesem Fall 3.3.0). . Wenn die Versionsnummern nicht übereinstimmen, treten wahrscheinlich entweder Kompilierzeit- oder Laufzeitfehler auf. Schritt #4:Python 2.7 oder Python 3? Bevor wir OpenCV auf unserem Raspberry Pi 3 kompilieren können, müssen wir zunächst pip installieren, einen Python-Paketmanager

BEFEHL-

$ wget    https://bootstrap.pypa.io/get-pip.py> 
>>
>$ sudo python get-pip.py $ sudo python3 get-pip.py 

Möglicherweise erhalten Sie eine Meldung, dass pip bereits auf dem neuesten Stand ist, wenn Sie diese Befehle ausführen, aber es ist am besten, diesen Schritt nicht zu überspringen. Wenn Sie ein langjähriger PyImageSearch-Leser sind, wissen Sie, dass ich ein großer Fan von virtualenv und virtualenvwrapper bin.

Die Installation dieser Pakete ist keine Voraussetzung und Sie können OpenCV absolut ohne sie installieren, aber ich empfehle Ihnen dringend, sie zu installieren, da andere bestehende PyImageSearch-Tutorials (sowie zukünftige Tutorials) auch virtuelle Python-Umgebungen nutzen.

Ich gehe auch davon aus, dass Sie für den Rest dieses Handbuchs sowohl virtualenv als auch virtualenvwrapper installiert haben. Was bringt es also, virtualenv und virtualenvwrapper zu verwenden? Zunächst ist es wichtig zu verstehen, dass eine virtuelle Umgebung ein spezielles Werkzeug ist, das verwendet wird, um die Abhängigkeiten, die von verschiedenen Projekten erforderlich sind, an separaten Orten zu halten, indem isolierte, unabhängige Python-Umgebungen für jedes von ihnen erstellt werden. Kurz gesagt, es löst das Dilemma „Projekt X hängt von Version 1.x ab, aber Projekt Y braucht 4.x“.

Es hält auch Ihre globalen Site-Pakete sauber, ordentlich und frei von Unordnung. Wenn Sie eine vollständige Erklärung wünschen, warum virtuelle Python-Umgebungen eine gute Praxis sind, lesen Sie unbedingt diesen hervorragenden Blogbeitrag zu RealPython. Es ist gängige Praxis in der Python-Community, virtuelle Umgebungen zu verwenden, daher empfehle ich Ihnen dringend, dasselbe zu tun:

BEFEHL-

$ sudo pip install virtualenv virtualenvwrapper$ sudo rm -rf ~/.cache/pip  

Nachdem sowohl virtualenv als auch virtualenvwrapper installiert wurden, müssen wir unsere ~/.profile-Datei aktualisieren. Fügen Sie die folgenden Zeilen am Ende der Datei ein:Raspbian Stretch

BEFEHL-

$ nano ~/.profile 

Kopieren Sie die folgenden Zeilen und fügen Sie sie am Ende der Datei ein:

BEFEHL-

# virtualenv und virtualenvwrapperWORKON_HOME=$HOME/.virtualenvs Quelle /usr/local/bin/virtualenvwrapper.sh  

ODER

Sie sollten einfach cat und die Ausgabeumleitung verwenden, um die Aktualisierung von ~/.profile zu handhaben:

BEFEHL-

$ echo -e "\n# virtualenv und virtualenvwrapper">> ~/.profile $ echo "exportWORKON_HOME=$HOME/.virtualenvs">> ~/.profile$ echo "source /usr/local/ bin/virtualenvwrapper.sh">> ~/.profile  

Nachdem wir unser ~/.profile aktualisiert haben, müssen wir es neu laden, um sicherzustellen, dass die Änderungen wirksam werden. Sie können ein erneutes Laden Ihrer ~/.profile-Datei erzwingen, indem Sie sich abmelden und dann wieder anmelden.

Schließen einer Terminalinstanz und Öffnen einer neuen

Oder mein persönlicher Favorit

BEFEHL-

$ source ~/.profile  

Hinweis :Ich empfehle, die Quelldatei ~/.profile jedes Mal auszuführen, wenn Sie ein neues Terminal öffnen, um sicherzustellen, dass Ihre Systemvariablen korrekt eingerichtet wurden. Erstellen Ihrer virtuellen Python-Umgebung Als Nächstes erstellen wir die virtuelle Python-Umgebung, die wir für die Entwicklung von Computer Vision verwenden:

BEFEHL-

$ mkvirtualenv cv -p python2  

Dieser Befehl erstellt eine neue virtuelle Python-Umgebung namens cv mit Python 2.7.

Wenn Sie stattdessen Python 3 verwenden möchten, verwenden Sie stattdessen diesen Befehl:

BEFEHL-

$ mkvirtualenv cv -p python3 

Auch hier kann ich diesen Punkt nicht genug betonen:Die virtuelle Umgebung von cv Python ist völlig unabhängig und von der Standard-Python-Version getrennt, die im Download von Raspbian Stretch enthalten ist.

Alle Python-Pakete im globalen Verzeichnis site-packages sind für die virtuelle Umgebung von cv nicht verfügbar. Ebenso sind alle Python-Pakete, die in Site-Paketen von cv installiert sind, für die globale Installation von Python nicht verfügbar.

Denken Sie daran, wenn Sie in Ihrer virtuellen Python-Umgebung arbeiten, und es hilft, viel Verwirrung und Kopfschmerzen zu vermeiden. So überprüfen Sie, ob Sie sich in der virtuellen Umgebung "cv" befinden Wenn Sie Ihren Raspberry Pi jemals neu starten; aus- und wieder einloggen; oder ein neues Terminal öffnen, müssen Sie den Befehl workon verwenden, um wieder auf die virtuelle Umgebung von cv zuzugreifen.

In früheren Blog-Posts habe ich gesehen, wie Leser den Befehl mkvirtualenv verwendet haben – das ist völlig unnötig! Der Befehl mkvirtualenv soll nur einmal ausgeführt werden:um die virtuelle Umgebung tatsächlich zu erstellen. After that, you can use workon and you’ll be dropped down into your virtual environment:

COMMAND-

$ source ~/.profile $ workon cv 

To validate and ensure you are in the cv virtual environment, examine your command line — if you see the text (cv) preceding your prompt, then you are in the cv virtual environment:Make sure you see the “(cv)” text on your prompt, indicating that you are in the cv virtual environment.

Otherwise, if you do not see the (cv) text, then you are not in the cv virtual environment:

If you do not see the “(cv)” text on your prompt, then you are not in the cv virtual environment and need to run “source” and “workon” to resolve this issue. To fix this, simply execute the source and workon commands mentioned above. Installing NumPy on your Raspberry Pi Assuming you’ve made it this far, you should now be in the cv virtual environment (which you should stay in for the rest of this tutorial).

Step #4 :Installing NumPy on your Raspberry Pi

Our only Python dependency is NumPy, a Python package used for numerical processing:

COMMAND-

$ pip install numpy  

the NumPy installation can take a bit of time.

Step #5:Compile and Install OpenCV

COMMAND-

$ workon cv 

Once you have ensured you are in the cv virtual environment, we can setup our build using CMake:

COMMAND-

$ cd ~/opencv-3.3.0/ $ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \ -D BUILD_EXAMPLES=ON .. 

Now, before we move on to the actual compilation step, make sure you examine the output of CMake! Start by scrolling down the section titled Python 2 and Python 3 . If you are compiling OpenCV 3 for Python 2.7, then make sure your Python 2 section includes valid paths to the Interpreter, Libraries, numpy and packages

Checking that Python 3 will be used when compiling OpenCV 3 for Raspbian Stretch on the Raspberry Pi 3. Notice how the Interpreter points to our python2.7 binary located in the cv virtual environment. The numpy variable also points to the NumPy installation in the cv environment.

Again, the Interpreter points to our python3.5 binary located in the cv virtual environment while numpy points to our NumPy install.

In either case, if you do not see the cv virtual environment in these variables paths, it’s almost certainly because you are NOT in the cv virtual environment prior to running CMake! If this is the case, access the cv virtual environment using workon cv and re-run the cmake command outlined above.

Configure your swap space size before compiling Before you start the compile process, you should increase your swap space size. This enables OpenCV to compile with all four cores of the Raspberry PI without the compile hanging due to memory problems.

Open your /etc/dphys-swapfile and then edit the CONF_SWAPSIZE variable

COMMAND-

$ nano /etc/dphys-swapfile  

and then edit the following section of the file:#set size to absolute value, leaving empty (default) then uses computed value # you most likely don't want this, unless you have an special disk situation

# CONF_SWAPSIZE=100 CONF_SWAPSIZE =1024 

Notice that I’ve commented out the 100MB line and added a 1024MB line. This is the secret to getting compiling with multiple cores on the Raspbian Stretch. If you skip this step, OpenCV might not compile.

To activate the new swap space, restart the swap service:

COMMAND-

$ sudo /etc/init.d/dphys-swapfile stop $ sudo /etc/init.d/dphys-swapfile start  

Note:It is possible to burn out the Raspberry Pi microSD card because flash memory has a limited number of writes until the card won’t work. It is highly recommended that you change this setting back to the default when you are done compiling and testing the install (see below). To read more about swap sizes corrupting memory, see this page. Finally, we are now ready to compile OpenCV:

COMMAND-

$ make -j4 

The -j4 switch stands for the number of cores to use when compiling OpenCV. Since we are using a Raspberry Pi 2, we’ll leverage all four cores of the processor for a faster compilation.

However, if your make command errors out, I would suggest starting the compilation over again and only using one core

$ make clean$ make  

Once OpenCV 3 has finished compiling.Our OpenCV 3 compile on Raspbian Stretch has completed successfully.

From there, all you need to do is install OpenCV 3 on your Raspberry Pi 3:

COMMAND-

$ sudo make install$ sudo ldconfig  

Step #6 :Finish installing OpenCV on your Pi

We’re almost done — just a few more steps to go and you’ll be ready to use your Raspberry Pi 3 with OpenCV 3 on Raspbian Stretch.

For Python 2.7:

#5 Provided your Step without error, OpenCV should now be installed in/usr/local/lib/python2.7/site-pacakges . You can verify this using the ls command:

COMMAND-

$ ls -l /usr/local/lib/python2.7/site-packages/ total 1852 -rw-r--r-- 1 root staff 1895772 Mar 20 20:00 cv2.so  

Note:In some cases, OpenCV can be installed in /usr/local/lib/python2.7/dist-packages(note the dist-packages rather than site-packages ). If you do not find the cv2.so bindings insite-packages , we be sure to check dist-packages . Our final step is to sym-link the OpenCV bindings into our cv virtual environment for Python 2.7:

COMMAND-

$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/ $ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so  

For Python 3:After running make install , your OpenCV + Python bindings should be installed in/usr/local/lib/python3.5/site-packages . Again, you can verify this with the ls command:

COMMAND-

$ ls -l /usr/local/lib/python3.5/site-packages/ total 1852 -rw-r--r-- 1 root staff 1895932 Mar 20 21:51 cv2.cpython-34m.so  

I honestly don’t know why, perhaps it’s a bug in the CMake script, but when compiling OpenCV 3 bindings for Python 3+, the output .so file is named cv2.cpython-35m-arm-linux-gnueabihf.so(or some variant of) rather than simply cv2.so (like in the Python 2.7 bindings). Again, I’m not sure exactly why this happens, but it’s an easy fix. All we need to do is rename the file:

COMMAND-

$ cd /usr/local/lib/python3.5/site-packages/ $ sudo mv cv2.cpython-35m-arm-linux-gnueabihf.so cv2.so  

After renaming to cv2.so , we can sym-link our OpenCV bindings into the cv virtual environment

for Python 3.5:

COMMAND-

$ cd ~/.virtualenvs/cv/lib/python3.5/site-packages/ $ ln -s /usr/local/lib/python3.5/site-packages/cv2.so cv2.so  

Step #7:Testing your OpenCV 3 install

Congratulations, you now have OpenCV 3 installed on your Raspberry Pi 3 running Raspbian Stretch! But before we pop the champagne and get drunk on our victory, let’s first verify that your OpenCV installation is working properly.

Open up a new terminal, execute the source and workon commands, and then finally attempt to import the Python + OpenCV bindings:

COMMAND-

$ source ~/.profile$ workon cv $ python>>> import cv2>>> cv2.__version__ '3.3.0'>>>  

OpenCV 3 has been successfully installed on my Raspberry Pi 3 + Python 3.5 environment . Once OpenCV has been installed, you can remove both the opencv-3.3.0 and opencv_contrib-3.3.0 directories to free up a bunch of space on your disk:

COMMAND-

$ rm -rf opencv-3.3.0 opencv_contrib-3.3.0  

However, be cautious with this command! Make sure OpenCV has been properly installed on your system before blowing away these directories. A mistake here could cost you hours in compile time.

Open your /etc/dphys-swapfile and then edit the CONF_SWAPSIZE variable COMMAND-

# set size to absolute value, leaving empty (default) then uses computed value# you most likely don't want this, unless you have an special disk situation CONF_SWAPSIZE=100 #CONF_SWAPSIZE=1024 

Notice that I’ve commented out the 1024MB line and uncommented the 100MB line. As stated above, larger swap spaces may lead to memory corruption, so I recommend setting it back to 100MB. If you skip this step, your memory card won’t last as long. To revert to the smaller swap space, restart the swap service

COMMAND-

$ sudo /etc/init.d/dphys-swapfile stop
$ sudo /etc/init.d/dphys-swapfile start
  • STEP 4:Setting Up Python Program

You can verify that the camera works by running.

COMMAND-

$ raspistill -o image.jpg 

which will save a image from the camera in your current directory.

After you checked the camera is working. Now download all the python files and models from below link :

LINK:

https://drive.google.com/file/d/0B98uoD6BbkpqZU9FT...

You can open up the file inspector and view the image.

Make sure you are using the virtual environment by typing the following commands:

COMMANDS-

$ source ~/.profile $ workon cv  

Next, navigate to the repository directory,

COMMANDS-

$ cd Smart-Security-Camera  

and install the dependencies for the project

COMMANDS-

$ pip install -r requirements.txt  

To get emails when objects are detected, you'll need to make a couple modifications to the mail.py file. Open mail.py with vim vim mail.py , then press i to edit. Scroll down to the following section

# Email you want to send the update from (only works with gmail)fromEmail ='[email protected]' fromEmailPassword ='password1234' # Email you want to send the update to toEmail ='[email protected]'  

and replace with your own email/credentials.

The mail.py file logs into a gmail SMTP server and sends an email with an image of the object detected by the security camera. Press esc then ZZ to save and exit.

You can also modify the main.py file to change some other properties.

email_update_interval =600 # sends an email only once in this time intervalvideo_camera =VideoCamera(flip=True) # creates a camera object, flip verticallyobject_classifier =cv2.CascadeClassifier("models/fullbody_recognition_model.xml") # an opencv classifier facial_recognition_model.xml fullbody_recognition_model.xml upperbody_recognition_model.xml 

Run the program python main.py

You can view a live stream by visiting the IP address of your pi in a browser on the same network. You can find the IP address of your Raspberry Pi by typing ifconfig in the terminal and looking for the inet address. Visit :5000 in your browser to view the stream.

Note:

To view the live stream on a different network than your Raspberry Pi, you can use ngrok to expose a local tunnel. Once downloaded, run ngrok with ./ngrok http 5000 and visit one of the generated links in your browser. Note:The video stream will not start automatically on startup. To start the video stream automatically, you will need to run the program from your /etc/rc.local file see this video for more information about how to configure that. Receiving Emails When receiving an email for the first time, you might get the following notification from Google:

By default, Google blocks apps from using SMTP without permissions. We can solve this by clicking on the allow "less secure apps" link and toggle the feature on. The next object detected will send an email.

STEP 4:Blynk App Interface Setup

This is one of the easiest and fun steps. So let's get started. Shall we?

  • Downloading the Blynk App is the first obvious step. Download it from App Store or Google Play Store. Sign Up or Login in the app to get started.
  • Click on New Project to create a new project. Name it whatever you like. In devices Choose NodeMCU. In connection type choose WiFi and click on Create.
  • Now you will get a Auth key on your Email. Make sure to copy that and add that to your code.
  • Now click on the + sign to add widgets. You may need to buy some energy!
  • Now add three Gauge's. Click on of the Gauge's, name it Temperature. Choose a color of you choice for this gauge. In the pin choose Virtual Pin V6. Set the range from 0 to 50 °C ( not sure for °F), make the label °C/ °F and keep the reading rate to Push.
  • Repeat this for other two Gauges using data as shown in the pictures.
  • Now, add a zeRGBa and set R to digital Pin GP15, B to GP3 and B to GP1.
  • Now add 4 Buttons, change there colors accordingly. Set them as shown in the pictures.
  • Add a SuperChart, add 3 data streams Temperature, Humidity and gas, set there colors, there pins, Range and Suffix.
  • Now, add tabs. Go to the second tab and add Twitter, Notifications, Email and Eventor. In Twitter add you twitter username and password. In Notifications, Switch on Notify when hardware goes off. In Email, set your Email address. In Eventor you can set many triggers, see the picture for the triggers that I have set up.
  • You are done. now click on the play button to use the interface that you have created. You can change the interface as you like. It is really simple and fun process!

STEP 5:Making Octopod Structure

Warning - This is going to be one of most time-consuming process!

NOTE:You can skip this step and 3D print the enclosure that I have provided!

Actually, this step is optional yet the most important step! You can just take a shoe box and avoid all of this hard work. But on the contrary, this hard work makes the project unique. The idea for this unique design striked me while, I was doing my math homework. This shape is inspired from an octagon. Rather, This is a 3D octagon! Fangen wir also an!

Making the Structure:

  • Take your cardboard and draw a rectangle of 9 cm x 9.5 cm (You can change the dimensions as per your convince). Now, joining end to end draw 4 of theses similar rectangles (8 if your cardboard is long enough).
  • Now make partial cuts (somewhat like paper creases) in between these rectangles and cut out this whole long piece. Repeat this process until you have 4 of these long pieces.
  • Now, using a D draw a 135° and cut it out as shown in the images. Make 16 of these same angles.
  • Using Glue gun glue these angles in between the small pieces. Repeat this for all the joints.
  • Now using glue gun join 2 of these open structures to make a closed structure (somewhat octagon) .
  • Now glue the other two open structure perpendicularly, making a 3-D shape.
  • Now Cut 4 More pieces of of 9 x 9.5 cm and glue them in between all the empty spaces.
  • Now you will be left with only 8 open triangles. Using Acrylic Butter paper cut 8 triangles, which will fit on these open areas, but don't glue them now.

Paint Job:

For this you need to head out towards an open area! Wear your Mask and Gloves and just make one coat over the structure that you have created. You can go to Youtube, to learn proper ways to make a perfect coat. Now let this dry for 4- 5 Hours and then apply 1 more coat. I think 3 coats will be good for this.

That's it! You have arrived with a unique piece of art.

STEP 6:Making Door Lock Enclosure

Really simple. Just take a Shoe Box and apply 2- 3 even coats of spray. And maybe for design make check pattern using duck tape like we did!

STEP 7:Assembling the Octopod

I have tried to make this step as simple as possible, by making the schematic diagram. Refer the picture or the file, and make connections accordingly. I will briefly explain all the connections!

  • We have connected the nodeMCU to a large size Solderless Breadboard. We have also connected Breadboard power supply on the breadboard. NodeMCU, all the sensors, LED's and other components are powered by the power supply.
  • Following are the sensor connections:DHT11D4 / GP2 MQ2A0 / adc00 Soil Moisture SensorD2 / GP4 PIRD6 / GP1 RGB R → D8 / GP15, G → Rx / GP3, B → Tx / GP1 RelayLn1D0 / GP16, Ln2D5 / GP14 Make the following connections.
  • For powering this you can use Power Bank or a Wall Adapter, which will be connected to the breadboard Power supply.
  • Now, take your Raspberry Pi along with the Raspberry Pi Camera. Make a small hole in one of the walls of the cardboard and glue or tape your Raspberry Camera.

Now, insert all these electronics inside, through any open triangle and close the triangle by using the cut outs of acrylic butter paper that we made. It is better to leave 1 or 2 open, in case something inside needs to be fixed! Also let the prongs of the Soil Moisture Sensor sit outside.

All done! We have completed the making process of the Octopod! Now, Just switch On the power and keep your Octopod over the dining Table or maybe on the Guest's Table and enjoy! To see the live feed from the Raspberry Pi, just open a browser and put in the IP address of the Pi. Enjoy!

STEP 8:Assembling the Door Lock

After uploading the code on your Arduino just make the connections as shown in the picture or in fritzing file! It is quite simple. Then take the handy shoe box that we made make 2 holes in it for the LED's to pop out. and allow the servo to stand out. These days mechanical locks like servo's are also available in the market, though servo works just as fine. This is just an experiment, so please so please don't use this as you actual lock! Glue the Rfid to one wall of the box and also glue the small breadboard and Arduino. You can use a wall adapter or a Power bank to power this. Just power the Arduino and you will be good to go! Done!

CONCLUSION:

This was a really fun project to do!

I was really happy how it turned out. I think the lights look really well, and i think its well worth making even one of these as a side lamp. I really can't thank creators of Blynk and OpenCV libraries enough, they are both really excellent pieces of software and made this project possible! As always, if you have any questions on any part of the process please let me know and I will be happy to try help. Thanks a lot! And Please Vote for Us!

-Saksham

Arduino Blog

Full Instructable

UPDATE:

I have been working on integrating this system with Amazon Alexa, I am almost done. Will upload the code in 2-3 days!

Code

  • octopod.ino
  • octopod_door.ino
  • octopod_door_bluetooth.ino
octopod.inoArduino
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/latestDownload latest DHT Sensor library here:https://github.com/adafruit/DHT-sensor-library***************************************************************************/#include  //Include ESP8266 Wifi Library#include  //Include Blynk Library#include  //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 moist ure 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 Valueint soilValue; // Place to store read Soil Moisture Valueint PIRpinValue; // Place to store the value sent by Blynk App Pin V0int 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, AM2301DHT 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(); // oder dht.readTemperature (true) für Fahrenheit if (isnan (h) || isnan (t)) { Serial.println ( "Fehler beim Lesen vom DHT-Sensor!"); // to check if sensor is not sending any false values return; } // Sie können jederzeit einen beliebigen Wert senden. // Bitte senden Sie nicht mehr als 10 Werte pro Sekunde. 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.inoArduino
Code for Automatic Door Lock Control (NO BLUETOOTH VERSION)
/*********************************************************************************************************** OCTOPOD:A SMART HOME AUTOMATION PROJECT MADE BY SAKSHAM ARDUINO RFID DOOR LOCK CODELibrary Required - MFRC522 ************************************************************************************************************/#include #include #include  #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 pinMFRC522 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  
octopod_door_bluetooth.inoArduino
Code for Automatic Door Lock Control (Bluetooth Version)
/*********************************************************************************************************** OCTOPOD:A SMART HOME AUTOMATION PROJECT MADE BY SAKSHAM ARDUINO RFID DOOR LOCK CODELibrary Required - MFRC522 ************************************************************************************************************/#include SoftwareSerial BTserial(0, 1); // RX | TX#include #include #include #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 pinMFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.Servo myServo; //define servo namevoid 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  

Kundenspezifische Teile und Gehäuse

This is the basic design that you can use if you want to make the enclosure out of Cardboard/ Wood like me! octopod_v2_ukTmIJ0uMl.f3dProper Enclosure that you can 3D Print! octo_2_v3_sii4tuCF7d.f3d

Schaltpläne

Pin configuration might be different with Arduino MKR 1010 Without Bluetooth
For Bluetooth connect Rx (HC-05) --> Tx (Arduino)
Tx (HC-05) --> Rx (Arduino)
and 5v to 5v
Ground to Ground 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

Herstellungsprozess

  1. Anwendungen der Heimautomatisierung
  2. heimtückische Malvertising-Attacken auf Smart Home IoT
  3. RASPBERRY PI HOME AUTOMATION
  4. Smart Blinds
  5. IOT - Smart Jar mit ESP8266, Arduino und Ultraschallsensor
  6. Smart Home Automation und Sicherheitssystem mit 1Sheeld
  7. Tech-TicTacToe
  8. Arduino-Countdown-Timer
  9. Smart Door Lock mit WLAN-Anmeldeseite von Arduino &ESP8266
  10. Automatisierung in der Industrie 4.0