First
First
Submitted by:
CONTENTS
Pg. No.
1. Project Objective……………………………………………………….3
2. Libraries in python………………………………………………….….4
3. Description of libraries…………………………………………….…..4-5
4. Project Discussion……………………………………………………..6
5. Project Steps…………………………………………………….…….7
6. PROJECT PICTURE……………………………………………….....8-10
7. Result………………………………………………………………….11
8. Conclusion……………………………………………………….……11
1. Introduction of Arduino………………………………………………. 12
2. Bus Communication……………………………………………………14
3. Node MCU……………………………………………………………..18
4. Node MCU based IoT………………………………………………….20
5. Introduction to Raspberry Pi 2…………………………………………28
6. RPi based IoT………………………………………………………….30
2
A PROJECT REPORT
TATHAGATA CHATTERJEE
Project Carried Out At
Submitted By
PROJECT OBJECTIVE
The primary objective of this project is to employ data analysis techniques to uncover patterns
within a dataset containing information about product ratings, quantities, and corresponding
discounts. Through the utilization of machine learning models, particularly polynomial regression
and multiple linear regression, the project aims to make accurate predictions of discounts based
on user-provided ratings and quantities. The insights gained from this analysis will empower
businesses to optimize discounting strategies, improve inventory management, and enhance the
overall customer experience by tailoring promotions to specific rating and quantity scenarios.
4
LIBRARIES IN PYTHON
What is a Library?
· A library is a collection of pre-combined codes that can be used iteratively to reduce the time
required to code.
· They are particularly useful for accessing the pre-written frequently used codes instead of
writing them from scratch every single time.
· Similar to physical libraries, these are a collection of reusable resources, which means every
library has a root source.
· This is the foundation behind the numerous open-source libraries available in Python.
Python library is a collection of modules that contain functions and classes that can be used by
other programs to perform various tasks.
As we write large-size programs in Python, we want to maintain the code’s modularity. For the
easy maintenance of the code, we split the code into different parts and we can use that code later
ever we need it.
· In Python, modules play that part. Instead of using the same code in different programs and
making the code complex, we define mostly used functions in modules and we can just simply
import them in a program wherever there is a requirement.
· We don’t need to write that code but still, we can use its functionality by importing its module.
Multiple interrelated modules are stored in a library. And whenever we need to use a module, we
import it from its library. In Python, it’s a very simple job to do due to its easy syntax. We just
need to use import.
DESCRIPTION OF LIBRARIES
pandas (Data Analysis and Manipulation):
● Purpose: Pandas is a powerful library for data manipulation and analysis. It
provides data structures like DataFrame, which is particularly useful for handling
tabular data.
● Usage in the Code:
● Reading a CSV file into a Pandas DataFrame: df = pd.read_csv('data3.csv')
● Handling missing values: df['rating'].fillna(100, inplace=True)
5
PROJECT DISCUSSION
In this project, our primary objective is to leverage data analysis techniques to predict discounts
based on product ratings and quantities. We will analyze a dataset comprising information about
product ratings, quantities, and corresponding discounts to extract meaningful patterns and
enhance decision-making processes.
Objectives:
Data Exploration:
● We began by loading and exploring the dataset, identifying key variables such as
ratings, quantities, and discounts.
● Addressed missing values responsibly, ensuring data integrity.
Polynomial Regression Analysis:
● Utilized polynomial regression to model the relationship between ratings and
discounts as well as quantities and discounts.
● Plotted regression curves to visually represent the trends in the data.
Multiple Linear Regression:
● Applied multiple linear regression to understand the combined influence of both
quantity and rating on discounts.
● Trained the model using the dataset and evaluated its performance.
User Interaction:
● Implemented a user-friendly interface allowing users to input quantity and rating
values.
● Leveraged the trained model to predict discounts based on the user inputs.
7
PROJECT STEPS
PROJECT PICTURE
1.Importing Libraries:
2. Reading the CSV file and Performing Polynomial Regression for Rating vs. Discount:
9
3.Performing Multiple Linear Regression for Quantity and Rating vs. Discount:
RESULT
● This step-by-step execution ensures that each part of the analysis is performed
independently and allows for a clear understanding of the relationships within the dataset.
Users can interact with the system to obtain predictions tailored to their inputted quantity
and rating values, providing practical insights for decision-making in discount strategies.
● The polynomial regression curves provided insights into the non-linear relationships between
ratings, quantities, and discounts.
● Multiple linear regression demonstrated the significance of both quantity and rating in predicting
discounts, offering a holistic view of their impact.
CONCLUSION
The "Data Analysis and Prediction of Discounts based on Ratings and Quantities" project offers a
robust framework for businesses to enhance their discounting strategies through data-driven
insights. By understanding the intricate relationships within the dataset, users can make informed
decisions that positively impact sales, customer satisfaction, and overall business performance.
12
MODULE:1
Introduction of Arduino Uno
Fig no. 1
Basically, the processor of the Arduino board uses the Harvard architecture where the program code
and program data have separate memory.
The Atmega328 microcontroller has 32kb of flash memory, 2kb of SRAM 1kb of EPROM and
operates with a 16MHz clock speed.
The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output
pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a
USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed
to support the microcontroller; simply connect it to a computer with a USB cable or power it with
a AC-to-DC adapter or battery to get started.
13
Fig no. 2
✔ Operating voltage: 5 V
✔ SRAM: 2 kB
✔ EEPROM: 1 kB
MODULE:2
14
Bus Communication
}
void loop()
{
softSerial.print(1);
Serial.print(1);
delay(5000);
softSerial.print(0);
Serial.print(0);
delay(5000);
}
Code for Slave Arduino:
#include <SoftwareSerial.h>
SoftwareSerial softSerial(10, 11);
char number = ' ';
int LED = 2;
void setup()
{
softSerial.begin(9600);
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
void loop()
{
if (softSerial.available())
{
char number = softSerial.read();
if (number == '0')
{
digitalWrite(LED, LOW);
}
16
if (number == '1')
{
digitalWrite(LED, HIGH);
}
Serial.println(number);
}
}
----------------------------------------------------------------------------------------------------------------
}
______________________________________________________________________________
________________________________________________________________________
MODULE:3
Node MCU
Fig No. 3
❑ The development board equips the ESP-12E module containing ESP8266 chip having
Tensilica Xtensa® 32-bit LX106 RISC microprocessor which operates at 80 to 160 MHz
adjustable clock frequency and supports RTOS.
❑ There’s also 128 KB RAM and 4MB of Flash memory (for program and data storage) just
enough to cope with the large strings that make up web pages, JSON/XML data, and
everything we throw at IoT devices nowadays.
❑ The ESP8266 Integrates 802.11b/g/n HT40 Wi-Fi transceiver, so it can not only connect
to a Wi-Fi network and interact with the Internet, but it can also set up a network of its
own, allowing other devices to connect directly to it.
❑ Power to the ESP8266 NodeMCU is supplied via the on- board MicroB USB connector.
19
❑ You can also regulated 5V voltage source, the VIN pin can be used to directly supply
current the ESP8266 and its peripherals.
❑ As the operating voltage range of ESP8266 is 3V to 3.6V, the board comes with a
LDO(Low Dropout) voltage regulator to keep the voltage steady at 3.3V.
❑ It can reliably supply up to 600mA, which should be more than enough when ESP8266
pulls as much as 80mA during RF transmissions.
The ESP8266 NodeMCU has total 17 GPIO pins :
❑ SPI, I2C & I2S interface – SPI and I2C interface to hook up all sorts of sensors and
peripherals.
❑ I2S interface – I2S interface if you want to add sound to your project.
Fig no. 4
MODULE:4
4.1 IoT based Temperature and Humidity and Light Intensity Monitoring and
control devices using Thing Speak cloud server.
20
Fig no. 5
#include <ESP8266WiFi.h>;
#include <WiFiClient.h>;
#include <ThingSpeak.h>;
#include <DHT.h>;
WiFiClient client;
const char* ssid = "Redmi"; //Your Network SSID
const char* password = "12345678"; //Your Network Password
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.println(h);
Serial.println(t);
val = analogRead(ldr);
Serial.println(val);
ThingSpeak.setField(1, h);
ThingSpeak.setField(2, t);
ThingSpeak.setField(3, val);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
hum = ThingSpeak.readIntField(myChannelNumber, 1, myReadAPIKey);
temp = ThingSpeak.readIntField(myChannelNumber, 2, myReadAPIKey);
22
}
delay(15000);
}
4.2 IoT based Light Intensity Monitoring and control devices using UBIDOTS
cloud server (MQTT Protocol Based).
#include "UbidotsESPMQTT.h"
#include <ESP8266WiFi.h>
int ldrPin = A0;
/**************
* Define Constants
**************/
#define TOKEN "BBFF-x5e4HGEd4oiVIl6M34KiuJqD6qU3Cx" // Your Ubidots
TOKEN
#define WIFINAME "Redmi" //Your SSID
#define WIFIPASS "12345678" // Your Wifi Pass
Ubidots client(TOKEN);
int LED = D5;
char* variable1 = "led";
char* variable2 = "ldr";
/**************
* Auxiliar Functions
**************/
24
client.reconnect();
}
int ldrValue = analogRead(ldrPin);
Serial.println(ldrValue);
client.add(variable2, ldrValue);
client.ubidotsPublish("MQTT");
client.loop();
delay(6000);
}
4.3 IoT based Temperature and Humidity Monitoring and control devices
using FireBase cloud server.
FirebaseData firebaseData;
FirebaseData ledData;
//FirebaseJson json;
void setup()
{
Serial.begin(9600);
dht.begin();
pinMode(led,OUTPUT);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.reconnectWiFi(true);
}
void sensorUpdate(){
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t) ) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.println(h);
Serial.println(t);
if (Firebase.pushFloat(firebaseData, "/FirebaseIOT/temperature", t))
{
Serial.println("PASSED");
}
else
27
{
Serial.println("FAILED");
}
if (Firebase.pushFloat(firebaseData, "/FirebaseIOT/humidity", h))
{
Serial.println("PASSED");
}
else
{
Serial.println("FAILED");
}
}
void loop() {
sensorUpdate();
if (Firebase.getString(ledData, "/FirebaseIOT/led")){
Serial.println(ledData.stringData());
if (ledData.stringData() == "1") {
digitalWrite(led, HIGH);
}
else if (ledData.stringData() == "0"){
digitalWrite(led, LOW);
}
}
delay(100);
}
MODULE: 5
28
Introduction to Raspberry Pi
Fig no. 6
The Raspberry Pi is a small computer (which includes the processor, graphics card, and memory in
a single package.), about the size of a credit card which was developed in UK by the Raspberry Pi
Foundation. Name of Raspberry Pi is combination of Raspberry and Pi, where raspberry is fruit
name and pi stand for Python.
29
Fig no. 7
GPIO.output(21,GPIO.LOW)
time.sleep(1)
print("Off")
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
MODULE: 6
RPi Based IoT
6.1 IoT based Temperature and Humidity Monitoring using Thing Speak
cloud server.
import sys
import urllib.request
from time import sleep
import Adafruit_DHT as dht
try:
humi, temp = DHT11_data()
# If Reading is valid
if isinstance(humi, float) and isinstance(temp, float):
# Formatting to two decimal places
humi = '%.2f' % humi
temp = '%.2f' % temp
print(humi)
print(temp)
# DHT11 requires 2 seconds to give a reading, so make sure to add delay of above 2
seconds.
sleep(20)
except:
break
6.2 Human Motion Detection and post to UBIDOTS cloud server.
from gpiozero import MotionSensor
import json,requests
32
import time
PIR = MotionSensor(21)
url = "http://things.ubidots.com"
TOKEN = "BBFF-x5e4HGEd4oiVIl6M34KiuJqD6qU3Cx" # Put your TOKEN
here
DEVICE_LABEL = "pir"
url = "{}/api/v1.6/devices/{}".format(url, DEVICE_LABEL)
headers = {"X-Auth-Token": TOKEN, "Content-Type": "application/json"}
#VARIABLE_LABEL_1 = "dust-sensor" # Put your first variable label here
#VARIABLE_LABEL_2 = "alcohol" # Put your second variable label here
VARIABLE_LABEL_3 = "PIR"
PIR.wait_for_motion()
print("You moved")
value(1)
PIR.wait_for_no_motion()
print("Don't Moved")
value(0)
6.3 Data gets from UBIDOTS cloud server. (IoT based Automation)
import time
import requests
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(21,GPIO.OUT)
DEVICE ="LED"
VARIABLE1 ="BLINK"
TOKEN = "BBFF-x5e4HGEd4oiVIl6M34KiuJqD6qU3Cx"
try:
while True:
light1 =
requests.get("http://things.ubidots.com/api/v1.6/devices/"+DEVICE+"/"+VARIABL
E1+"/lv?token="+TOKEN)
print(light1.content) # Returns the content of the response, in bytes
print(light1.json()) # Returns a JSON object of the result
data = light1.json()
print(type(data))
if data==1.0:
34
GPIO.output(21,GPIO.HIGH)
#GPIO.output(26,GPIO.LOW)
print("On")
#time.sleep(3)
if data==0.0:
GPIO.output(21,GPIO.LOW)
#GPIO.output(26,GPIO.HIGH)
print("Off")
#time.sleep(3)
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
light1 = ''