ES&IoT Lab Record

Download as pdf or txt
Download as pdf or txt
You are on page 1of 58

1.

FUNCTIONALITY TESTING OF DEVICES

AIM: Flashing the OS on to the device into a stable function state by porting
desktop environment with necessary packages

APPARATUS:

1. Raspberry Pi
2. Beagle Bone Black
3. Micro-SD Cards
4. Raspbian image file
5. BeagleBone Black image file
6. HDMI cable and Display
7. Power Supply

RASPBERRY PI AND ITS HARDWARE:

Figure 1.1: Front-view of a Raspberry Pi Board

1
EMBEDDED SYSTEMS LAB
BEAGLEBONE BLACK AND ITS HARDWARE:

Figure 1.2: Beagle Bone Black

1. The Processor
2. The Power Connector
3. Ethernet port
4. Reset Button
5. USB Host Port
6. Onboard LEDs
7. Expansion Headers
8. Mini USB port
9. MicroSD card Slot
10. Micro HDMI Port
11. Serial Header
12. On Board Flash Memory
13. Boot Switch

2
EMBEDDED SYSTEMS LAB
PROCEDURE:

FLASHING OS INTO SD CARD:

1. First, download the corresponding image files from the below links.

http://www.raspberrypi.org/downloads------- for Raspberry Pi Image

http://beagleboard.org/latest-images --------- for BeagleBone Black Image

The downloaded images will be compressed in .zip or .xz format, so extract them.

2. If the computer has a slot for SD cards, insert the card. If not, insert the card into an
SD card reader and then connect the reader to the computer. The SD card should be of
minimum 8GB size.

3. Format the SD card using either the format option or the SD card Formatter tool.

4. balenaEtcher is a graphical SD card writing tool that works on Mac OS, Linux and
Windows, and is the easiest option for most users. balenaEtcher also supports writing
images directly from the zip file, without any unzipping required. To write your
image with balenaEtcher:Download the latest version of balenaEtcher form
https://www.balena.io/etcher/ and install it.

5. Open balenaEtcher and select from your hard drive the .img or .zip file you wish to
write to the SD card.

6. Select the SD card you wish to write your image to.

7. Review your selections and click 'Flash!' to begin writing data to the SD card.
Writing to a drive can overwrite any partition of the machine. If the wrong device is
specified in the instructions below then the primary partition could be deleted.
Be careful.

When the procedure finishes unplug your SD card from your computer and
insert it into the hardware (Raspberry Pi or BeagleBone module).

3
EMBEDDED SYSTEMS LAB
BOOTING THE RASPBERRY PI FOR THE FIRST TIME:

1. After booting, an orange screen with options in a grey box in the centre
appears. Click on Next.

Figure 1.5: Raspberry Pi Welcome screen

2. A Set country window is displayed where country, language and timezone can
be adjusted. Then click on Next.

Figure 1.6: Set Country and Language Window

3. A Change Password window is displayed where a password can be created.


Then click on Next.

4
EMBEDDED SYSTEMS LAB
Figure 1.7: Change password Window
4. A Set up screen window is displayed. Then click on Next tosave the settings.

Figure 1.8: Set Up Screen Window

5. An Update software window is displayed. Click on Next to check and update software.

Figure 1.9: Update Software Window

6. A Set up complete window is displayed. Click on Restart.

5
EMBEDDED SYSTEMS LAB
Figure 1.10: Setup Complete Window

7. Login name: pi and password: raspberry (don't panic passwords are not shown
in Linux).

BEAGLEBONE BLACK:

1. With the power off on the BeagleBone Black, insert the eMMC flasher
MicroSD card into theMicroSD slot.
2. While holding the boot button, connect the BeagleBone to power and keep
holding the boot button for about fifteen seconds.
3. The USR LEDs will blink while the flashing process is taking place.

RESULT: Operating systems have been flashed onto the devices and their
functionalities have been verified.

6
EMBEDDED SYSTEMS LAB
2. EXPORTING DISPLAY ON TO OTHER SYSTEMS

AIM: Exporting Raspberry Pi display to a Linux system using SSH client and X11
display server.

APPARATUS:

1. Raspberry Pi

2. SD card.

SSH: SSH was designed and created to provide the best security when accessing
another computer remotely. It also provides better authentication facilities,as well as
features like secure file transfer, x session forwarding,port forwarding and more so
that you can increase the security of other protocols.

X11 display server: X11 is a network protocol designed for Unix and similar
operating systems to enable remote graphical access to applications. Display server or
window server is a program whose primary task is to coordinate the input and output
of its clients to and from the rest of O.S,the hardware,and each other. Display server
communicates with its clients over the display server protocol,
acommunication,which can be network-transparent.

PROCEDURE:

FLASHING RASPBIAN IMAGE ON TO SD CARD:

1. Download Raspbian Buster from raspberry.org website.


2. balenaEtcher is a graphical SD card writing tool that works on Mac OS, Linux
and Windows, and is the easiest option for most users. balenaEtcher also
supports writing images directly from the zip file, without any unzipping
required. To write your image with balenaEtcher Download the latest version
of balenaEtcher form https://www.balena.io/etcher/ and install it.
4. Connect an SD card reader with the SD card (8 GB) inside.
5. Open balenaEtcher and select from your hard drive the Raspberry
Pi .img or .zip file you wish to write to the SD card.
6. Select the SD card you wish to write your image to.
7. Review your selections and click 'Flash!' to begin writing data to the SD card.

7
EMBEDDED SYSTEMS LAB
8. When procedures finishes unplug your SD card from your computer and insert
it into your Raspberry Pi.

BOOTING YOUR RASPBERRY PI FOR THE FIRST TIME:

1. After booting, an orange screen with options in a grey box in the centre
appears. Click on Next.
2. A Set country window is displayed where country, language and timezone can
be adjusted. Then click on Next.
3. A Change Password window is displayed where a password can be created.
Then click on Next.
4. A Set up screen window is displayed. Then click on Next to save the settings.
5. An Update software window is displayed. Click on Next to check and update software.
6. A Set up complete window is displayed. Click on Restart.
7. Login name: pi and password: raspberry (don't panic passwords are not shown
in Linux)
8. Enter the following command in the Raspberry Pi terminal
sudo raspi-config

