0% found this document useful (0 votes)
7 views

CODE

Codes for risc verilog

Uploaded by

Balaji Karthic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CODE

Codes for risc verilog

Uploaded by

Balaji Karthic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

19CSE350 Internet of Things

Term Project
Batch : 5
Title : Home Security Automation

This report presents the code structure for the ESP32-based Home
Security Automation system. Each node within the system is listed
with its respective code. The

1. SERVER:
//receiver side
#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <LCD_I2C.h>
LCD_I2C lcd(0x27);

#define BLYNK_TEMPLATE_ID "TMPL3lYLy1J4V"


#define BLYNK_TEMPLATE_NAME "HOME SECURITY"
#define BLYNK_AUTH_TOKEN "RHqPlMuKI8Q-
61aEhkWXf320vtYLe-ra"

char ssid[] = "IOT";


char pass[] = "123456789";
char auth[] = BLYNK_AUTH_TOKEN;

#include <EveryTimer.h>
#define PERIOD_MS 1000
EveryTimer timer;
BlynkTimer timer1;

int sec = 0;

void setup() {
Serial.begin(9600);
Serial.print("SETUP");
lcd.begin();
timer.Every(PERIOD_MS, action);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("HOME SECURITY");
lcd.setCursor(0, 1);
lcd.print("AUTOMATION MAIN");
delay(3000);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
lcd.clear();
Blynk.syncVirtual(V6);
Blynk.syncVirtual(V7);
}

