1 of 60

2 of 60

EKO-KONNECT RESEARCH AND EDUCATION INITIATIVE

Internet of Things (IoT) with Python and Virtual Lab

[Pycon Nigeria Conference 2019 Workshop Session]

3 of 60

Building a Low Power Weather Station in real-time

using ESP8266 with MicroPython and Thingspeak IoT Platform

4 of 60

HARDWARE

Esp8266 (Wemos)

Temperature and Humidity sensors (SHT 30)

5 of 60

HARDWARE

Breadboard

USB

6 of 60

ESP8266 Digital Input/Output

7 of 60

Software

  • Thonny IDE
  • ThingSpeak IoT platform

Programming Language

  • MicroPython

8 of 60

IMPLEMENTATION

9 of 60

USB SERIAL PORT

Linux

  • sudo apt-get install minicom
  • minicom -s
  • set up the serial port to ttyUSB0
  • enter>exit minicom

Windows

  • Device manager
  • Ports
  • Select the Com port

MAC

  • ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
  • brew install minicom
  • manually edit your $path file sudo nano /private/etc/paths, add; /opt/minicom/2.2/bin
  • minicom -s

10 of 60

FLASH MICROPYHON FIRMWARE

“/dev/ttyUSB0”/com port- your serial port

  • Erase the flash esptool.py --port /dev/ttyUSB0 erase_flash

  • Download the latest MicroPython firmware for esp8266 at http://micropython.org/download#esp8266
  • Install esptool to flash the micrpython firmware on the board with following commands

  • Install python3
  • Install pip
  • [sudo]pip3 install esptool
  • Downloaded firmware is esp8266-20190529-v1.11.bin
  • esptool.py --port /dev/ttyUSB0 --baud 115200write_flash --flash_size=detect 0 esp8266-20190529-v1.11.bin [Linux]
  • [MAC] [/dev/cu.usbserial-(port-no)
  • esptool.py --port COM3 --baud 460800 write_flash --flash_size=detect 0 esp8266-20161110-v1.8.6.bin [Windows]

11 of 60

REPL (Read Evaluate Print Loop) Interface

Access the raw REPL (Read evaluate print loop) microPython prompt with the command

  • picocom /dev/ttyUSB0 -b115200>picocom /dev/ttyUSB0 -b115200 picocom v1.7
  • [Linux]
  • TeraTerm [Windows]
  • Minicom [Mac]

Error Note: Unplug the esp8266 USB cable from the port and replug if the error is Fatal: can't open /dev/ttyUSB0

CTRL-B to exit

12 of 60

THONNY

Linux Commands

  • sudo apt install python3 python3-pip python3-tk
  • sudo apt upgrade python3 python3-pip python3-tk
  • git clone https://github.com/thonny/thonny-espThonny
  • Tool>Option>Intereper>Micropython>portUSB0
  • To upload a py file for import-Device>upload current script with current name

Download

https://thonny.org/

https://bitbucket.org/plas/thonny/downloads/

13 of 60

Connecting Esp8266 T0 WIFI

import network

WiFi_SSID = "YOUR SSID"

WiFi_PASS = "YOUR PASSWORD"

def do_connect():

wlan = network.WLAN(network.STA_IF)

wlan.active(True)

if not wlan.isconnected():

print('connecting to network...')

wlan.connect(WiFi_SSID, WiFi_SSID)

while not wlan.isconnected():

pass

print('network config:', wlan.ifconfig())

do_connect() #The network module is used to connect the board to wifi and it’s default in MicroPython

14 of 60

CLONE SHT30 DRIVER

Python script to measure Temperature and Humidity

sensor = SHT30()

temperature, humidity = sensor.measure()

print('Temperature:', temperature, 'ºC’, ‘Humidity:', humidity, '%')

15 of 60

ThingSpeak

  • Create an account on ThinkSpeak.com

  • Next, follow the instructions to create a Channel and take note of your Channel ID

  • Note the Write API Key. Channelsettings> Channel ID>API keys> Write API key

#https://www.mathworks.com/mwaccount/register

16 of 60

Simple MQTT Protocol

  • Clone simplemqtt python script /libraries

  • MQTT stands for Message Queuing Telemetry Transport. MQTT is a simple messaging protocol, designed for devices with low-bandwidth to connect over wireless networks for the Internet of Things applications.
  • Using MQTT protocol, we will get captured mqtt client data, that is read and publish the data from sensors, logging them to an IoT service like ThingSpeak.com
  • It is a simple and lightweight protocol that runs over TCP/IP sockets or WebSockets.

17 of 60

ESP8266 MicroPython

18 of 60

Importing Libraries

import time # import time module

from umqttsimple import MQTTClient # umqttsimple library

from driver import SHT30 #STH30 sensor driver

import network #import network library

19 of 60

Connect to Wifi

#connect esp8266 board to wifi

WiFi_SSID = "YOUR SSID"

WiFi_PASS = "YOUR PASSWORD"

def do_connect():

wlan = network.WLAN(network.STA_IF)

wlan.active(True)

if not wlan.isconnected():

print('connecting to network...')

wlan.connect(WiFi_SSID, WiFi_SSID)

while not wlan.isconnected():

pass

print('network config:', wlan.ifconfig())

do_connect()

20 of 60

Connect to ThingSpeak

#create Thingspeak MQTT client

SERVER = "mqtt.thingspeak.com"

client = MQTTClient("umqtt_client", SERVER)

#Thingspeak credentials

CHANNEL_ID = "846133"

WRITE_API_KEY = "2JGLP14KN2HW3R5D"

# Create MQTT topic

topic = "channels/" + CHANNEL_ID + "/publish/" + WRITE_API_KEY

21 of 60

Run SHT30

#Get our temperature and humidity data in real time every 2 minutes sent to Thingspeak IoT service

while True:

sensor = SHT30()

temperature, humidity = sensor.measure()

#create MQTT payload

payload= "field1="+str(temperature)+"&field2="+str(humidity)

#continuously log temperature and humidity data to thingspeak channel

client.connect()

client.publish(topic, payload)

client.disconnect()

time.sleep(120)

22 of 60

REFERENCE

23 of 60

Home Automation with Echo Dot

24 of 60

HARDWARE

Echo Dot

Raspberry Pi

25 of 60

HARDWARE

LED

Resistors

26 of 60

SOFTWARE

  • Python
  • Fauxmo

27 of 60

LEDs on breadboard

Connecting LEDs on a breadboard

  • An LED has Anode negative pin and Cathode positive pin (longest pin)

  • Connect the LED on a breadboard on a row

  • Connect one leg of the resistor to the led cathode leg and another leg on the board

  • Then connect a pin of the wire to the led cathode leg and the other pin to a GPIO pin then connect another wire from the led anode to the GPIO ground pin.

28 of 60

FAUXMOS

  • Use the Fauxmos python library https://github.com/kanesurendra/echo-pi to communicate with the Echo dot in order to control the GPIO pins

  • Instruct Echo dot Alexa to find the device that is the project.

Credit: kanesurendra

Other remote access

Amazon Alexa Alexa Skills Kit

29 of 60

THANK YOU

30 of 60

31 of 60

Using Python with robots and the Raspberry Pi

32 of 60

Objective

To demonstrate the use of Python in physical computing.

33 of 60

Devices description...

Raspberry Pi 3 model

GPIO PINS

34 of 60

...Devices description

Pi-camera

PIR Sensor

Finch robot

35 of 60

physical computing with python - Light Emitting diode

36 of 60

Physical computing with PYTHON - SURveillance SYstem

37 of 60

Other possible use cases

  • Burglar Detection
  • Traffic Monitoring
  • Wildlife Monitoring
  • Campus Access Control

Using A Virtual Assistant - Google Home, Echo Dot

38 of 60

Reference

https://gitlab.wacren.net/kaffy9017/Surveillance_System

39 of 60

40 of 60

Thank you

41 of 60

USING CSIRT AND NREN FOR DATA PROTECTION AND PRIVACY

Presented by Kafayat Adeoye

DIRISA NATIONAL DATA WORKSHOP 2019

Authors: Pius Effiom and Kafayat Adeoye

42 of 60

OUTLINES

43 of 60

    • Definitions
  • CSIRT
  • NREN
  • NREN CSIRT
    • Why CSIRT in NREN?

NREN CSIRT Model

CSIRT Team Structure

NREN CSIRT Establishment Processes

      • Phase 1: Obtain support and buy-in
      • Phase 2: NREN CSIRT strategic plan
      • Phase 3: Vision and implementation
      • Phase 4: Funding for operation
      • Phase 5: Announcement and communication
    • Conclusion

44 of 60

DEFINITIONS

45 of 60

CSIRT

A CSIRT meaning Computer Security Incident Response Team is an organization or team that provides services and support to a defined constituency for preventing, handling, and responding to computer security incidents.

NREN

National Research and Education Network (NREN) comprises of network infrastructure and communities of users dedicated to supporting the needs of the research and education within a country.

NREN-CSIRT

The CSIRT created in institutions aggregate to form the NREN CSIRT and it is managed by an NREN Operator who is responsible for handling security and data privacy related issues nationally.

46 of 60

WHY CSIRT?

47 of 60

Operational Infrastructure

Research Data

Personal Data

Vulnerabilities

UNIVERSITIES (NIGERIA)

48 of 60

IMPLEMENTATION

49 of 60

NREN CSIRT MODEL

INSTITUTION B

INSTITUTION D

NREN CSIRT

INSTITUTION E

INSTITUTION C

INSTITUTION A CSIRT

INSTITUTION F

50 of 60

CSIRT TEAM STRUCTURE

CSIRT Manager

Researcher

System/Network Administrator

Communication Officer

Legal Officer

Finance Officer

51 of 60

NREN CSIRT ESTABLISHMENT PROCESSES

52 of 60

Obtain Management Support and Buy-in

Strategic Plan

Announce the Operational CSIRT

Design vision and Implementation Process

Funding for Operation

53 of 60

OBTAIN MANAGEMENT SUPPORT AND BUY-IN

A CSIRT has to be acknowledged by the institution management before implementation this may involve management of the institution signing the following documents;

  • A mandate for the CSIRT
  • MoU for the CSIRT
  • A clear statement of the objective for the CSIRT

54 of 60

STRATEGIC PLAN

Where will the group members come from ?

Communication model with management

What administrative issues must be dealt with ?

What specific time frames to be met ?

Are all stakeholders represented ?

What project issues must be addressed?

55 of 60

DESIGN THE NREN CSIRT VISION AND IMPLEMENTATION PROCESS

Gather relevant information

  • Identify types of incident activity currently being reported
  • Identify what information you need to know to plan and implement the CSIRT
  • Access to relevant information such as;
  • existing security policies and procedures,
  • critical system and asset inventories
  • topologies for systems and networks
  • Determine who has those information and how best to gather that information either through general discussions or interviews or by making them part of the project

56 of 60

NREN CSIRT OPERATIONS

Incident handling

  • Incident reporting
  • Acceptable Response Time
  • Preventative measure

Incident postmortems

  • Incident reporting documentation
  • Tracking and monitoring: Audit, Yearly security report, Research and Analytics

Communication

  • Helpdesk
  • Website
  • media

  • Network Monitoring tools
  • Intrusion and penetration detection tools
  • Auditing tools
  • Other security tools

Tools

  • Security policy for exchange of data and access to resources
  • Legal documents handling
  • Operational mandate

Policy Framework

57 of 60

SECURE FUNDING FOR THE CSIRT OPERATIONS

  • Obtain funding for start-up, short-term and long-term operations.

  • Decide what funding model you will use to support the CSIRT

58 of 60

BEGIN IMPLEMENTATION

Training initial CSIRT staff.�• Acquire necessary tools and build network infrastructure to support the team.�• Develop the initial set of CSIRT policies and procedures to support your services.�• Define the specifications for your incident-tracking system.�• Develop incident-reporting guidelines. These guidelines define how the institution interacts with the CSIRT.

59 of 60

ANNOUNCE THE OPERATIONAL CSIRT

Publicity

Awareness training

Communication process

Announce the operational CSIRT

60 of 60

NREN CSIRT