Figure 2.1: Raspberry Pi Configuration Window

9. Use the up and down arrow keys to move the highlighted selection between
the options available. Pressing the right arrow key will jump out of the options
menu and take you to the <Select> and <Finish> buttons.
Select interfacing options and enable SSH.

8
EMBEDDED SYSTEMS LAB
ACCESSING RASPBERRY PI REMOTELY BY USING SSH CLIENT FROM
LINUX SYSTEM:

Once SSH service is activated on Raspbian, you can access your Raspberry Pi
remotely by using SSH client.

1. To install SSH client on a separate Linux system, type the command below
sudo apt-get install openssh-client
2. You can get Raspberry IP address by typing the following command in the
terminal of the Pi
ifconfig
3. After SSH client is installed, connect to your Raspberry Pi over SSH as
follows.
ssh pi@[rasberrypi_ip_address]

Figure 2.2: SSH successfully enabled

X11 FORWARDING FOR EXPORTING RASPBERRY PI DISPLAY ON


LINUX SYSTEM:

With X11+SSH forwarding, you can actually run the entire desktop of
Raspberry Pi remotely. Your Linux desktop is running by default on the first virtual
terminal, which isvirtual terminal #7. Follow the instructions below to get your
Raspberry Pi desktop to show up in your second virtual terminal via X11 forwarding.

9
EMBEDDED SYSTEMS LAB
 Open your terminal in the Linux system, and change to root user by typing

$ sudo su

 Then Type the command:

# xinit -- :1 &

Figure 2.3: Accessing Raspberry Pi from Ubuntu


 This will activate xinit in virtual terminal 8. Note that you will be
automatically switched to virtual terminal 8. You can switch back to the
original virtual terminal 7 by pressing CTRL+ALT+F7.
 After switching to virtual terminal 8, execute command:

# DISPLAY=:1 ssh –X <username of pi>@<ipaddr of pi>lxsession

Figure 2.4: Command for Raspberry Pi remote access

 To launch the RPi desktop remotely, type Pi user password when asked.

10
EMBEDDED SYSTEMS LAB
 You will bring to your new virtual terminal 8 the remote RPi desktop, as well
as a small terminal launched from your active virtual terminal 7
 Remember, do NOT close that terminal. Otherwise, your RPi desktop will
close immediately.
 You can move between first and second virtual terminals by pressing
CTRL+ALT+F7 or CTRL+ALT+F

Figure 2.5: Remote access of Raspberry Pi

 To close your remote RPi desktop over X11+SSH, you can either close a small
terminal seen in your active virtual terminal 8, or kill session running in your
virtual terminal 7.

RESULT: Exporting the Raspberry Pi display to another system is performed.

11
EMBEDDED SYSTEMS LAB
3. GPIO PROGRAMMING

AIM: To blink an LED connected to the Raspberry pi with the help of the GPIO pins
present on the Raspberry pi.

APPARATUS:

1. Raspberry Pi
2. SD Card With Raspbian OS flashed
3. LED
4. Connecting Wire
5. Keyboard and Mouse
6. Resistor – 1KΩ
7. Breadboard

RASPBERRY PI GPIO HEADER:

Raspberry Pi Models A and B have 26 pins (17 GPIO) whereas the new model
B+ comes with 40 pins (26 GPIO). The model B+ is pin compatible with models A
and B.The easiest way to control these pins is to use the RPi.GPIO Python library.

Raspberry Pi Pin Configuration:

The RPi model B+ consists of 40 pins, out of which 26 can be used as GPIO.

Figure 3.1: GPIO port pin configuration

12
EMBEDDED SYSTEMS LAB
THE RPi.GPIO PYTHON LIBRARY:

The RPi.GPIOlibrary provides a class to control the GPIO on a Raspberry Pi.


Starting version 0.5.6, the library has support for RPi model B+ as well. While the
library is the best way to access and control the GPIO pins, it still lacks support for
SPI, I2C, hardware PWM and serial functionality, which are planned to be added
(This is with respect to version 0.5.6. In future, this might change).

Installationof the library from repositories:

The RPi.GPIO library comes pre-installed with the latest version of Raspbian.
In case it doesn’t, the library can be installed from the repositories by running the
following commands in the terminal.

sudo apt-get update

sudo apt-get install python-rpi.gpio python3-rpi.gpio

Using the RPi.GPIO Library:

Importing Module

The module is imported in the beginning of the program.

importRPi.GPIO as GPIO

This allows us to refer the module by simply mentioning GPIO instead of its full
name RPi.GPIO.

Specify Mode of Operation

The next step is to specify the mode in which the module is going to be used. RPi
(BOARD) and the CPU (BCM) have different pin numbers.

GPIO.setmode(GPIO.BOARD) # for RPi numbering

or

GPIO.setmode(GPIO.BCM) # for CPU/BCM numbering

13
EMBEDDED SYSTEMS LAB
Set up a Channel

Next the desired channel needs to be setup as either input or output.

GPIO.setup(channel, GPIO.IN) # input channel

GPIO.setup(channel, GPIO.OUT) # output channel

For instance, if pin 7on the board is connected to the LED, it means that the pin must
be configure as an output channel. The pin 7 on the board is mapped to GPIO4 of the
CPU.

GPIO.setup(7, GPIO.OUT) # if BOARD numbering system is used

or

GPIO.setup(4, GPIO.OUT) # if BCM numbering system is used

Read and Write from/to a Channel

In order to read the value of any GPIO pin,

GPIO.input(channel)

In order to write a value to any GPIO pin,

GPIO.output(channel, HIGH)

or

GPIO.output(channel, LOW)

Cleanup

After all the GPIO operations, we need to clean up and free any resources that
might have been used. This is not required but is considered a good programming
practice.

GPIO.cleanup()

14
EMBEDDED SYSTEMS LAB
Figure 3.2: Circuit Diagram

PROCEDURE:

 Connect the circuit as shown in the circuit diagram to the Pi's GPIO pins
 Here, we have used the pin 6 of GPIO as ground and pin 12 (GPIO 1) as