void loop() {
timer.Update();
Blynk.run();
delay(1000);
if (sec >= 10) { lcd.clear(); sec = 0; Serial.println("LCD
CLEARED"); }
}

BLYNK_WRITE(V6) {
String button = param.asStr();
Serial.print("Button value :");
Serial.println(button);
lcd.setCursor(0, 0);
lcd.print(button);
}

BLYNK_WRITE(V7) {
String button = param.asStr();
Serial.print("Button value :");
Serial.println(button);
lcd.setCursor(0, 1);
lcd.print(button);
}

void action() {
Serial.print("pull data from nodemcu");
Serial.print('#');
Blynk.syncVirtual(V6);
Blynk.syncVirtual(V7);
sec++;
}

2. NODE 1
#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <LCD_I2C.h>
LCD_I2C lcd(0x27);

#define ir 4
#define fire 27
#define gas 35
#define pir 14

#define BLYNK_TEMPLATE_ID "TMPL3lYLy1J4V"


#define BLYNK_TEMPLATE_NAME "HOME SECURITY"
#define BLYNK_AUTH_TOKEN "RHqPlMuKI8Q-
61aEhkWXf320vtYLe-ra"

char ssid[] = "IOT";


char pass[] = "123456789";
char auth[] = BLYNK_AUTH_TOKEN;
int gasval, fireval, pirval, irval;

#include <EveryTimer.h>
#define PERIOD_MS 1000
EveryTimer timer;
BlynkTimer timer1;

void setup() {
Serial.begin(9600);
Serial.print("SETUP");
lcd.begin();
timer.Every(PERIOD_MS, action);
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("HOME SECURITY");
lcd.setCursor(0,1);
lcd.print("AUTOMATION 1");
delay(3000);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
lcd.clear();
pinMode(fire, INPUT);
pinMode(gas, INPUT);
pinMode(pir, INPUT);
pinMode(ir, INPUT);
Blynk.syncVirtual(V6);
Blynk.syncVirtual(V7);
}

void loop() {
Serial.print("FIRE:");
Serial.println(digitalRead(fire));
fireval = digitalRead(fire);

Serial.print("PIR:");
Serial.println(digitalRead(pir));
pirval = digitalRead(pir);

Serial.print("IR:");
Serial.println(digitalRead(ir));
irval = digitalRead(ir);
if(digitalRead(fire) == 0) {
Serial.print("-------------fire detection");
lcd.setCursor(0, 1);
lcd.print("F:DET");
Blynk.virtualWrite(V0,"FIRE DETECTION");
delay(3000);
} else {
Blynk.virtualWrite(V0," ");
lcd.setCursor(0, 1);
lcd.print("F:NOT");
}

if(digitalRead(ir) == 0) {
Serial.print("------------------OBJECT DETECTED");
Blynk.virtualWrite(V0, "OBJECT DETECTED");
Blynk.virtualWrite(V6, "F1:" + String(fireval) + " H:" +
String(pirval) + " IR1:" + String(irval) + " G:" + String(gasval));
lcd.setCursor(6, 1);
lcd.print("IR:DET");
delay(3000);
} else {
Blynk.virtualWrite(V0, " ");
lcd.setCursor(6, 1);
lcd.print("IR:NOT");
}

if(digitalRead(pir) == 1) {
Serial.print("------------------HUMAN DETECTED");
lcd.setCursor(6, 0);
lcd.print("H:DET");
Blynk.virtualWrite(V0, "HUMAN DETECTED");
} else {
lcd.setCursor(6, 0);
lcd.print("H:NOT");
Blynk.virtualWrite(V0, " ");
}

Serial.print("GAS:");
Serial.println(analogRead(gas));
gasval = (analogRead(gas));
gasval = map(gasval, 0, 1023, 0, 100);
if (gasval < 0 || gasval > 100) {
gasval = 100;
}
Serial.print(gasval);
lcd.setCursor(0, 0);
lcd.print("G:");
if (gasval <= 9) { lcd.print("00"); lcd.print(gasval); }
else if (gasval <= 99) { lcd.print("0"); lcd.print(gasval); }
else if (gasval <= 999) { lcd.print(""); lcd.print(gasval); }

if(gasval > 60) {


Serial.print("-------------gas detection");
Blynk.virtualWrite(V0, "GAS LEAKAGE DETECTED");
} else {
Blynk.virtualWrite(V0, " ");
}

Blynk.run();
delay(3000);
Blynk.virtualWrite(V6, "F1:" + String(fireval) + " H:" +
String(pirval) + " IR1:" + String(irval) + " G:" + String(gasval));
}

void action() {
Serial.print("pull data from nodemcu");
Serial.print('#');
Blynk.syncVirtual(V6);
Blynk.syncVirtual(V7);
}

3. NODE 2

//fire and gas sensor node


#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <LCD_I2C.h>
LCD_I2C lcd(0x27);

#define fire 27
#define gas 35

#define BLYNK_TEMPLATE_ID "TMPL3lYLy1J4V"


#define BLYNK_TEMPLATE_NAME "HOME SECURITY"
#define BLYNK_AUTH_TOKEN "RHqPlMuKI8Q-
61aEhkWXf320vtYLe-ra"

char ssid[] = "IOT";


char pass[] = "123456789";
char auth[] = BLYNK_AUTH_TOKEN;

int gasval, fireval;


#include <EveryTimer.h>
#define PERIOD_MS 1000
EveryTimer timer;
BlynkTimer timer1;

void setup() {
Serial.begin(9600);
Serial.print("SETUP");
lcd.begin();
timer.Every(PERIOD_MS, action);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("HOME SECURITY");
lcd.setCursor(0, 1);
lcd.print("AUTOMATION 2");
delay(3000);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
lcd.clear();
pinMode(fire, INPUT);
pinMode(gas, INPUT);
Blynk.syncVirtual(V6);
Blynk.syncVirtual(V7);
}

void loop() {
timer.Update();
Serial.print("FIRE:");
Serial.println(digitalRead(fire));
fireval = digitalRead(fire);

if (digitalRead(fire) == 0) {
Serial.print("-------------fire detection");
lcd.setCursor(0, 1);
lcd.print("F:

DET");
Blynk.virtualWrite(V1, "FIRE DETECTION");
Blynk.virtualWrite(V7, "F2:" + String(fireval) + " MQ2: " +
String(gasval));
delay(3000);
} else {
Blynk.virtualWrite(V1, " ");
lcd.setCursor(0, 1);
lcd.print("F:NOT");
}

Serial.print("GAS:");
Serial.println(analogRead(gas));

gasval = analogRead(gas);
gasval = map(gasval, 0, 1023, 0, 100);
if (gasval < 0 || gasval > 100) {
gasval = 100;
}
Serial.print(gasval);
lcd.setCursor(0, 0);
lcd.print("G:");
if (gasval <= 9) { lcd.print("00"); lcd.print(gasval); }
else if (gasval <= 99) { lcd.print("0"); lcd.print(gasval); }
else if (gasval <= 999) { lcd.print(""); lcd.print(gasval); }

if (gasval > 80) {


Serial.print("-------------gas detection");
lcd.setCursor(0, 1);
Blynk.virtualWrite(V1, "GAS LEAKAGE DETECTED");
} else {
Blynk.virtualWrite(V1, " ");
}

Blynk.run();
delay(3000);
Blynk.virtualWrite(V7, "F2:" + String(fireval) + " MQ2: " +
String(gasval));
}

void action() {
Serial.print("pull data from nodemcu");
Serial.print('#');
Blynk.syncVirtual(V6);
Blynk.syncVirtual(V7);
}

4. NODE 3
//controller node
#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define relay1 2
#define relay2 4
#define relay3 14
#define relay4 27

#include <Wire.h>
#include <LCD_I2C.h>
LCD_I2C lcd(0x27);

#define BLYNK_TEMPLATE_ID "TMPL3WZAyqtwW"


#define BLYNK_TEMPLATE_NAME "HOME SECURITY"
#define BLYNK_AUTH_TOKEN
"HS4ecLdcxo7zVhkyzCUtpRF4kS8mE_hV"

char ssid[] = "IOT";


char pass[] = "123456789";
char auth[] = BLYNK_AUTH_TOKEN;

void setup() {
Serial.begin(9600);
Serial.print("SETUP");
lcd.begin();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("HOME SECURITY");
lcd.setCursor(0,1);
lcd.print("AUTOMATION 4");
delay(3000);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
lcd.clear();

pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);

digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
}

void loop() {
Blynk.run();
delay(1000);
}

BLYNK_WRITE(V9) {
int button = param.asInt();
if (button == 1) {
Serial.println("LAMP ON");
digitalWrite(relay1, LOW);
lcd.setCursor(0, 0);
lcd.print("L1:ON ");
} else {
Serial.println("LAMP OFF");
digitalWrite(relay1, HIGH);
lcd.setCursor(0, 0);
lcd.print("L1:OFF");
}
}

BLYNK_WRITE(V10) {
int button = param.asInt();
if (button == 1) {
Serial.println("FAN ON");
digitalWrite(relay2, LOW);
lcd.setCursor(0, 1);
lcd.print("L2:ON ");
} else {
Serial.println("LAMP OFF");
digitalWrite(relay2, HIGH);
lcd.setCursor(0, 1);
lcd.print("L2:OFF");
}
}

BLYNK_WRITE(V11) {
int button = param.asInt();
if (button == 1) {
Serial.println("forward");
digitalWrite(relay3, LOW);
lcd.setCursor(10, 0);
lcd.print("L3:ON ");
} else {
Serial.println("STOP");
digitalWrite(relay3, HIGH);
lcd.setCursor(10, 0);
lcd.print("L3:OFF");
}
}
BLYNK_WRITE(V12) {
int button = param.asInt();
if (button == 1) {
Serial.println("reverse");
digitalWrite(relay4, LOW);
lcd.setCursor(10, 1);
lcd.print("L4:ON ");
} else {
Serial.println("stop");
digitalWrite(relay4, HIGH);
lcd.setCursor(10, 1);
lcd.print("L4:OFF");
}
}
Web server codes
This section contains the code for the design, implementation, and
integration of the front-end and back-end web server with Blynk IoT
software. This integration connects the web server with the IoT
system nodes and displays sensor values and system status.

Modules:

1. app
1.1. admin.py
1.2. apps.py
1.3. models.py
1.4. utils.py
1.5. views.py

2. homesecurity
2.1. asgi.py
2.2. settings.py
2.3. urls.py
2.4. wsgi.py

3. manage.py
1. app

1.1 admin.py
from django.contrib import admin
from .models import *
# Register your models here.
admin.site.register(SmokeData)
admin.site.register(HumanData)
admin.site.register(ObjectData)

1.2 apps.py
from django.apps import AppConfig
class AppConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'app'

1.3 models.py
from django.db import models
# Create your models here.
class SmokeData(models.Model):
smoke_value = models.IntegerField() # Store the smoke value
timestamp = models.DateTimeField() # Automatically store current
date and time
class HumanData(models.Model):
human_value = models.IntegerField()
timestamp = models.DateTimeField()
class ObjectData(models.Model):
object_value = models.IntegerField()
timestamp = models.DateTimeField()

1.4 utils.py

import requests
import re
BLYNK_AUTH_TOKEN = 'RHqPlMuKI8Q-
61aEhkWXf320vtYLe-ra'
#BLYNK_BASE_URL = 'http://blynk-cloud.com'
def get_blynk_data(pin):
# Blynk API endpoint for reading pin data
url = f"https://blynk.cloud/external/api/get?token=RHqPlMuKI8Q-
61aEhkWXf320vtYLe-ra&pin={pin}"
# Make a GET request to the Blynk server
try:
response = requests.get(url)
if response.status_code == 200:
data = response.text.strip('[]').strip("'")
print(f"Raw data from Blynk: {data}") # Debugging line
# If pin is V6 or V7, parse the data into a dictionary
if pin in ['V6', 'V7']:
data = data.replace(" ", "")
# Find all letter-number pairs, e.g., [('F', '1'), ('H', '0'), ('IR', '1'), ('G',
'89')]
matches = re.findall(r'([A-Z0-9]+)(?::(\d+))?', data)
# Convert to dictionary where key is the identifier and value is its
number
parsed_data = {key: value for key, value in matches}
print(parsed_data)
return parsed_data # e.g., {'F': '1', 'H': '0', 'IR': '1', 'G': '89'}
# For other pins, return normal comma-separated split
return data.split(',')
else:
return None
except requests.exceptions.RequestException as e:
print(f"Connection error: {e}")
return None

