SlideShare a Scribd company logo
IoT on Raspberry Pi
John Staveley MVP
16/10/2021
https://uk.linkedin.com/in/johnstaveley/
@johnstaveley
About Me
 John Staveley MVP
 IT Contractor in C#, Mvc, Sql Server, Angular and Azure
 Organise LeedsSharp and IoTNorth etc
 Used microcontrollers, Not an electronics expert!
What we will cover
 Programming with C# on a Raspberry Pi
 Setup .Net 5
 Control the things
 GPIO, PWM, I2C
 Control from the outside world
 Azure IoTHub
 Receiving updates from the device
Hardware Overview
 Raspberry Pi 4-b, Wifi, Camera
port
 GPIO, SPI, USB2/3, Ethernet,
HDMI etc
 MicroSD card and USB-C power
 Meadow
 .Net Nanoframework on ESP32
Prepare for launch
 USB-C Power supply (3A)
 Noobs on MicroSD card
 Screen (Micro-HDMI), Keyboard (USB 2/3), Mouse (USB 2/3)
 Wifi (fixed IP)
Basic Raspbian setup
 Install .Net 5 https://www.petecodes.co.uk/install-and-use-microsoft-dot-
net-5-with-the-raspberry-pi/
 Install VS Code
 Security settings
Control the things
 Digital Input/Output
 PWM
 I2C
 Camera
 Docs for C#: https://github.com/dotnet/iot
 using System.Device.Gpio
 using Iot.Device.Bindings
PIN Layout
Ref: https://pinout.xyz/pinout/5v_power#
Hello World
Digital Output Code
 Install-Package System.Device.IO
Digital output examples
 LED
 Buzzer
 Infrared LED
 Laser
 Relay
 Multi-LED
 … and lots more
Electronics
 Hardware recipes:
https://gpiozero.readthedocs.io/e
n/stable/recipes.html#led
 Pull up/down
 Anti-short
 Anti back EMF diodes
 Geekcreit 45 In 1 Sensor Module
Board Starter Kits Upgrade
Version For Arduino (Banggood
£15)
 https://images-eu.ssl-images-
amazon.com/images/I/C1lrpIfADa
S.pdf
Azure IoT Hub
 Free for < 8000 messages per day
 Control hundreds of devices
 Event Hubs
 HTTP, AQMP, MQTT
 Device Twins
 IoT Edge
 Setup:
 Create IoTHub in Azure portal
 Create device in portal
 Set up a direct method
DEMO
Controlling using Azure IoT
Explorer
Connecting device to Azure IoT Hub
 Get DEVICE connection string from IoTHub