output pin
 First, for using the GPIO pins of the Raspberry Pi, install the library
RPI.GPIO in the terminal using the necessary commands
 Now, open a text editor to write the program. Since Python programming
language is used, save the file as <filename>.py
 To run the program, enter the following command in the terminal

python<filename>.py

CODE:

importRPi.GPIO as GPIO

from time import sleep

GPIO.setwarnings(FALSE)

GPIO.setmode(GPIO.BOARD)

GPIO.setup(12, GPIO.OUT, initial = GPIO.LOW)

15
EMBEDDED SYSTEMS LAB
while True:

GPIO.output(12, GPIO.HIGH)

sleep(2)

GPIO.output(12, GPIO.LOW)

sleep(2)

The LED blinks indefinitely with a 2 seconds delay.

RESULT: The Raspberry Pi GPIO is programmed by blinking an LED.

16
EMBEDDED SYSTEMS LAB
4.INTERFACING CHRONOS eZ430

AIM: To interface the programmable Texas Instruments watch Chronos eZ430 with
the PC and other devices and exploit its features for multiple purposes like PPT
control, mouse operations and others

OVERVIEW:

The eZ430-Chronos software development tool is a highly integrated, wearable,


wireless development system that is based on the CC430F6137. It may be used as a
reference platform for watch systems, a personal display for personal area networks,
or as a wireless sensor node for remote data collection. Based on the CC430F6137
sub-1-GHz RF SoC, the eZ430-Chronos is a complete development system featuring
a 96-segment LCD display, an integrated pressure sensor, and a three-axis
accelerometer for motion sensitive control.
The integrated wireless interface allows the eZ430-Chronos to act as a central
hub for nearby wireless sensors such as pedometers and heart-rate monitors. The
eZ430-Chronos offers temperature and battery voltage measurement and is complete
with a USB-based MSP430F5509 +CC1101 (part of the new eZ430-Chronos kit with
white PCBs) or CC1111 (part of the initial eZ430-Chronos kit with black PCBs)
wireless interface to a PC. The eZ430-Chronos wrist module may be disassembled to
be programmed with custom applications and includes aneZ430 USB programming
interface.
NOTE: The information provided in this document applies equally to all of the kits
that are available, unless otherwise noted. There are several different eZ430-Chronos
kit versions available. In addition to the different frequency versions, there are two
generations of kits:

1. First generation eZ430-Chronos with black PCBs (legacy), sometimes referred


to as Chronos BLACK.
 Chronos module based on VIT accelerometer and pressure sensor
 Chronos module based on discrete RF matching
 Access Point based on CC1111 (8051 based SoC with USB and
<1GHz transceiver)
2. Second generation eZ430-Chronos with white PCBs, sometimes referred to as
Chronos WHITE.

17
EMBEDDED SYSTEMS LAB
 Chronos module based on Bosch Sensor Tec accelerometer and
pressure sensor
 Model number engraved in metal back of wrist housing
 Chronos module based on Johansson Technology Filter baluns
 Access Point based on MSP430F5509 microcontroller with USB and
CC1101 <1GHz transceiver

Figure 4.1: Chronos eZ430-Black PCB Figure 4.2: Chronos eZ430-White PCB

CHRONOS eZ430 FEATURES

 Sports watch development kit based on the CC430F6137, an MSP430™


microcontroller with integrated sub-1-GHz wireless transceiver
 Wrist module can be programmed for custom wireless applications
 Highly integrated wrist module includes on-board a three-axis accelerometer,
a pressure sensor, a temperature sensor and a battery voltage sensor
 96-segment LCD display driven directly by the CC430 microcontroller
 Can be paired wirelessly with heart-rate monitors, pedometers, or other
devices based on RF

Transceivers such as the CC430 or CC11xx devices

 Includes an eZ430-RF USB emulator that connects the eZ430-Chronos to a


PC for real-time in-system programming and debugging.

KIT CONTENTS

 One eZ430-Chronos module with wrist housing (battery included)


 One eZ430-RF USB debugging interface
 One CC1111 USB RF access point (Chronos BLACK only)
 One MSP430F5509 + CC1101 USB RF access point (Chronos WHITE only)
 One 4-pin solder-on debug connector for the USB RF access point (Chronos
WHITE only)

18
EMBEDDED SYSTEMS LAB
 One mini Phillips screwdriver
 Two spare screws

Figure 4.3: Contents of the Chronos eZ430 kit

PROCEDURE:

The Chronos eZ430 PC software can be installed in Windows as well as in Linux.

INSTALLATION IN WINDOWS

The latest eZ430-Chronos Software for Windows (SLAC341) can be


downloaded from theeZ430-Chronos web page at www.ti.com/chronos.

1. Unzip the archive and run Chronos-Setup.exe

2. Respond to the prompts to install the software. During the installation a separate
window opens for the Windows driver installation. Accept the driver installation

3. When installation finishes, connect the eZ430-Chronos RF USB access point to the
PC and follow the Windows driver installation

4. If prompted for the driver for the TI CC1111 Low-Power RF to USB CDC Serial
Port (legacy software), or eZ430-ChronosAP (current software) allow Windows to
'Install the software automatically'. This can be done only if the eZ430-Chronos PC
Software package has already been installed

5. Open the eZ430-Chronos Control Center program. A shortcut is available on the


Desktop and the Start Menu under Programs > Texas Instruments > eZ430-Chronos >
eZ430-Chronos Control Center

Using the eZ430-Chronos Wrist Module With a PC:

1. The Control Center provides a variety of demos.

19
EMBEDDED SYSTEMS LAB
Figure 4.4: Chronos eZ430 Control Center

Transmission of Acceleration Data and Button Pushes:

1. Select the Simplicity Acc/PPT tab.


2. Click Start Access Point to start PC. When the PC is ready, the control center
status line displays “Access point started. Now start watch in ACC, PPT or
sync mode”
3. Select the ACC mode in the bottom LCD line of the eZ430-Chronos module
and activate the data transmission by pressing the DOWN button. The
Chronos module connects to the PC (this may take a few seconds) and starts
transmitting 3-Axis acceleration values.

