Académique Documents
Professionnel Documents
Culture Documents
DEVELOPMENT ON
SINGLE BOARD COMPUTER
Divneet Singh Kapoor
Electronics and Communication Engineering Department
Embedded Systems & Robotics Research Group
Chandigarh University
IoT Device Characteristics
while True:
humidity, temperature = Adafruit_DHT.read_retry(11, 4)
ctime = time.time()
print time.asctime(time.localtime(ctime))
print ‘Temperature: ‘ + str(temperature) +‘ C, Humidity: ‘+ str(humidity) +‘ %’
time.sleep(1)
Let’s Upload the DATA on CLOUD
Pre-Requisites for Data Upload
■ Open https://ubidots.com/education/
■ Install requests library for Python
– https://github.com/requests/requests
■ LINUX Commands
– sudo apt-get install python-pip python-dev build-essential
– pip install requests
■ WINDOWS
– pip install requests
■ http://docs.python-guide.org/en/latest/starting/installation/
Python Code
import time
import random
import requests
while True:
humidity = random.randint(20,80)
temperature = random.randint(0,50)
ctime = time.time()
print (time.asctime(time.localtime(ctime)))
print ('Temperature: ' + str(temperature) +' C, Humidity: '+ str(humidity) + ' %')
link='http://things.ubidots.com/api/v1.6/devices/weather/?token=A1E-
chC3epSzGGzQ1uKLpTdMqfLsl5c9Fc'
try:
r = requests.post(link, json = {'humidity':humidity, 'temperature':temperature})
except:
pass
time.sleep(1)
Weather Prediction
■ Numerical weather prediction (NWP) uses
mathematical models of the atmosphere
and oceans to predict the weather based on
current weather conditions.
■ Mathematical models based on the same
physical principles can be used to generate
either short-term weather forecasts or
longer-term climate predictions.
■ Predict temperature based on 2 days data
– max temperature
– min temperature
– mean humidity
– mean atmospheric pressure
Linear Regression model
to predict future values
ŷ = β0 + β1 * x1 + β2 * x2 + ... + β(p-n) x(p-n) + Ε
– ŷ is the predicted outcome variable (dependent variable)
– xj are the predictor variables (independent variables) for j
= 1,2,..., p-1 parameters
– β0 is the intercept or the value of ŷ when each xj equals
zero
– βj is the change in ŷ based on a one unit change in one of
the corresponding xj
– Ε is a random error term associated with the difference
between the predicted ŷi value and the actual yi value
Using SciKit-Learn's
LinearRegression Module
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=12)
from sklearn.linear_model import LinearRegression
# fit the build the model by fitting the regressor to the training data
regressor.fit(X_train, y_train)