IoT Parking Lot Demo on Toradex Modules

16
IoT Parking Lot Demo on Toradex Modules

description

Read our blog which describes our IoT parking lot demo and the technology behind it. We will also tell you how to use Azure IoT Hub to send messages between Azure services and devices to achieve the same level of communication we had in our demo. You will learn about the different modules we have used in our demo and how to develop simple applications using Azure IoT Hub.

Transcript of IoT Parking Lot Demo on Toradex Modules

Page 1: IoT Parking Lot Demo on Toradex Modules

IoT Parking Lot Demo on Toradex Modules

Page 2: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 2June’16

CHAIRMANIntroduction

In this blog post, I am going to talk about our IoT parking lot demo

and the technology behind it. I will try to explain how to use Azure IoT

Hub to send messages between Azure services and devices to achieve

the same level of communication we had in our demo. I will also quickly try to explain all

the different modules we used in our demo, but my samples will focus on Azure IoT Hub

and how to easily send and receive messages. If you are interested in knowing more

about Azure IoT Hub, you can check the details here.

Page 3: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 04/29/2023 3

In our demo, we have used multiple devices, namely:

• Parking Lot 1 (called Stretnor in our demo)

• Parking Lot 2 (called Theater Parkhouse in our demo)

• Public Display (Parking Lot independent device)

Every parking lot consists of more than one of the following devices:

• Gate Controller (Colibri T30 running Win10 IoT)

• Parking Controller (Colibri VF50 running Windows Embedded Compact 2013)

• Payment Terminal (Apalis iMX6 running Linux and Qt)

• Public Display (Colibri iMX6 running Windows Embedded Compact 2013)

Page 4: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 04/29/2023 4

Page 5: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 5June’16

CHAIRMANAs you can see in the above image, all the communication messages go

through the Azure IoT Hub to the application service that processes these

messages. You can also see that we have a web page and database running in

Azure but this blog post focuses only on the part about Azure IoT Hub.

Message flow in IoT Parking demo

There are two basic events that trigger the flow of information between

devices and IoT Hub.

The first event is when a car arrives at the gate (refer the diagram below):

Page 6: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 6June’16

CHAIRMAN

Page 7: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 7June’16

CHAIRMAN

When a car arrives to the gate, the gate controller will scan the license plate and send a

message to IoT Hub (1). After the application service verifies the data, it will send the

message back to Gate Controller to open the gate (2). At the same time, a message is

sent to the Parking Controller with the number of assigned parking spaces (3). The

Parking Controller will start blinking the Red light indicating that the parking space is

going to be occupied soon. The message is sent also to the Payment Terminal. This

message includes the license plate number and time of arrival (4). At the same time,

the Public Display receives the information about all the parking spaces in the area

(5).

When the car is parked at the parking space, the Parking Controller stops blinking the

Red light and sends a message to the IoT Hub indicating that car is parked (6). At the

same time, the Gate Controller is informed to close the gate (7).

Page 8: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 8June’16

CHAIRMAN

Page 9: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 9June’16

CHAIRMAN

When a car leaves the parking lot, the driver has to pay the parking charges first. On

the Payment Terminal, a person can select the appropriate license plate of their car

and select pay. A message is then sent to the IoT Hub initiating a request of payment

(1). Application service calculates the price and sends it back to the Payment

Terminal (2). When the Payment Terminal receives the payment credit, it sends the

information to the IoT Hub that the payment was successful (3). Application service

will than send a message to the Parking Controller that the car is about to be

removed from the parking lot (4). The Parking Controller starts blinking the Green

light. After the car is removed from the parking space, a message is sent to the IoT

Hub indicating the removal of car (5). The Parking Controller also opens the gate to

exit. After a timeout value, the gate is closed again and a message is sent to the IoT

Hub that the parking space is now free. After this, the Public Display again shows

the updated information on all the parking lots (6).

Page 10: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 10May’16

CHAIRMAN

Sample application

In the following sample application, I will try and show to you how to

communicate with the Azure IoT Hub easily. To understand this sample you need

a basic understanding of C#. If you want to build the application, you will need

Visual Studio 2015.

To run the example, you will also need an Azure account. You will need to create

a free Azure IoT Hub and create a device on your Azure IoT Hub. You can use the

device explorer to do this. Device explorer documentation can be found here.

Here I am going to show you a small example of a server-side application that

takes messages from the IoT Hub and processes them. This code is really simple

and is not meant for the production environment.

Page 11: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 11May’16

It is only to show you how easy it is to communicate with the Azure IoT Hub. In this

example, we only receive the message from the device and send new messages back

to the same device.

You will have to modify the server-side code with your connection string.

As you can see in my sample, I have only called the method connect of the class TDXServerEmulator

Page 12: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 12May’16

CHAIRMAN

This will take care of receiving and responding to messages.

To use the clients, you need to replace the URL to Azure IoT Hub with your URL.

Device.cs.

Inside your client you need to create a new Device object and register the

OnMessageReceived event. This will allow you to get all the messages sent from the

Azure IoT Hub to your device.

Page 13: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 13May’16

CHAIRMAN

After this, you will be able to run the demo project. After you’ve executed the

project, two console applications will appear. You have to wait for the server

application to be ready for connection

Page 14: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 14May’16

CHAIRMANAfter the server is ready, you can select “Send Hi” from the client application.

In the image above, you can see the client sending “Hi”. After the server received the

message from client, it responds with the following message, “Hi from IoT Hub”.

Page 15: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 15May’16

CHAIRMAN

As you can see in my sample, it is really easy to communicate with the Azure IoT

Hub and send simple messages. For more complex applications, there are many

things that can be improved but that also makes the sample application more

complex.

With this sample and explanation, you should be able to develop simple

applications using Azure IoT Hub. Also all Toradex modules support Azure IoT

Hub. You can read more about the type of support offered by the Toradex modules

here. You can also download SDKs for WinCE and Linux.

Page 16: IoT Parking Lot Demo on Toradex Modules

|www.toradex.com Toradex® is a registered trademark of Montadex GmbH 16May’16

Thank you!