a harbinger of events or things.

Overview

Herald: Intrusion Detection System using IR and ML

Herald - noun; a harbinger of events or things.

Overview

Herald is an intrusion detection system using infrared radiation and anomaly detection using machine learning and Bolt IoT wifi module. The IoT device makes use of IR sensor and cloud technology for alerting the stakeholders of the detected anomaly.

Things used in this project

Hardware Most of the hardware components can be found in the Bolt IoT starter kit and digital components are relatively inexpensive.

Hardware Components

  • Bolt IoT Wifi Module - 1 unit
  • Male-Male jumper wires - 3 units
  • Mini Breadboard - 1 unit
  • FC-51 or TCRT5000 Infrared Radiation Sensor - 1 unit
  • Powerbank capable of providing at least 5V - 1 unit
  • USB cable to power the module - 1 unit
  • Bolt IoT Starter box (for containing) - 1 unit

Software/digital requirements

  • Python
  • Cloud VPS
  • SMTP Credentials
  • Bolt Cloud Pro Account (for better API rate limit, not required for testing)

Story

Introduction

An intrusion detection system monitors an area for malicious activity or privacy violations. These are reported to the person(s) whom it concerns via an alert system. It can protect your home/office by detection intrusion.

Our system utilizes machine learning to adjust the alert parameters and emails the concerned entities via Simple Mail Transfer Protocol.

FC-51 or TCRT5000. Which one to use?

TCRT5000 and FC-51 Both IR sensors are capable to provide valid results for this experiment however, for anomaly detection, the TCRT5000 should work better than FC-51. The reason being that TCRT5000 can provide both analog and digital output depending upon the proximity of the object and the FC-51 sensor can only provide either HIGH or LOW output depending upon the detection and doesn't consider the proximity of the object.

While creating this project, I tried to purchase the TCRT5000 sensor but due to COVID-19 lockdown and restrictions on online shopping, I was unable to purchase it. So, I had to settle with an FC-51 sensor. Ideally, I should have used a TCRT5000.

I have written this and the code with compatibility of both sensors and either can be used without changing the code and connections.

Procedure

Setting up the hardware

Step 1: Connect the sensor to breadboard. This is optional. In case you want to connect the sensor directly to the Bolt IoT Wifi Module, you may do so.

breadboard and sensor

Step 2: Connect the male-male jumper wires to the corresponding pins on the breadboard.

jumper with breadboard and sensor

Step 3: Connect the other end of jumper wires to the Bolt module. Connection should match as:

Sensor to Bolt Module connections:
VCC <-> 5V
GND <-> GND
OUT <-> A0

bolt

Step 4: Power on the bolt module via a power bank or direct connection of at least 5V.

Step 5: Verify connectivity on bolt module and connections. The IR sensor should show an LED for power and another LED may light up in case it detects some object in proximity. You may adjust the sensitivity by adjusting the potentiometer.

Loading the software

The code is written in the Python language and is coded to be suitable with both types of hardware described above. You will need to install Python which can be done easily (just google it if you don’t have it) and then install the Bolt IoT library via pip.

For deployment purpose, you will need a VPS for hosting the script and SMTP credentials for emailing. You may create a VPS via DigitalOcean or AWS and use Gmail credentials for sending emails (you should create a new Gmail account for this instead of using a personal account). However, if you are just trying the project, you may skip these and run on your PC.

Step 1: Log in to your server

Step 2: Assuming you already have python3 installed, run this command to install the Bolt IoT library

$ pip3 install boltiot

Step 3: Clone the git repository containing the code and navigate to it

$ git clone https://github.com/muhammadmuzzammil1998/herald; cd herald

git clone

Configuring the system

After cloning the repository, you have to edit the configuration file config.py as per your own configurations and requirements. The contents of config.py are used in the main code and have description along the line as well.

You might want to adjust the api_limit_margin and api_limit_per_minute as per your bolt account or use the pro account.

$ nano config.py # To edit the configurations
# API and Device configurations #