Figure 4.5: Chronos eZ430 module in ACC mode paired with the PC

4. After connection, the Control Center status bar reports "Receiving data from
acceleration sensor" and the values according to the axis. The graphs display
the acceleration data of the Chronos module for each axis.

20
EMBEDDED SYSTEMS LAB
Figure 4.6: Chronos Control Center with Acceleration Data

Mouse Control:

1. Click Mouse On (M) to control the PC mouse pointer with the eZ430-Chronos
module. Hold the Chronos module with its display facing up. The mouse
pointer moves vertically (x-axis in Control Center) when tilting the Chronos
module forward/backward and moves vertically (y-axis in Control Center)
when tilting the Chronos module left/right. Mouse clicks are possible as well:
 Left single click: * button
 Left double click: # button
 Right click: UP button
2. Mouse control can be calibrated to set a point of zero acceleration (that is, no
pointer movement) by selecting Calibration (C). It may be disabled by clicking
Mouse Off (M) or by typing M on the PC keyboard.

Note: Holding buttons (for example, for drag and drop) is not supported.

3. Turn the demo off by pushing the DOWN button on the eZ430-Chronos
module and clicking Stop Access Point in the PC application

21
EMBEDDED SYSTEMS LAB
Figure 4.7: Chronos as Mouse Controller

PowerPoint Control:

The Control Center allows the user to map button pushes on the wrist module
into keystrokes on the PC. The default setting is PowerPoint control, which allows
switching slides forward/backward and to start the slide show.

1. Select the Simplicity Acc/PPT tab.


2. Click Start Access Point to start linking. The control center status line displays
"Access point started".
3. Select PPt mode in the bottom LCD line of the eZ430-Chronos module and
activate the RF link by pressing the DOWN button. The wrist module
connects to the PC, this may take a moment.
4. Once connected, the Control Center status bar show when a button is pushed.
5. Open a PowerPoint presentation. Press # to go to presentation mode (slide
show - F5), UP to switch to next slide (right arrow key), and * (left arrow key)
to switch to previous slide.

NOTE: To avoid bouncing of the Chronos buttons, a delay of 0.6 seconds


between transmissions is implemented; that is, if a button is pressed twice in less
than 0.6 seconds, it is translated intoone key stroke only.

22
EMBEDDED SYSTEMS LAB
Figure 4.8: Chronos in PPt mode

Figure 4.9: Key configuration in PPt mode

Reading and Setting of data in Chronos watch:

1. The date, time, temperature, altitude and other data can be read from the watch
and can also be set from the control center.
2. Open the SimpliciTI Sync tab and click on Start Access Point to pair the PC to
the watch. The Control Center status line displays "Access point started. Now
start watch in ACC, PPT or synch mode" when the PC is ready.
3. Select "SYnC" on the eZ430-Chronos module by pushing the # button.
4. Initiate pairing on the Chronos module by pushing the DOWN button to
activate the selected mode. After a short time, the link is established.

23
EMBEDDED SYSTEMS LAB
Fig 4.10: Chronos eZ430 in SYnC mode paired with the PC

5. In the SimpliciTI Sync tab, select metric or imperial units.


6. Read the data from the watch by clicking Read Watch. The data read is
displayed in the Sync tab.

Figure 4.11: Data from the Chronos module is read

7. Enter the data for temperature or altitude or any other parameter and click Set
Watch to transfer the data to the Chronos module

Fig 4.12: Data is set in the Chronos module

24
EMBEDDED SYSTEMS LAB
8. The Chronos module shows DONE
9. Push the DOWN button on the Chronos module to end connection.

Heart Rate Simulator:

This mode simulates an active heart rate chest belt.

1. Select heart rate mode (heart symbol is shown) by pushing the "*" button
.Start receiver on watch by pushing the "UP" button .
2. After a short moment, the current heart rate is displayed, Speed can be
selected by pushing the "*" button, Calories can be selected by pushing the "#"
button, Distance can be selected by pushing the "DOWN" button in Calorie
Mode.
3. The reception may be stopped by pushing "UP" while the heart rate is shown.

Fig 4.13 : Chronos Control Center Heart Rate Simulator

RESULT: The Chronos eZ430 module is interfaced with a PC and used for multiple
purposes like mouse control, PPT control, checking accelerometer data and setting
and reading data from the module.

25
EMBEDDED SYSTEMS LAB
5. ON/OFF CONTROL BASED ON LIGHT INTENSITY

AIM: To control the intensity of an LED (Light Emitting Diode) using an LDR (Light
Dependent Resistor) by taking analog input, making sense of that input and output
what appears to be analog signal using an Arduino board.

APPARATUS:

1. Arduino UNO board


2. Bread board
3. Resistors
4. Light Emitting Diode
5. Light Dependency Resistor
6. Connecting wires.

ARDUINO UNO BOARD:

Arduino is an open-source computer hardware and software company, project


and user community that designs and manufactures microcontroller-based kits for
building digital devices and interactive objects that can sense and control the physical
world. Arduino UNO has 14 digital I/O pins (of which 6 provide PWM output) and 6
analog input pins. The Arduino Uno can be powered via the USB connection or with
an external power supply. The power source is selected automatically. External (non-
USB) power can come either from an AC-to-DC adapter or battery.

The board can operate on an external supply of 6 to 20 volts. If supplied with


less than 7V, however, the 5V pin may supply less than five volts and the board may
be unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts. Each of the 14 digital pins on the
Uno can be used as an input or output, using pinMode(), digitalWrite() and
digitalRead() functions.

26
EMBEDDED SYSTEMS LAB
Figure 5.1: Arduino UNO board

LIGHT DEPENDENCY RESISTOR:

A photo resistor or light-dependent resistor (LDR) or photocell is a light-


controlled variable resistor. The resistance of a photoresistor decreases with
increasing incident light intensity; in other words, it exhibits photoconductivity. A
photoresistor can be applied in light-sensitive detector circuits, and light- and dark-
activated switching circuits.

A photoresistor is made of a high resistance semiconductor. In the dark, a