DeviceClient _deviceClient =
DeviceClient.CreateFromConnectionString(configuration.IoTHubConnect
ionString);
await _deviceClient.SetMethodHandlerAsync(“MyMethod”, ActionMethod,
null);
….
private static async Task<MethodResponse>
ActionMethod(MethodRequest methodRequest, object userContext)
{
var data = methodRequest.DataAsJson;
var controlAction =
JsonConvert.DeserializeObject<ControlAction>(data);
Development experience
 Develop in Visual Studio
 Publish to directory
 Deployment: self-contained
 Target runtime: linux-arm
 Target framework: net5.0
 Fixed IP
 SFTP files using FileZilla
 VNC
 chown <user> <Directory or File> e.g. chown pi ./Control
 chmod +rwx <Directory> e.g. chmod +rwx ./Control
 ./<My dll name> e.g. ./Control
Digital input examples
 Push button
 Reed switch
 Magnetic sensor
 Tilt switch
 Ball switch
 Knock sensor
 Light blocking
 Infrared receiver
 Motion sensor
Pulse-width Modulation
(PWM)
Pulse-width Modulation
Examples
 Servos
 Lamps/LED
 Motors
 Pumps
 Fan
 Display Dial
 Audio effects https://www.youtube.com/watch?v=l4cuy1HOR3E
 …and lots more
Pulse-width Modulation Setup
PWM Code
 Software PWM
 Hardware PWM
var _servo1 = new SoftwarePwmChannel(18, 400, 0.9, true);
_servo1.Start();
_servo1.DutyCycle = 0;
_servo1.DutyCycle = 50;
_servo1.DutyCycle = 100;
I2C Overview
 Inter-Integrated Circuit (I2C)
 Two wire communication
 Pin 3, 5 and 27, 28
 Short range, multiple devices
 Enable on hardware
 sudo apt-get install i2c-tools
 sudo i2cdetect –y 1
I2C Examples
 Relay controller
 PWM controller
 Digital IO Expansion
 LCD screen
 Analogue inputs
 GPS
 RFID
 Rotary encoder (Volume switch)
 Temperature, Pressure, Humidity
 Accelerometer
 EEPROM
Aside:
Prototyping
 Jumper cables (M-F, F-F)
 Din rail mounting
 Connector blocks
 Breadboard
 Totemmaker
I2C Hardware – PWM controller
I2C PWM controller - code
Choosing hardware
 https://shop.pimoroni.com
 https://github.com/dotnet/iot/tree/
main/src/devices
 No driver? Translate the I2C interface!
I2C Relay Hat
 Solenoids
 High ampage lamps
 Fireworks
 …See code in project
I2C Relay hat - code
// Set relay 0 to 3, control Action 0 or 1
// Get relayNumber 0 to 3, returns either 0 or 1
… see code e.g. SetRelay
Introducing Blazor
 SPA Application framework
 Server side
 Push updates by SignalR
Blazor – how it works
Sending a message to Azure IoT Hub
 Get SERVICE connection string
ServiceClient _serviceClient =
ServiceClient.CreateFromConnectionString(configuration.IoTHubConnec
tionString);
var deviceMethod = new CloudToDeviceMethod(“MyMethod”);
var payload = JsonSerializer.Serialize(controlAction);
deviceMethod.SetPayloadJson(payload);
var result = await
_serviceClient.InvokeDeviceMethodAsync(_deviceId, deviceMethod);
DEMO
Putting it together: Website
controlling remote device
Camera
 Normal, Hi-def, infra-red
Digital Input example
Digital Input code
int _inputPin = 22;
System.Device.Gpio.GpioController _controller = new();
_controller.OpenPin(_inputPin, PinMode.Input);
var inputResult = _controller.Read(_inputPin);
Console.Log(inputResult); // High or Low
Sending messages from the device
 …to the event hub
Event Hubs
 Azure IoTHub is backed by an
Event Hub
 Scalable to millions of events
per second
 Kafka as a service
 Supports AMQP, HTTPS and
Apache Kafka
Receiving messages from Event Hub
 Messages can be routed to blob storage/service bus etc
 IoTHub -> Message Routing -> Enable fallback route
 Receive message from Event Hub
Demo: Receiving events from device
 Device started
 Is alive
 Button push
Summary
 You have the power using C# to control lots of types of hardware: I/O, PWM,
I2C, Camera
 Not everything you can buy can be controlled – yet!
 Azure IoT Hub can be used to connect to and control your device from the
internet and receive live events from it
Get started
resources
 Starter kit:
https://thepihut.com/products/r
aspberry-pi-starter-kit
 “How to” book:
https://shop.pimoroni.com/produ
cts/the-official-raspberry-pi-
beginners-guide-4th-ed-uk
 45 in 1 sensor pack:
https://www.banggood.com/Gee
kcreit-45-In-1-Sensor-Module-
Board-Starter-Kits-Upgrade-
Version-For-Arduino-UN0-R3-
MEGA2560-Plastic-Bag-Package-p-
1137050.html
Any Questions?
@johnstaveley
Demo code: https://github.com/johnstaveley/RaspberryPiControl
Slides: https://www.slideshare.net/johnstaveley/iot-on-raspberry-pi
Connect: https://uk.linkedin.com/in/johnstaveley/

More Related Content

What's hot

AWS SQS SNS
AWS SQS SNSAWS SQS SNS
AWS SQS SNS
Durgesh Vaishnav
 
DDoS Mitigation Techniques and AWS Shield
DDoS Mitigation Techniques and AWS ShieldDDoS Mitigation Techniques and AWS Shield
DDoS Mitigation Techniques and AWS Shield
Amazon Web Services
 
AWS EC2
AWS EC2AWS EC2
AWS EC2
Mahesh Raj
 
Aws VPC
Aws VPCAws VPC
Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3
Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3
Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3
Amazon Web Services
 
[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA
[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA
[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA
Amazon Web Services Korea
 
Introduction to Amazon EC2
Introduction to Amazon EC2Introduction to Amazon EC2
Introduction to Amazon EC2
Amazon Web Services
 
AWS | VPC Peering
AWS | VPC PeeringAWS | VPC Peering
AWS | VPC Peering
Mohan Reddy
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
Amazon Web Services
 
AWS Systems manager 2019
AWS Systems manager 2019AWS Systems manager 2019
AWS Systems manager 2019
John Varghese
 
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
Amazon Web Services Korea
 
Getting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and Serverless
Amazon Web Services
 
Introduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best PracticesIntroduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best Practices
Gary Silverman
 
Intro to Amazon ECS
Intro to Amazon ECSIntro to Amazon ECS
Intro to Amazon ECS
Amazon Web Services
 
Intro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute ServicesIntro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute Services
Amazon Web Services
 
Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM
Amazon Web Services
 
CI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelCI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day Israel
Amazon Web Services
 
AWS API Gateway
AWS API GatewayAWS API Gateway
AWS API Gateway
Muhammed YALÇIN
 
Development and Test on AWS
Development and Test on AWSDevelopment and Test on AWS
Development and Test on AWS
Amazon Web Services
 
Fundamentals of AWS Security
Fundamentals of AWS SecurityFundamentals of AWS Security
Fundamentals of AWS Security
Amazon Web Services
 

What's hot (20)

AWS SQS SNS
AWS SQS SNSAWS SQS SNS
AWS SQS SNS
 
DDoS Mitigation Techniques and AWS Shield
DDoS Mitigation Techniques and AWS ShieldDDoS Mitigation Techniques and AWS Shield
DDoS Mitigation Techniques and AWS Shield
 
AWS EC2
AWS EC2AWS EC2
AWS EC2
 
Aws VPC
Aws VPCAws VPC
Aws VPC
 
Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3
Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3
Hands-on Setup and Overview of AWS Console, AWS CLI, AWS SDK, Boto 3
 
[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA
[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA
[AWS Builders] AWS IAM 을 통한 클라우드에서의 권한 관리 - 신은수, AWS Security Specialist SA
 
Introduction to Amazon EC2
Introduction to Amazon EC2Introduction to Amazon EC2
Introduction to Amazon EC2
 
AWS | VPC Peering
AWS | VPC PeeringAWS | VPC Peering
AWS | VPC Peering
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
 
AWS Systems manager 2019
AWS Systems manager 2019AWS Systems manager 2019
AWS Systems manager 2019
 
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
Amazon VPC와 ELB/Direct Connect/VPN 알아보기 - 김세준, AWS 솔루션즈 아키텍트
 
Getting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and Serverless
 
Introduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best PracticesIntroduction to AWS VPC, Guidelines, and Best Practices
Introduction to AWS VPC, Guidelines, and Best Practices
 
Intro to Amazon ECS
Intro to Amazon ECSIntro to Amazon ECS
Intro to Amazon ECS
 
Intro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute ServicesIntro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute Services
 
Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM
 
CI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day IsraelCI/CD pipelines on AWS - Builders Day Israel
CI/CD pipelines on AWS - Builders Day Israel
 
AWS API Gateway
AWS API GatewayAWS API Gateway
AWS API Gateway
 
Development and Test on AWS
Development and Test on AWSDevelopment and Test on AWS
Development and Test on AWS
 
Fundamentals of AWS Security
Fundamentals of AWS SecurityFundamentals of AWS Security
Fundamentals of AWS Security
 

Similar to IoT on Raspberry PI v1.2

IoT on Raspberry Pi
IoT on Raspberry PiIoT on Raspberry Pi
IoT on Raspberry Pi
John Staveley
 
Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)
Amarjeetsingh Thakur
 
Generating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdeviceGenerating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdevice
Alon Fliess
 
Bare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in LinuxBare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in Linux
Alexander Vanwynsberghe
 
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Codemotion Tel Aviv
 
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
Codit
 
Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)
남균 김
 
IoT on azure
IoT on azureIoT on azure
IoT on azure
Joanna Lamch
 
A serverless IoT Story From Design to Production and Monitoring
A serverless IoT Story From Design to Production and MonitoringA serverless IoT Story From Design to Production and Monitoring
A serverless IoT Story From Design to Production and Monitoring
Moaid Hathot
 
A serverless IoT story from design to production and monitoring
A serverless IoT story from design to production and monitoringA serverless IoT story from design to production and monitoring
A serverless IoT story from design to production and monitoring
CodeValue
 
FIWARE Internet of Things
FIWARE Internet of ThingsFIWARE Internet of Things
FIWARE Internet of Things
Miguel González
 
FIWARE Internet of Things
FIWARE Internet of ThingsFIWARE Internet of Things
FIWARE Internet of Things
Miguel García González
 
Вещи на Python - Сергей Матвеенко, DataArt
Вещи на Python - Сергей Матвеенко, DataArtВещи на Python - Сергей Матвеенко, DataArt
Вещи на Python - Сергей Матвеенко, DataArt
it-people
 
Azure Internet of Things
Azure Internet of ThingsAzure Internet of Things
Azure Internet of Things
Alon Fliess
 
How To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetHow To Electrocute Yourself using the Internet
How To Electrocute Yourself using the Internet
Alexander Roche
 
Fiware IoT_IDAS_intro_ul20_v2
Fiware IoT_IDAS_intro_ul20_v2Fiware IoT_IDAS_intro_ul20_v2
Fiware IoT_IDAS_intro_ul20_v2
FIWARE
 
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT Meetup
 
Fiware io t_ul20_cpbr8
Fiware io t_ul20_cpbr8Fiware io t_ul20_cpbr8
Fiware io t_ul20_cpbr8
FIWARE
 
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech TalksEssential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Amazon Web Services
 
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Amazon Web Services
 

Similar to IoT on Raspberry PI v1.2 (20)

IoT on Raspberry Pi
IoT on Raspberry PiIoT on Raspberry Pi
IoT on Raspberry Pi
 
Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)
 
Generating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdeviceGenerating cross platform .NET based azure IoTdevice
Generating cross platform .NET based azure IoTdevice
 
Bare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in LinuxBare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in Linux
 
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
 
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
Azure IoT suite - A look behind the curtain (Sam Vanhoutte @AZUG Event)
 
Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)
 
IoT on azure
IoT on azureIoT on azure
IoT on azure
 
A serverless IoT Story From Design to Production and Monitoring
A serverless IoT Story From Design to Production and MonitoringA serverless IoT Story From Design to Production and Monitoring
A serverless IoT Story From Design to Production and Monitoring
 
A serverless IoT story from design to production and monitoring
A serverless IoT story from design to production and monitoringA serverless IoT story from design to production and monitoring
A serverless IoT story from design to production and monitoring
 
FIWARE Internet of Things
FIWARE Internet of ThingsFIWARE Internet of Things
FIWARE Internet of Things
 
FIWARE Internet of Things
FIWARE Internet of ThingsFIWARE Internet of Things
FIWARE Internet of Things
 
Вещи на Python - Сергей Матвеенко, DataArt
Вещи на Python - Сергей Матвеенко, DataArtВещи на Python - Сергей Матвеенко, DataArt
Вещи на Python - Сергей Матвеенко, DataArt
 
Azure Internet of Things
Azure Internet of ThingsAzure Internet of Things
Azure Internet of Things
 
How To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetHow To Electrocute Yourself using the Internet
How To Electrocute Yourself using the Internet
 
Fiware IoT_IDAS_intro_ul20_v2
Fiware IoT_IDAS_intro_ul20_v2Fiware IoT_IDAS_intro_ul20_v2
Fiware IoT_IDAS_intro_ul20_v2
 
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
 
Fiware io t_ul20_cpbr8
Fiware io t_ul20_cpbr8Fiware io t_ul20_cpbr8
Fiware io t_ul20_cpbr8
 
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech TalksEssential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
Essential Capabilities of an IoT Cloud Platform - AWS Online Tech Talks
 
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
Essential Capabilities of an IoT Cloud Platform - April 2017 AWS Online Tech ...
 

More from John Staveley

Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
John Staveley
 
Image and Audio Detection using Edge Impulse
Image and Audio Detection using Edge ImpulseImage and Audio Detection using Edge Impulse
Image and Audio Detection using Edge Impulse
John Staveley
 
Product and Customer Development
Product and Customer DevelopmentProduct and Customer Development
Product and Customer Development
John Staveley
 
Getting started with satellite IoT
Getting started with satellite IoTGetting started with satellite IoT
Getting started with satellite IoT
John Staveley
 
Birdwatching using a Raspberry pi, Azure IoT Hub and Cognitive services
Birdwatching using a Raspberry pi, Azure IoT Hub and Cognitive servicesBirdwatching using a Raspberry pi, Azure IoT Hub and Cognitive services
Birdwatching using a Raspberry pi, Azure IoT Hub and Cognitive services
John Staveley
 
DevSecOps - automating security
DevSecOps - automating securityDevSecOps - automating security
DevSecOps - automating security
John Staveley
 
Azure functions and container instances
Azure functions and container instancesAzure functions and container instances
Azure functions and container instances
John Staveley
 
Non nullable reference types in C#8
Non nullable reference types in C#8Non nullable reference types in C#8
Non nullable reference types in C#8
John Staveley
 
Graph databases and SQL Server 2017
Graph databases and SQL Server 2017Graph databases and SQL Server 2017
Graph databases and SQL Server 2017
John Staveley
 
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure FunctionsMessaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
John Staveley
 
Why you should use Type script and EcmaScript 6
Why you should use Type script and EcmaScript 6Why you should use Type script and EcmaScript 6
Why you should use Type script and EcmaScript 6
John Staveley
 
Updated Mvc Web security updated presentation
Updated Mvc Web security updated presentationUpdated Mvc Web security updated presentation
Updated Mvc Web security updated presentation
John Staveley
 
Web security leeds sharp dot netnotts
Web security leeds sharp dot netnottsWeb security leeds sharp dot netnotts
Web security leeds sharp dot netnotts
John Staveley
 
Design Patterns - LFM and POM
Design Patterns - LFM and POMDesign Patterns - LFM and POM
Design Patterns - LFM and POM
John Staveley
 
Web security presentation
Web security presentationWeb security presentation
Web security presentation
John Staveley
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
John Staveley
 

More from John Staveley (16)

Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Image and Audio Detection using Edge Impulse
Image and Audio Detection using Edge ImpulseImage and Audio Detection using Edge Impulse
Image and Audio Detection using Edge Impulse
 
Product and Customer Development
Product and Customer DevelopmentProduct and Customer Development
Product and Customer Development
 
Getting started with satellite IoT
Getting started with satellite IoTGetting started with satellite IoT
Getting started with satellite IoT
 
Birdwatching using a Raspberry pi, Azure IoT Hub and Cognitive services
Birdwatching using a Raspberry pi, Azure IoT Hub and Cognitive servicesBirdwatching using a Raspberry pi, Azure IoT Hub and Cognitive services
Birdwatching using a Raspberry pi, Azure IoT Hub and Cognitive services
 
DevSecOps - automating security
DevSecOps - automating securityDevSecOps - automating security
DevSecOps - automating security
 
Azure functions and container instances
Azure functions and container instancesAzure functions and container instances
Azure functions and container instances
 
Non nullable reference types in C#8
Non nullable reference types in C#8Non nullable reference types in C#8
Non nullable reference types in C#8
 
Graph databases and SQL Server 2017
Graph databases and SQL Server 2017Graph databases and SQL Server 2017
Graph databases and SQL Server 2017
 
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure FunctionsMessaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
 
Why you should use Type script and EcmaScript 6
Why you should use Type script and EcmaScript 6Why you should use Type script and EcmaScript 6
Why you should use Type script and EcmaScript 6
 
Updated Mvc Web security updated presentation
Updated Mvc Web security updated presentationUpdated Mvc Web security updated presentation
Updated Mvc Web security updated presentation
 
Web security leeds sharp dot netnotts
Web security leeds sharp dot netnottsWeb security leeds sharp dot netnotts
Web security leeds sharp dot netnotts
 
Design Patterns - LFM and POM
Design Patterns - LFM and POMDesign Patterns - LFM and POM
Design Patterns - LFM and POM
 
Web security presentation
Web security presentationWeb security presentation
Web security presentation
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 

Recently uploaded

Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 

Recently uploaded (20)

Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 

IoT on Raspberry PI v1.2

  • 1. IoT on Raspberry Pi John Staveley MVP 16/10/2021 https://uk.linkedin.com/in/johnstaveley/ @johnstaveley
  • 2. About Me  John Staveley MVP  IT Contractor in C#, Mvc, Sql Server, Angular and Azure  Organise LeedsSharp and IoTNorth etc  Used microcontrollers, Not an electronics expert!
  • 3. What we will cover  Programming with C# on a Raspberry Pi  Setup .Net 5  Control the things  GPIO, PWM, I2C  Control from the outside world  Azure IoTHub  Receiving updates from the device
  • 4. Hardware Overview  Raspberry Pi 4-b, Wifi, Camera port  GPIO, SPI, USB2/3, Ethernet, HDMI etc  MicroSD card and USB-C power  Meadow  .Net Nanoframework on ESP32
  • 5. Prepare for launch  USB-C Power supply (3A)  Noobs on MicroSD card  Screen (Micro-HDMI), Keyboard (USB 2/3), Mouse (USB 2/3)  Wifi (fixed IP)
  • 6. Basic Raspbian setup  Install .Net 5 https://www.petecodes.co.uk/install-and-use-microsoft-dot- net-5-with-the-raspberry-pi/  Install VS Code  Security settings
  • 7. Control the things  Digital Input/Output  PWM  I2C  Camera  Docs for C#: https://github.com/dotnet/iot  using System.Device.Gpio  using Iot.Device.Bindings
  • 10. Digital Output Code  Install-Package System.Device.IO
  • 11. Digital output examples  LED  Buzzer  Infrared LED  Laser  Relay  Multi-LED  … and lots more
  • 12. Electronics  Hardware recipes: https://gpiozero.readthedocs.io/e n/stable/recipes.html#led  Pull up/down  Anti-short  Anti back EMF diodes  Geekcreit 45 In 1 Sensor Module Board Starter Kits Upgrade Version For Arduino (Banggood £15)  https://images-eu.ssl-images- amazon.com/images/I/C1lrpIfADa S.pdf
  • 13. Azure IoT Hub  Free for < 8000 messages per day  Control hundreds of devices  Event Hubs  HTTP, AQMP, MQTT  Device Twins  IoT Edge  Setup:  Create IoTHub in Azure portal  Create device in portal  Set up a direct method
  • 15. Connecting device to Azure IoT Hub  Get DEVICE connection string from IoTHub DeviceClient _deviceClient = DeviceClient.CreateFromConnectionString(configuration.IoTHubConnect ionString); await _deviceClient.SetMethodHandlerAsync(“MyMethod”, ActionMethod, null); …. private static async Task<MethodResponse> ActionMethod(MethodRequest methodRequest, object userContext) { var data = methodRequest.DataAsJson; var controlAction = JsonConvert.DeserializeObject<ControlAction>(data);
  • 16. Development experience  Develop in Visual Studio  Publish to directory  Deployment: self-contained  Target runtime: linux-arm  Target framework: net5.0  Fixed IP  SFTP files using FileZilla  VNC  chown <user> <Directory or File> e.g. chown pi ./Control  chmod +rwx <Directory> e.g. chmod +rwx ./Control  ./<My dll name> e.g. ./Control
  • 17. Digital input examples  Push button  Reed switch  Magnetic sensor  Tilt switch  Ball switch  Knock sensor  Light blocking  Infrared receiver  Motion sensor
  • 19. Pulse-width Modulation Examples  Servos  Lamps/LED  Motors  Pumps  Fan  Display Dial  Audio effects https://www.youtube.com/watch?v=l4cuy1HOR3E  …and lots more
  • 21. PWM Code  Software PWM  Hardware PWM var _servo1 = new SoftwarePwmChannel(18, 400, 0.9, true); _servo1.Start(); _servo1.DutyCycle = 0; _servo1.DutyCycle = 50; _servo1.DutyCycle = 100;
  • 22. I2C Overview  Inter-Integrated Circuit (I2C)  Two wire communication  Pin 3, 5 and 27, 28  Short range, multiple devices  Enable on hardware  sudo apt-get install i2c-tools  sudo i2cdetect –y 1
  • 23. I2C Examples  Relay controller  PWM controller  Digital IO Expansion  LCD screen  Analogue inputs  GPS  RFID  Rotary encoder (Volume switch)  Temperature, Pressure, Humidity  Accelerometer  EEPROM
  • 24. Aside: Prototyping  Jumper cables (M-F, F-F)  Din rail mounting  Connector blocks  Breadboard  Totemmaker
  • 25. I2C Hardware – PWM controller
  • 27. Choosing hardware  https://shop.pimoroni.com  https://github.com/dotnet/iot/tree/ main/src/devices  No driver? Translate the I2C interface!
  • 28. I2C Relay Hat  Solenoids  High ampage lamps  Fireworks  …See code in project
  • 29. I2C Relay hat - code // Set relay 0 to 3, control Action 0 or 1 // Get relayNumber 0 to 3, returns either 0 or 1 … see code e.g. SetRelay
  • 30. Introducing Blazor  SPA Application framework  Server side  Push updates by SignalR
  • 31. Blazor – how it works
  • 32. Sending a message to Azure IoT Hub  Get SERVICE connection string ServiceClient _serviceClient = ServiceClient.CreateFromConnectionString(configuration.IoTHubConnec tionString); var deviceMethod = new CloudToDeviceMethod(“MyMethod”); var payload = JsonSerializer.Serialize(controlAction); deviceMethod.SetPayloadJson(payload); var result = await _serviceClient.InvokeDeviceMethodAsync(_deviceId, deviceMethod);
  • 33. DEMO Putting it together: Website controlling remote device
  • 36. Digital Input code int _inputPin = 22; System.Device.Gpio.GpioController _controller = new(); _controller.OpenPin(_inputPin, PinMode.Input); var inputResult = _controller.Read(_inputPin); Console.Log(inputResult); // High or Low
  • 37. Sending messages from the device  …to the event hub
  • 38. Event Hubs  Azure IoTHub is backed by an Event Hub  Scalable to millions of events per second  Kafka as a service  Supports AMQP, HTTPS and Apache Kafka
  • 39. Receiving messages from Event Hub  Messages can be routed to blob storage/service bus etc  IoTHub -> Message Routing -> Enable fallback route  Receive message from Event Hub
  • 40. Demo: Receiving events from device  Device started  Is alive  Button push
  • 41. Summary  You have the power using C# to control lots of types of hardware: I/O, PWM, I2C, Camera  Not everything you can buy can be controlled – yet!  Azure IoT Hub can be used to connect to and control your device from the internet and receive live events from it
  • 42. Get started resources  Starter kit: https://thepihut.com/products/r aspberry-pi-starter-kit  “How to” book: https://shop.pimoroni.com/produ cts/the-official-raspberry-pi- beginners-guide-4th-ed-uk  45 in 1 sensor pack: https://www.banggood.com/Gee kcreit-45-In-1-Sensor-Module- Board-Starter-Kits-Upgrade- Version-For-Arduino-UN0-R3- MEGA2560-Plastic-Bag-Package-p- 1137050.html
  • 43. Any Questions? @johnstaveley Demo code: https://github.com/johnstaveley/RaspberryPiControl Slides: https://www.slideshare.net/johnstaveley/iot-on-raspberry-pi Connect: https://uk.linkedin.com/in/johnstaveley/

Editor's Notes

  1. 3.5-5V and low ampage, use a relay to control greater power Do demo on board
  2. Deals with pull up/pull down, Back EMF diodes
  3. Emphasise this is not the only way of doing it DevOps is possible
  4. The main difference between a tilt switch and ball switch is speed, the mercury takes time to drop. Don’t use mercury in a child’s toy! A tilt ball switch can bounce if the movement is quick, use a latch in your software
  5. Enable Hardware PWM on raspberry pi 200 and 400 are Hertz values Do demo on device
  6. “Using the same device client you used before”