api_key = ""              #Bolt user API key
device_id = ""            #Bolt device ID
cooldown = 10             #Cooldown after an unsuccessful api call to device in seconds
frame_size = 5            #Frame size for computing z-score
factor = 2                #Factor for computing z-score
api_limit_per_minute = 20 #Ratelimit for the API requests per minute
api_limit_margin = 1      #API calls to leave as margin
interval = 60 / (api_limit_per_minute - api_limit_margin) #Optional edit: Interval for checking status

# Email configurations #

smtp_server = ":587"  #SMTP server with port in format smtp.gmail.com:587
sender_name = "Herald - the intrusion detector" #Sender's name to display
sender_email = ""     #Username for SMTP server
sender_password = ""  #Password for SMTP server
recipients = ""       #Single recipient in string or a list of recipients in array form
  • api_key: You can obtain it from cloud.boltiot.com
  • device_id: Same as cloud.boltiot.com
  • cooldown: Time to pause after an unsuccessful api call to device
  • frame_size: Used to calculate the boundary for data
  • factor: Used for anomaly detection
  • api_limit_per_minute: Ratelimit for the API requests per minute
  • api_limit_margin: API calls to leave for other stuff
  • interval: Automatically calculated as per above two parameters
  • smtp_server: Address of your SMTP server with port. We are using TLS encryption with 587 port. Gmail uses smtp.gmail.com:587.
  • sender_name: Name to display on email alert
  • sender_password: Password for your gmail account
  • recipients: Email addresses of the stakeholders who should be informed. Can be string or list of strings.

Starting Herald

final

Ensure that you have correctly connected the pins as VCC to 5V, GND to GND, and OUT to A0.

Type the following command to start the program. Make sure your Bolt module is connected to the internet and cloud, as indicated by the blue and green LEDs on wifi module and LED on the sensor module.

$ python3 main.python3

execution

As you can see from the above output, an alert is sent when bounds changed. The bounds are calculated using Machine Learning so that minor object detection, such as curtain flowing in front, can be handled without triggering a false alert.

Bounds are calculated using z-score analysis for anomaly detection as:

zscore

Code explanation

z_score

z_score function takes in the dataset, frame size, and the factor to adjust the boundary of the given curve. It returns the range in which the next data point should fall.

sensor_data

sensor_data takes in the pin to read from and returns the value read when successful. In case there is an error, the function also deals with it.

verify_dataset

To ensure that we have sufficient data to generate boundaries for anomaly detection.

Why read analog instead of digital read?

The reason here for opting for analog is that the, as discussed earlier, I wished to build this with an advanced sensor but could not get my hands on it. Therefore, to be compatible with both sensors, I chose to read analog input.

Schematics

schematics

Conclusion

To conclude, we built an intrusion detection system using Bolt IoT which was able to sense the presence when passing through. I installed the device in my home and the device was powered by a power bank. It worked and I received emails when passing through the door.

Owner
Muhammad Muzzammil
I code stuff.
Muhammad Muzzammil
Telegram bot to trim and download videos from youtube.

Inline-YouTube-Trim-Bot Telegram bot to trim and download youtube videos Deploy You can deploy this bot anywhere. Demo - YouTubeBot Required Variables

SUBIN 56 Dec 11, 2022
RevSpotify is a fast, useful telegram bot to have Spotify music on Telegram.

RevSpotify A Telegram Bot that can download music from Spotify RevSpotify is a fast, useful telegram bot to have Spotify music on Telegram. ✨ Features

Alireza Shabani 12 Sep 12, 2022
Twitter bot code can be found in twitterBotAPI.py

NN Twitter Bot This github repository is BASED and is yanderedev levels of spaghetti Neural net code can be found in alexnet.py. Despite the name, it

167 Dec 19, 2022
SkyzoMusicBot - Bot Music Telegram By Skyzo

SKYZO MUSIC BOT Telegram Music Bot And Stream Feature New Version Ready to use m