1.5 views.py
import requests
from django.shortcuts import render,redirect
from django.contrib.auth import logout
from django.utils import timezone
from .models import SmokeData,HumanData,ObjectData
from .utils import get_blynk_data
from datetime import datetime
import pytz
# Create your views here.
BLYNK_AUTH_TOKEN = "RHqPlMuKI8Q-
61aEhkWXf320vtYLe-ra"
# SM_VPIN = "V0"
# H_VPIN = "V1"
# Create your views here.
def index(request):
return render(request,"sensor_data/index.html")
def logout_view(request):
logout(request)
return redirect('home')
def login(request):
if request.method == 'POST':
username = request.POST.get('uname')
password = request.POST.get('pswd')
# Check hard-coded username and password
if username == 'admin' and password == 'admin':
# Here you can create a user session or simply redirect
print(username)
print(password)
return redirect('sensor-data') # Redirect to the home page
else:
error_message = 'Invalid username or password'
return render(request, 'sensor_data/index.html', {'error_message':
error_message})
return render(request, 'sensor_data/index.html')
def display_sensor_data(request):
# Fetch data from V6 and V7 pins
v6_data = get_blynk_data('V6') # Now returns a dictionary with
parsed values
v7_data = get_blynk_data('V7') # Similarly returns a dictionary
# Example: Accessing 'H' value from V6 if it exists
h_value = v6_data.get('H', 'N/A') if v6_data else 'N/A'
print(h_value)
ir_value=v6_data.get('IR1', 'N/A') if v6_data else 'N/A'
print(ir_value)
sm_value=v7_data.get('MQ2', 'N/A') if v7_data else 'N/A'
print(sm_value)
# Prepare context to pass to the template
if h_value == '1':
current_time = timezone.now() # Get current date and time
ist_timezone = pytz.timezone('Asia/Kolkata')
current_time_ist = timezone.now().astimezone(ist_timezone) # Get
the current time in IST
naive_current_time_ist = current_time_ist.replace(tzinfo=None) #
Convert current_time_ist to naive datetime (remove timezone info)
print(current_time_ist)
# Create an instance of MyModel with IST time
# my_instance =
SmokeData.objects.create(time_in_ist=current_time_ist)
# Store in database
HumanData.objects.create(human_value=h_value,
timestamp=naive_current_time_ist)
detection_message = "Detected"
else:
detection_message = "Not Detected"
if ir_value == '1':
current_time = timezone.now() # Get current date and time
ist_timezone = pytz.timezone('Asia/Kolkata')
current_time_ist = timezone.now().astimezone(ist_timezone) # Get
the current time in IST
naive_current_time_ist = current_time_ist.replace(tzinfo=None) #
Convert current_time_ist to naive datetime (remove timezone info)
print(current_time_ist)
# Create an instance of MyModel with IST time
# my_instance =
SmokeData.objects.create(time_in_ist=current_time_ist)
# Store in database
ObjectData.objects.create(object_value=ir_value,
timestamp=naive_current_time_ist)
detection_message1 = "Detected"
else:
detection_message1 = "Not Detected"
current_time = timezone.now() # Get current date and time
ist_timezone = pytz.timezone('Asia/Kolkata')
current_time_ist = timezone.now().astimezone(ist_timezone) # Get
the current time in IST
naive_current_time_ist = current_time_ist.replace(tzinfo=None) #
Convert current_time_ist to naive datetime (remove timezone info)
print(current_time_ist)
# Create an instance of MyModel with IST time
# my_instance =
SmokeData.objects.create(time_in_ist=current_time_ist)