photoresistor can have a resistance as high as several mega ohms (MΩ), while in the
light, a photoresistor can have a resistance as low as a few hundred ohms. If incident
light on a photoresistor exceeds a certain frequency, photons absorbed by the
semiconductor give bound electrons enough energy to jump into the conduction band.
The resulting free electrons (and their holepartners) conduct electricity, thereby
lowering resistance. The resistance range and sensitivity of a photoresistor can
substantially differ among dissimilar devices. Moreover, unique photoresistors may
react substantially differently to photons within certain wavelength bands.A
photoelectric device can be either intrinsic or extrinsic.

27
EMBEDDED SYSTEMS LAB
Figure 5.2: Light Dependency Resistor (LDR)

LIGHT EMITTING DIODE (LED):

A light-emitting diode (LED) is a two-lead semiconductor light source. It is a


p–n junction diode, which emits light when activated. When a suitable voltage is
applied to the leads, electrons are able to recombine with electron holes within the
device, releasing energy in the form of photons. This effect is called
electroluminescence, and the colour of the light (corresponding to the energy of the
photon) is determined by the energy band gap of the semiconductor.

Figure 5.3: Parts of LED

CONNECTIONS:

The connections are as follows:

 Connect one end of a resistor (1kΩ or little more) to the 5V pin of the Arduino
board. Connect the other end of the resistor to one end of the LDR. The other
end of the LDR should be connected to the ground (GND)

28
EMBEDDED SYSTEMS LAB
 Take a wire from the junction of the resistor & the LDR connected earlier and
connect it to the analog input Pin A0 on the Arduino board
 Next take a wire from any of the PWM pins on your board and connect it to
the anode of the LED. Connect the cathode of the LED to one end of a resistor
with the other end connected to the GND.

Figure 5.4: Circuit Diagram

PROGRAM CODE:

#include<SoftwareSerial.h>

intsensorPin = A0; //select the input pin for the LDR

intsensorValue = 0; //variable to store the value coming from sensor

int led=3;