Skyzo 19 Apr 08, 2022
Droplink URL Shortener Bot, deployable to Heroku and Railway.

Droplink-bot Make short link by using Droplink API key. Made by @dakshy. Installation The Easy Way Required Variables BOT_TOKEN: Create a bot using @B

ToonsHub 5 Jun 25, 2022
Draw your telegram bot in draw.io and generate its code

README Contents: Draw your bot Install requirements Registering a telegram bot Draw bot Start point Message block Single choice block Functions block

DENIS TSITKO 23 Nov 09, 2022
Twitch Points Miner for multiple accounts with Discord logging

Twitch Points Miner for multiple accounts with Discord logging Creator of the Twitch Miner -- PLEASE NOTE THIS IS PROBABLY BANNABLE -- Made on python

8 Apr 27, 2022
This bot will automatically like and follow users that post under a specified hashtag

Instagram-bot This bot will automatically like and follow users that post under a specified hashtag Dependencies Java JDK Selenium Updated version of

Makana Edwards 1 Nov 04, 2021
✖️ Unofficial API of 1337x.to

✖️ Unofficial Python API Wrapper of 1337x This is the unofficial API of 1337x. It supports all proxies of 1337x and almost all functions of 1337x. You

Hemanta Pokharel 71 Dec 26, 2022
Example-bot-discord - Example bot discord xD

example-python-bot-discord Clone this repository Grab a token on Discord's devel

Amitminer 1 Mar 14, 2022
A Bot Telegram Anti Users Channel to automatic ban users who using channel to send message in group.

Tg_Anti_UsersChannel A Bot Telegram Anti Users Channel to automatic ban users who using channel to send message in group. Features: Automatic ban Whit

idzeroid 6 Dec 26, 2021
A Discord token grabber written in Python3, with awesome obfuscation and anti-debug protection.

☣️ Plague ☣️ Plague is a Discord token grabber written in Python3, obfuscated with Kramer, protected from traffic analysers with Scarecrow and using t

Billy 125 Dec 20, 2022
Zero2 Discord bot is written with Discord.py using Python.

Zero2 Discord bot is written with Discord.py using Python.

Siva Avanish 4 Nov 08, 2021
A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats.

VC UserBot A Telegram Userbot to play Audio and Video songs / files in Telegram Voice Chats. It's made with PyTgCalls and Pyrogram Requirements Python

조던 1 Nov 29, 2021
Public release of Telepathy, an OSINT toolkit for investigating Telegram groups. Enhanced features and improvements will be added over time.

Telepathy Welcome to Telepathy, an OSINT toolkit for scraping Telegram data to help investigate shady goings on. Currently, the tool is limited to scr

Jordan Wildon 484 Jan 01, 2023
Herramienta para transferir eventos de Sucuri WAF hacia Azure Monitor Log Analytics.

Transfiere eventos de Sucuri hacia Azure LogAnalytics Script para transferir eventos del Sucuri Web Application Firewall (WAF) hacia Azure LogAnalytic

CSIRT-RD 1 Dec 22, 2021
twtxt is a decentralised, minimalist microblogging service for hackers.

twtxt twtxt is a decentralised, minimalist microblogging service for hackers. So you want to get some thoughts out on the internet in a convenient and

buckket 1.8k Jan 09, 2023
Python library for RetroMMO related stuff, including API wrapper

python library for RetroMMO related stuff, including API wrapper.

1 Nov 25, 2021
Data from popular CS:GO website hltv.org

Welcome to hltv-data 👋 🎮 Data from popular CS:GO website hltv.org Install pip install hltv-data Usage The public methods can be reached using HLTVCl

Dariusz Choruży 28 Dec 23, 2022
Amazon AWS Web Tool (view only)

Amazon AWS Web Tool (AAWT) discontinued Features Cloudfront (simple) EC2 (With Charts and Prices) EC2 Reserved EBS ELB (With Charts) Obs:. only classi

Carlos Augusto Malucelli 9 Nov 07, 2022