# Store in database
SmokeData.objects.create(smoke_value=sm_value,
timestamp=naive_current_time_ist)
context = {
'v6_data': v6_data or {'Error': 'Error retrieving data'},
'v7_data': v7_data or {'Error': 'Error retrieving data'},
'h_value': h_value,
'ir_value':ir_value,
'sm_value':sm_value,
'dm':detection_message,
'dm1':detection_message1
}

# Render the data in the template


return render(request, 'sensor_data/view.html', context)

def smoke_data_report(request):
# Fetch all records of SmokeData from the database
smoke_data_list = SmokeData.objects.all().order_by('-timestamp') #
Order by timestamp descending
# Pass the smoke data to the template
context = {
'smoke_data_list': smoke_data_list
}
return render(request, 'report/smoke_data_report.html', context)
def human_data_report(request):
# Fetch all records of SmokeData from the database
human_data_list = HumanData.objects.all().order_by('-timestamp') #
Order by timestamp descending

# Pass the smoke data to the template


context = {
'human_data_list': human_data_list
}
return render(request, 'report/human_data_report.html', context)
def object_data_report(request):
# Fetch all records of SmokeData from the database
object_data_list = ObjectData.objects.all().order_by('-timestamp') #
Order by timestamp descending

# Pass the smoke data to the template