void setup() {

// declare the ledPin as an OUTPUT

pinMode(led,OUTPUT);

Serial.begin(9600);

void loop() {

Serial.println(“ON/OFF control based on Light Intensity”);

29
EMBEDDED SYSTEMS LAB
sensorValue = analogRead(sensorPin);

Serial.println(sensorValue);

if(sensorValue<30)

Serial.println(“LED Light ON”);

digitalWrite(led, HIGH);

delay(1000);

else

Serial.println(“LED Light OFF”);

digitalWrite(led, LOW);

delay(sensorValue);

Some things to note are as follows

 When we upload the program to the board we find that the value in the
variable “sensorValue” varies over a range of 30 – 50. This is a very small
range in comparison to 0 – 1023. So we constrain it between 30 and 50. If we
do not do this then value written to the led pin will vary over a much smaller
range and this will not be noticeable in the varying brightness of the LED.
 We have also put in the Serial.println() function which helps in debugging.

30
EMBEDDED SYSTEMS LAB
OUTPUTS:

Figure 5.5: The circuit in sufficient light

When the light falling on the LDR sensor is greater than the given value the
LED stops glowing.

Figure 5.6: The circuit in dark

When the light falling on the LDR sensor is less than the given value the LED
starts glowing.

RESULT: The intensity of LED is controlled using LDR and Arduino.

31
EMBEDDED SYSTEMS LAB
6. BATTERY VOLTAGE INDICATOR

AIM: To monitor the voltage level of the battery and indicate the same using
multiple LEDs.

APPARATUS:

1. Resistors - 5 no’s
2. One battery
3. Connecting wires
4. Arduino UNO Board
5. Bread Board
6. LEDs

CONNECTIONS:

Figure 6.1: Voltage monitoring using voltage divider circuit.

PROCEDURE:

 Connect the circuit as shown in the circuit diagram.


 Then open the Arduino IDE software and create a file.
 The following is the code that is to be written in this file.
 Click on serial monitor to view output on the screen.

32
EMBEDDED SYSTEMS LAB
Figure 6.2: Battery level indicator using LEDs.

CODE:

constintanalogInPin = A0;
intanalogOutPin;
intsensorValue = 0;
intoutputValue = 0;

void setup()
{
Serial.begin(9600);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}

void loop()
{
sensorValue = analogRead(analogInPin);
outputValue = map(sensorValue, 0, 1023, 0, 255);
analogWrite(analogOutPin, outputValue);

33
EMBEDDED SYSTEMS LAB
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);

intval=(sensorValue*5)/1023;
Serial.print("\t val = ");
Serial.println(val);
if(val>=4)
{
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
}
if(val>=2 &&val<4)
{
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
}
if(val>0 &&val<2)
{
digitalWrite(11,HIGH);
}
else
{
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
delay(1000);
}

34
EMBEDDED SYSTEMS LAB
CALCULATIONS:
V(battery)=9V
RT = R1 + R2

Case 1:
V(battery)*(R2/RT)>=4V
R2/R1>=4/5
Consider R2=R1=1K ohm

Case 2:
2<=V(battery)*(R2/RT)<4V
2/7<=R2/R1<4/5
Consider R2=470 ohm,R1=1K ohm

Case 3:
0<V(battery)*(R2/RT)<2V
0<R2/R1<2/7
Consider R2=100 ohm,R1=1K ohm
OUTPUTS:

Figure 6.3: Circuit Connection

35
EMBEDDED SYSTEMS LAB
Figure 6.4: 3 LEDs Glowing

Figure 6.5: 2 LEDs Glowing

 When the sensor value or battery voltage is greater than or equal to 4V all the
three LEDs (9,10,11) start glowing.
 When the battery voltageis in between 2V and4V two LEDs (10, 11) start
glowing.
 When the battery voltage is in between 0V and 2V one LED (11) starts
glowing.
 When the battery voltage is 0v no LED glows.

RESULT: The voltage level of a battery is monitored using multiple LEDs and
Arduino UNO.

36
EMBEDDED SYSTEMS LAB
7. DICE GAME SIMULATION

AIM:To generate a random value similar to dice value and display the same value
using LEDs

APPARATUS:

1. Arduino UNO Board


2. LEDs
3. Pushbutton
4. Bread Board
5. Resistors - 220 ohm,10K ohm
6. Wires for bread board connections

ARDUINO UNO BOARD:

Arduino is an open-source computer hardware and software company, project


and user community that designs and manufactures microcontroller-based kits for
building digital devices and interactive objects that can sense and control the physical
world. Arduino UNO has 14 digital I/O pins (of which 6 provide PWM output) and 6
analog input pins. The Arduino Uno can be powered via the USB connection or with
an external power supply. The power source is selected automatically. External (non-
USB) power can come either from an AC-to-DC adapter or battery.

The board can operate on an external supply of 6 to 20 volts. If supplied with


less than 7V, however, the 5V pin may supply less than five volts and the board may
be unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts. Each of the 14 digital pins on the
Uno can be used as an input or output, using pinMode(), digitalWrite() and
digitalRead() functions.

37
EMBEDDED SYSTEMS LAB
Figure 7.1: Arduino UNO board

SCHEMATIC DIAGRAM:

Figure 7.2: Schematic diagram

To create all the faces of the dice, you must follow these rules:

For the number 1 of the dice: light up the led 4


For the number 2 of the dice: light up the group 1
For the number 3 of the dice: light up the groups 3 and 4
For the number 4 of the dice: light up the groups 1 and 3

38
EMBEDDED SYSTEMS LAB
For the number 5 of the dice: light up the groups 1, 3 and 4
For the number 6 of the dice: light up the groups 1, 2 and 3

First, attach the Arduino ground with the ground line of the breadboard. Then,
connect the LEDs to Arduino.Finally, connect the 5v of Arduino with the button, and
connect the button with the pin 6 of Arduino.

PROCEDURE:

 +5V is connected to the 10KΩ.


 Connect D2,D3,D4 and D5 to the 220ohms and other end of resistor is
connected to LED.
 LED negative pin is connected to ground.
 All the grounds are connected at one end of ground.

CODE:

// Dice Game Simulationusing Arduino

int pinLeds1 = 2;
int pinLeds2 = 3;
int pinLeds3 = 4;
int pinLed4 = 5;
int buttonPin = 6;
int buttonState;
long ran;
int time = 2000;

void setup ()
{
pinMode (pinLeds1, OUTPUT);
pinMode (pinLeds2, OUTPUT);
pinMode (pinLeds3, OUTPUT);
pinMode (pinLed4, OUTPUT);
pinMode (buttonPin, INPUT);
randomSeed(analogRead(0));

39
EMBEDDED SYSTEMS LAB
Serial.begin(9600);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH){
ran = random(1, 7);
Serial.println(ran);

if (ran == 1){
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (ran == 2){
digitalWrite (pinLeds1, HIGH);
delay (time);
}
if (ran == 3){
digitalWrite (pinLeds3, HIGH);
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (ran == 4){
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds3, HIGH);
delay (time);
}
if (ran == 5){
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds3, HIGH);
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (ran == 6){

40
EMBEDDED SYSTEMS LAB
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds2, HIGH);
digitalWrite (pinLeds3, HIGH);
delay (time);
}
}
digitalWrite (pinLeds1, LOW);
digitalWrite (pinLeds2, LOW);
digitalWrite (pinLeds3, LOW);
digitalWrite (pinLed4, LOW);
}

OUTPUT:

Press the pushbutton to generate random number from 1 to 6.

Figure 7.3: Number 4 generated

Figure 7.4: Number 1 generated

RESULT: A dice game is simulated using LEDs and Arduino.

41
EMBEDDED SYSTEMS LAB
8. HOSTING A WEBSITE ONRASPBERRY PI

AIM: Building and hosting a simple website on device (Raspberry Pi Board) and
making it accessible online

APPARATUS:

1. Raspberry pi board
2. SD memory card (4GB/larger)
3. Power adapter
4. Ethernet patch cable
5. HDMI compatible monitor and HDMI cable
6. USB keyboard and mouse

PROCEDURE:

BOOTING YOUR RASPBERRY PI FOR THE FIRST TIME:

1. Boot the SD card loaded with the operating system. The latest version is
Raspbian Buster.
2. Once the OS is copied into the SD card, plug the card into Raspberry Pi's SD
card slot and power on the device.
3. After booting, an orange screen with options in a grey box in the centre can be
seen. Click on Next.
4. A Set country window is displayed where country, language and timezone can
be adjusted. Then click on Next.
5. A Change Password window is displayed where a password can be created.
Then click on Next.
6. A Set up screen window is displayed. Then click on Next to save the settings.
7. An Update software window is displayed. Click on Next to check and update software.
8. A Set up complete window is displayed. Click on Restart.
9. Login name: pi and password: raspberry (don't panic passwords are not shown
in Linux).
10. Enter the following command in the Raspberry Pi terminal.
sudo raspi-config

42
EMBEDDED SYSTEMS LAB
Figure 8.1: Raspberry Pi Configuration Window

9. Use the up and down arrow keys to move the highlighted selection between
the options available. Pressing the right arrow key will jump out of the options
menu and take you to the <Select> and <Finish> buttons.
Select interfacing options and enable SSH.

FINDING IP ADDRESS OF PI:

 CODE : ifconfig

Run the following command to ensure that our OS is upto date.

 CODE : sudo apt-get update


 CODE : sudo apt-get upgrade

INSTALLING APACHE:

To install Apache use the following command

 CODE : sudo apt-get install apache2 php libapache2-mod-php

You will be promoted and asked to continue, type Y for yes and hit enter it will
continue and this process takes some time.

Restart the Apache using the following command

 CODE : sudo service apache2 restart

43
EMBEDDED SYSTEMS LAB
Now open the browser and type the IP address into the URL bar. If you forget
your IP address simply use the command "ifconfig" and continue. A web page is
displayed as in the below figure. If you get error as web page not found then repeat
the above commands again.

Figure 8.2: Apache2 Debian Default Page

INSTALL FTP:

FTP: File Transfer protocol, transfers files between computers on a network

Now install VSFTPD (Very Secure File Transfer Protocol Daemon) with the
following command

 CODE : sudo apt-get install vsftpd

Now restart the FTP using the following command

 CODE : sudo service vsftpd restart

Now open the web browser in another system and type the IP address of your Pi
and you going to see the web page of our Pi in another computer. Hence after
personal web server is complete, we can use it to host a custom HTML page. To edit
your HTML page use the following command

 CODE : cd /var/www/html

44
EMBEDDED SYSTEMS LAB
Then give file name

 CODE : nano index.html

Now edit the HTML file as per your requirement. The image below shows the
edited HTML file.

Figure 8.3: HTML file

 CODE : ls -al

The ls command lists the content of the current directory (or one that is specified).
It can be used with the -l flag to display additional information (permissions, owner,
group, size, date and timestamp of last edit) about each file and directory in a list
format. The -a flag allows you to view files beginning with . (i.e. dotfiles).

 CODE : sudo chown pi: index.html

The chown command changes the user and/or group that owns a file. It normally
needs to be run as root using sudo, e.g. sudo chown pi:root *filename* will change
the owner to pi and the group to root.

45
EMBEDDED SYSTEMS LAB
Figure 8.4: Necessary commands

Now open the web browser in another system and type the IP address of your
Pi and the web page of our Pi can be seen in another computer. Image of the
website is shown below.

Figure 8.5: Hosted web page

RESULT: A website has been hosted using Raspberry pi board and the functionality
has been verified.

46
EMBEDDED SYSTEMS LAB
9. FM TRANSMISSION

AIM: Transforming the device into a regular FM transmitter capable of transmitting


audio at desired frequency (88-108 MHz)

APPARATUS:

1. Raspberry Pi
2. SD card (8GB) with Raspbian OS flashed
3. Connecting wire

THEORY:

1. The experiment uses the hardware on the Raspberry pi that is actually meant
to generate spread-spectrum clock signals on the GPIO pins to output FM
radio energy.
2. This means that the Raspberry Pi can be turned into an FM transmitter simply
by plugging in a wire as the antenna (as little as 20cm will do) into GPIO pin 4
and run the code. It transmits on 100.0 MHz
3. The EMI suppression in a microprocessor is done by a signal called spread-
spectrum clock signal or SSCS. The frequency of this signal can vary from
1MHz to 250MHz which luckily falls within the FM band. So by writing a
code to perform frequency modulation using the spread-spectrum clock signal,
the Pi can be tweaked to work as an FM transmitter.

Figure 9.1:Arranging the Pi to PC

47
EMBEDDED SYSTEMS LAB
Figure 9.2: GPIO port pin configuration

PROCEDURE:

BOOTING THE RASPBERRY PI FOR THE FIRST TIME:

1. Boot the SD card loaded with the operating system. The latest version is
Raspbian Buster.
2. Once the OS is copied into the SD card, plug the card into Raspberry Pi's SD
card slot and power on the device.
3. After booting, an orange screen with options in a grey box in the centre can be
seen. Click on Next.
4. A Set country window is displayed where country, language and timezone can
be adjusted. Then click on Next.
5. A Change Password window is displayed where a password can be created.
Then click on Next.
6. A Set up screen window is displayed. Then click on Next to save the settings.
7. An Update software window is displayed. Click on Next to check and update software.
8. A Set up complete window is displayed. Click on Restart.
9. Login name: pi and password: raspberry (don't panic passwords are not shown
in Linux).
10. Enter the following command in the Raspberry Pi terminal.

sudo raspi-config

48
EMBEDDED SYSTEMS LAB
Figure 9.3: Raspberry Pi Configuration Window

9. Use the up and down arrow keys to move the highlighted selection between
the options available. Pressing the right arrow key will jump out of the options
menu and take you to the <Select> and <Finish> buttons.
Select interfacing options and enable SSH.

TURNING THE RASPBERRY PI INTO AN FM TRANSMITTER:

1. Connect a 20cm or so plain wire to GPIO 4 (which is pin 16 on the header) to


act as an antenna, and tune an FM radio to 100MHz. The antenna is optional,
but range is reduced from ~100 meters to ~10cm without the antenna.
2. Update and upgrade the system by running
sudo apt-get update
sudo apt-get upgrade
3. Open the terminal and type the following commands.
mkdirpi_fm
cdpi_fm
sudogit clone https://github.com/markondej/fm_transmitter
sudo apt-get install gcc g++ make
cdfm_trasmitter
sudomake
sudo ./fm_transmitter –f 100 –r acoustic_guitar_duet.wav

This plays the song on the default frequency set which is 100 MHz.

49
EMBEDDED SYSTEMS LAB
Figure 9.4: Commands and the Procedure

RESULT: The Raspberry pi device is transformed into a regular FM transmitter and


the audio is transmitted at a frequency of 100MHz

50
EMBEDDED SYSTEMS LAB
10. WEBCAM SERVER USING RASPBERRY PI

AIM: Interfacing the regular USB webcam with the device and turning it into a fully
functional IP webcam &testing the functionality

APPARATUS:

1. Raspberry pi

2. SD card (8GB)

3. Power Adapter

4. Webcam

5. Keyboard and Mouse

6. Ethernet Cable

7. Monitor/display and its cable

Figure 10.1: Front-view of a Raspberry Pi Board

51
EMBEDDED SYSTEMS LAB
CONNECTION:

Figure 10.2: Circuit Connection

PROCEDURE:

1. Download the Raspbian OS from the website: www.raspberry.org and unzip it


to a directory.
2. Format the SD card and write the OS into it.
3. Insert theSD card into the Raspberry pi board and flash the OS.
4. Enter the following command in the Raspberry Pi terminal.
sudo raspi-config
5. Select interfacing options and enable SSH and camera. Select finish option.
6. Open the Raspberry Pi terminal and enter the following commands.
7. sudo apt-get update-It updates the list of available packages and their
versions, but it does not install or upgrade any packages.
8. sudo apt-get upgrade-It actually installs newer versions of the packages you
have. After updating the lists, the package manager knows about available
updates for the software you have installed.
9. sudo apt-get install motion - Some packages will be installed in the
installation process; just type “Y” to proceed with the installation.
10. sudonano /etc/motion/motion.conf -To configure motion as a motion-
detecting application.
11. sudonano /etc/default/motion -Once the file is opened, change
start_motion_daemon=no to yes.

52
EMBEDDED SYSTEMS LAB
12. sudo reboot

WEBCAM SETTINGS

To save your changes,type ctrl-X,Y and press Enter button.

1. daemon off-> daemon on


2. width and height 640x480
3. framerate 2
4. threshold 1500
5. post_capture 5
6. output_picture off
7. quality 100
8. local_motion_mode off
9. stream_port 8081
10. stream_quality100
11. stream_motion off
12. stream_localhost off
13. webcontrol_localhost off
14. webcontrol_html_output on

 Start the webcam using commands:

sudo service motion start

sudo motion

 Webcam video can be viewed in other system by giving IP address in URL


Eg:172.15.16.155:8081
 Stop the webcam using commands:

sudo service motion stop

53
EMBEDDED SYSTEMS LAB
OUTPUT:

Figure 10.3: Live feed from webcam

RESULT: USB webcam has been interfaced with the device and its functionality has
been tested.

54
EMBEDDED SYSTEMS LAB
11. DISPLAYING RSS NEWS FEED ON DISPLAY
INTERFACE
AIM: To host a feed reader on the Raspberry Pi to acquire news feed from the
internet and display the feed.
APPARATUS:
1. Raspberry Pi Board
2. SD card (8 GB)
3. Power Adapter
4. Keyboard and Mouse
5. Ethernet Cable
6. Monitor/display and its cable
THEORY:
Many news sites and blogs make their news available on a home page as well
as through special newsfeed formats like RSS or Atom. These formats not only
contain the news itself but also use XML tags to supply certain data about the news,
such as title, author, and language of the text. This tagging makes the automated
processing of news easier. To access the feed, a feed reader is required. With this type
of program, you can subscribe to feeds from favourite news sites, and the software
will download the latest articles at regular intervals. You can then mark, sort, archive,
and even delete these feeds as desired.
Tiny Tiny RSS is a free and open source web-based news feed (RSS/Atom)
reader and aggregator. Hosting Tiny Tiny RSS on the Raspberry Pi promises not only
continuity but also data security. The bundled news feeds of the Pi server can be then
read - even via several client devices – at any time.
PROCEDURE:
BOOTING YOUR RASPBERRY PI FOR THE FIRST TIME:

11. Boot the SD card loaded with the operating system. The latest version is
Raspbian Buster.
12. Once the OS is copied into the SD card, plug the card into Raspberry Pi's SD
card slot and power on the device.
13. After booting, an orange screen with options in a grey box in the centre can be
seen. Click on Next.

55
EMBEDDED SYSTEMS LAB
14. A Set country window is displayed where country, language and timezone can
be adjusted. Then click on Next.
15. A Change Password window is displayed where a password can be created.
Then click on Next.
16. A Set up screen window is displayed. Then click on Next to save the settings.
17. An Update software window is displayed. Click on Next to check and update
software.
18. A Set up complete window is displayed. Click on Restart.
19. Login name: pi and password: raspberry (don't panic passwords are not
shown in Linux).
20. Enter the following command in the Raspberry Pi terminal.
sudo raspi-config

Figure 11.1: Raspberry Pi Configuration Window

10. Use the up and down arrow keys to move the highlighted selection between
the options available. Pressing the right arrow key will jump out of the options
menu and take you to the <Select> and <Finish> buttons.

Select interfacing options and enable SSH.

HOSTING A FEED READER ON RASPBERRY PI:


1. First, installthe required packages to allow the mini-computer (RaspberryPi) to
serve dynamic web pages using the following command.
$ sudo apt-get install apache2 mysql-server mysql-client phpphp-mysqlphp-curl

56
EMBEDDED SYSTEMS LAB
2. Next, open the website for Tiny Tiny RSS in a web browser and scroll down to
the Download section. Save the offered tarball to the Raspberry Pi. In the terminal,
change to the directory in which the archive is stored and enter the following
sequence of commands. It is necessary to adapt the name of the download archives
appropriately, because it contains the actual version number.
$ sudo mv Tiny-Tiny-RSS-<versionnumber>.tar.gz /var/www/
$ cd /var/www
$ sudo tar xvfz Tiny-Tiny-RSS-<versionnumber>.tar.gz
$ sudorm Tiny-Tiny-RSS-<versionnumber>.tar.gz
$ sudo mv Tiny-Tiny-RSS-<versionnumber>tt-rss
$ sudochmodugoa+rwtt-rss
3. A request needs to be made to create a new database on the freshly installed
MySQL environment. This step can be quite easily accomplished with the help of the
shell client for MySQL, which was installed during the first step.
$ mysql --user=root --password=<MySQL-password>
mysql> CREATE DATABASE ttrss;
mysql> QUIT
4. Determine the IP address of the Raspberry Pi using the following command.
$ ifconfig
5. Now, execute the installation assistant of Tiny Tiny RSS by pointing a web browser
on any computer attached to your LAN to the URL http://<RaspPi-IP>/tt-rss/install/.
Fill in the displayed form with information about your MySQL server.

Figure 11.2: Installation assistant of Tiny Tiny RSS

57
EMBEDDED SYSTEMS LAB
6. The feed reader itself can be invoked via http://<RaspPi-IP>/tt-rss/. For the first
login, a standard user account exists with user name admin and password password.
At this point, you should replace the admin password with your own. To do so, click
on Actions at the top right of the overview screen for Tiny Tiny RSS and
choose Preferences from the submenu that appears.

Figure 11.3: Window to change password after first login

Figure 11.4: The overview screen shows the latest news feeds

7. The Raspberry Pi still needs to refresh automatically and at regular intervals the
news feeds to which have been subscribed. The easiest way to accomplish this is by
installing a cron job. To do so, open up the cron editor and add the following line
viasudocrontab –e.
*/30 * * * * /usr/bin/php5 /var/www/tt-rss/update.php --feeds –quiet
This command will execute the accompanying update.php script approximately
every 30 minutes.
8. The Raspberry Pi now functions as a server, and client access is accomplished
through numerous other devices.
RESULT: The Raspberry Pi hosts a web based feed reader and the news feed is
acquired and displayed

58
EMBEDDED SYSTEMS LAB

You might also like