Pim Kot 052 Unit1
Pim Kot 052 Unit1
Ghaziabad
• https://www.youtube.com/watch?
v=KOa1aVijhao&t=873s&pp=ygUXcHJvZ
3JhbW1pbmcgdGhlIGFyZHVpbm8%3D
Prerequisite and Recap
PRE-REQUISITE:
Basic knowledge of programming of any language
CONTENTS
• Open Remote
• Flutter
• Arduino
• Kinoma
• Thinger.io
Creative Coding languages
Here are some of the top choices that are being used to build the foundations
of the next generation of things connected to the Internet.
1.Java
> known for being “write once, run anywhere.”
> The original project was aimed at set-top boxes, one of the first domains for non-desktop computing.
Developers can create and debug code on their desktop and then move it to any chip with a Java Virtual Machine.
That means the code can run not just on places where JVMs are common (servers and smartphones), but also on
the smallest machines.
Java ME, or micro edition, has been available on small phone handsets and other embedded devices.
It saved space with a very limited collection of class libraries and other tools.
2. C programming
The syntax is cluttered with punctuation.
There are a million different little mistakes you can make, but the language is still the first choice for many
programmers who write for the lowest layer of software, the one closest to the hardware.
The language hides nothing from you, and that means you can fiddle with every part of the code to squeeze out
the best performance from an underpowered device.
Every bit can be flipped. Every value on the stack is available. Just don’t make a mistake, because there are few
safety nets.
When a smartphone comes from Apple, much of the programming is still done in Objective C, but this will
probably be gradually replaced by Swift.
3. Python
Python is the language of choice for one of the most popular
microcontrollers on the market, the Raspberry Pi,” said Covey
It started as a scripting language to glue together real code, but it’s increasingly used as the main language for many
developers.
The syntax is clean and simple, attracting a greater range of programmers.
Extensive support libraries(NumPy for numerical calculations, Pandas for data analytics, etc.)
In Python, we don't need to declare the type of variable because the types and values can both be changed during
runtime.
Python can be used on various platforms such as iOS, Android, Windows phones, and desktops.
4. JavaScript
Normally JavaScript used as a language for popping up alert boxes on web pages.
Newfound popularity on the server makes it a surprisingly popular choice for IoT applications.
Focused on the servers and gateways or hubs that gather the information and then store it.
JavaScript is compatible with many hardware platforms such as Raspberry Pi and Arduino, making it a great choice for
IoT development.
There are various libraries and frameworks available for building IoT applications with JavaScript. Some popular ones
are : NODE-RED, Cyclon.js, Johnny-five, Noduino, Zetta etc.
5. Swift
Swift is still mainly used to build applications for Apple’s iOS and macOS devices.
If you want your things to interact with an iPhone or an iPad, you’re probably going to want to build the app in Swift (or
perhaps its predecessor, Objective C).
6. PHP
This language may be the first choice of bloggers and website prototypers, but it is also surprisingly popular in the IoT.
While the code’s role on the server to juggle microservices is an obvious application, it is also finding some traction at
the lowest level.
A number of Raspberry Pi developers are talking about starting up a full LAMP stack with Apache, MySQL, and PHP
running on top of Linux. They are effectively inverting the paradigm and turning the lowliest thing on the Internet into a
full web server.
Python in IOT:
• Automotive industry has allowed IoT to
revolutionize the automotive industry. The IoT
makes driving safe and efficient.
• Range of benefits in agriculture from
improving productivity to crop failure risks.
• IoT to diagnose a problem and avoid failure of
the system is helping in preventing the
breakdown scenario.
Python in IOT:
• Python is a very popular high-level programming language that
focuses on code readability. It is a dynamic and interpreted
programming language.
• Python can be used for software development, mathematics, web
development, and system scripting.
• In Python web development, developers use python on the server-
side to develop web applications. Python can handle big and complex
data easily. It can work on different platforms Windows, Mac, Linux,
and Raspberry Pi.
• Python can be treated as procedural, functional and object-oriented,
etc. With the scripting language, you can develop desktop
applications and web applications. It also translated into binary
language like java.
Python in IOT:
Languages used in IOT
•C
• C++
• Java
• Javascript
• PHP
• Python and many more
Python in IOT:
Easy to code: With the clear syntax developers get an idea on code identification instead of {};
Simple Syntax: Python has a simple syntax similar to the English Language
Interpreted Language: Python runs on interpreter system. The code can be executed as soon as it is
written. Prototyping can be very quick.
Embeddable: Python allows integration with other languages. It is possible to put our code in other
programming languages like C++ etc.
Extensible: Python is extensible language. It allows developers to write programs with fewer lines than
some other programming languages.
Portable: Python code is portable there is no need to change the code for different machines. You can run
one code in many machines.
Free and open-source: Python is open-source language. Its source code is freely available to the public you
can download it, change it and distribute it.
Community supports: Python has already got its huge response in the market with the above-mentioned
features thus provides many users grouped into community to support the advancements further.
Easy to debug: Python scripting language is one of the better language to debug than C++ and C. In this
source code is executed line by line.
Library support: Python supports large standard libraries. Installation of the libraries is easy, and it saves
time.
Python on Pi-Board
The next great solution for Python in IoT devices is the Pi-Board with an ARM
microcontroller.
Pi-Board is a compact & powerful electronics development board that runs
Micro Python.
It connects to your PC via USB, giving you a USB flash drive to save your
Python scripts and a serial Python prompt (a REPL) for instant programming.
This works with Windows, Mac, and Linux.
The built-in Pib module contains functions and classes to control the
peripherals available on the board, such as UART, I2C, SPI, ADC, and DAC.
SKETCHES in Arduino
• A sketch is the name that Arduino uses
for a program.
• A sketch has 3 parts
1. Structure
2. functions
3. Variables and constants
Structure and Function
Arduino sketch has 2 functions in its structure
1.Setup()
Used to initialize the variables, pin modes, libraries etc.
Gets executed once
Formation is like
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
2.loop()
Used to execute the desired function multiple times
void loop ()
{
}
Values(variable and constants)-:
.
Control statements are elements (functions) in a source code that control the
flow of program execution, either to wait, jump, repeat, etc. Arduino control
statements include:
• If statement • Else statement
• Else if statement • For statement
• While statement • Do while statement
If Statement
If and Else
For Loop
While Statement
Do while statement
Sensor Characterization
• Static Characteristics- sensor output when constant input is
applied
Accuracy- output should be close to the standard known value.
Range- maximum and minimum value that the sensor can measure.
Exp: temperature sensor range could be -10°C to 50°C
Span- span = max – min value of sensor
Exp: for the above temp sensor, span= 50-(-10)= 60°C
Precision- Capability of the device to give similar result every time at
similar applied input.
Sensor Characterization
Linearity- Device must show constant change in output for a defined
change in input i.e. ratio of output to input must be constant
Sensitivity-
Dynamic Characteristics
Speed of response with respect to the input
Response to the system i.e.
first order- normally have linear elements
second order or higher order system- normally have energy storing
elements
INTERFACING THE REAL WORLD
IoT applications promise to bring immense value into our lives. IoT
applications are expected to equip billions of everyday objects with
connectivity and intelligence. It is already being deployed extensively, the
outline of the article is as follows:
•Prediction of natural disasters
•Industry applications
•Water Scarcity monitoring
•Medical applications
•Design of smart homes
•Agriculture application
•Intelligent transport system design
•Design of smart cities
•Smart metering and monitoring
References
Text books:
1.Programming Interactivity, Second Edition By Josha
Noble, 2012
2.Programming the Raspberry Pi: Getting Started with
Python 2E, 2016