context = {
'object_data_list': object_data_list
}
return render(request, 'report/object_data_report.html', context)

2. Homesecurity
2.1 asgi.py
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'homesecurity.settings')
application = get_asgi_application()

2.2 settings.py
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.


BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production


# See
https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production


secret!
SECRET_KEY = 'django-insecure-
ke9y8snqw(0=p(it7ua4klbozv7dsq^zp2_i01iz_$hcj(4q02'

# SECURITY WARNING: don't run with debug turned on in


production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'homesecurity.urls'

TEMPLATES = [
{
'BACKEND':
'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'homesecurity.wsgi.application'

# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-
validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME':
'django.contrib.auth.password_validation.UserAttributeSimilarityVal
idator',
},
{
'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidat
or',
},
{
'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidato
r',
},
]

# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_TZ = False

# Static files (CSS, JavaScript, Images)


# https://docs.djangoproject.com/en/5.1/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [
BASE_DIR / "static", # or the path to your static folder
]

# Default primary key field type


# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-
field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

2.3 urls.py
from django.contrib import admin
from django.urls import path
from app import views
from django.contrib.auth import logout

urlpatterns = [
path('admin/', admin.site.urls),
path('', views.login,name="index"),
path('', views.index,name="home"),
path('logout/',views.logout_view,name='logout') ,
path('sensor-data/', views.display_sensor_data, name='sensor-
data'),
path('smoke-data-report/', views.smoke_data_report,
name='smoke_data_report'),
path('human-data-report/', views.human_data_report,
name='human_data_report'),
path('object-data-report/', views.object_data_report,
name='object_data_report'),
]

2.4 wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'homesecurity.settings')

application = get_wsgi_application()

3. manage.py
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'homesecurity.settings')
try:
from django.core.management import
execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable?
Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

if __name__ == '__main__':
main()

You might also like