You are on page 1of 9

MALNAD COLLEGE OF ENGINEERING

[An autonomous Institution under VTU, Belagavi]


Hassan, Karnataka 573202, India

Activity report on

Simulation of using Raspberry Pi using Wokwi


Simulation of IoT network using Contiki

Submitted by
NAME USN NAME USN

BASAVARPITHA T C 4MC19CS024 BRUNDA D S 4MC18CS024


BINDU C K 4MC19CS030 CHITHRA 4MC19CS036
CK
CHINMAYI R SHANKAR 4MC19CS033 APEKSHA H M 4MC19CS020
CHANDANA Y M 4MC20CS401

Submitted to
Dr. Mohana Lakshmi J
Associate Professor
Department of Computer Science and Engineering
Malnad college of Engineering Hassan, Karnataka 573202,India
1)Write a RaspberryPi Pico compatible python code to record the temperature in a room,
display this value on a LED

Problem statement:-

Write a RaspberryPi Pico compatible python code to record the temperature in a room,
display this value on a LED
We will read the Temperature Sensor Value from Raspberry Pi Pico. The Raspberry Pi
Pico has internal Temperature Sensor connected to one of a few special pins
called ADCs or Analog-to-Digital Converters
We will connect an I2C OLED Display to the Raspberry Pi Pico & read the Temperature
Data from the Sensor. We will then display the temperature on OLED Screen

Circuit design:
 Simulation using Wokwi
Wokwi is an online simulator that simulates several electronic
components. We also implement the code so that the project can
run successfully.
Step1:
Open wokwi platform and create a python file .py. Add the
required components
Step2:
There will be two windows, editor window and simulator
window. In the simulator window, we make connections of
the components as shown in circuit diagram
Step3:
According to the connections we have to implement the python
code in order to run the simulator.
Step4:
Code is written in such a way that the temperature will be displayed
on OLED screen
 Results:

 Code Implementation
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import machine
import utime

sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

WIDTH = 128
HEIGHT = 64

i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=200000) # Init I2C using pins


GP8 & GP9 (default I2C0 pins)
print("I2C Address : "+hex(i2c.scan()[0]).upper()) # Display device
address
print("I2C Configuration: "+str(i2c)) # Display I2C config

oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) # Init oled display

while True:
reading = sensor_temp.read_u16() * conversion_factor
temperature = 27 - (reading - 0.706)/0.001721
print(temperature)

# Clear the oled display in case it has junk on it.


oled.fill(0)

# Add some text


oled.text("Temp: ",6,8)
oled.text(str(round(temperature,2)),50,8)
oled.text("*C",95,8)
utime.sleep(2)

# Finally update the oled display so the image & text is displayed
oled.show()

We can observe that after simulation the temperature is displayed on OLED


2. Simulation of IoT Network Using Contiki
➢ Problem statement:-
Using Contiki Simulator create sky websense node and enable
the sensors to test the temperature
➢ Simulation using Contiki-
Step-1 Open the menu on cooja and create a new simulation
with random seeding.
 It will auto-generate the seeds for every time reload
thesimulation.
 File-new simulation (or)(ctrl +n).
 Click-Newrandomseed onreloadoption.
 Click-Create
Step-2 After click, different tabs will appear in the terminal
which is a basic necessity to simulate applications.
 In Network window there are different network options
displayed select the option that we require
 Open sky motes menu>>add motes>>create new motes type
>>sky
 Two files are necessary to run this application. In order to
create the motes.
 buttonapp.
 user-examples-websense.c
 user-examples-Makefile
Step-3 To create motes
 home/user/contiki/examples/IPv6/RPL-Border-
Router/Bourder-Router.c
 Choose the file>>clean>>compile>>create
 Addmotes.(1 motes)
Step-4 To.
 To Create Another motes
 /home/user/contiki/examples/IPv6/sky-websense/sky-
websense.c
 Choose the file>>clean>>compile>>create
 Add motes (10 motes)

Step-5 Connect the serial socket server in border router


 Leftclickonborderroutermoteschoose:motetoolsforsky1s
erial socket(SERVER).
 New tab of serial socket(server)(sky1)will appear click
: start -> now the default portwilllisten.
 Open one more command terminal and set directories to
this location: cd examples/ ipv6/ rpl-border-router/make
connect-router-cooja the server will be connected torouter.
 Next command make connect router-cooja
 Results (images and explanation)

 Here in the terminal in order to open new simulate we give the


Commands as shown in fig.1

 First the new simulation is being created named websense


 We create sky 1 Server mote and rest 10 nodes of sky 2 motes

 run the Server sky mote and also the simulation control
EXECUTION
VideoLink
https://drive.google.com/drive/folders/1g0qwM0Cz8pyotqXwVP__Z9C
LrhbfdIOD

You might also like