Parking Space Management
Learn how to monitor parking space availability using simulated smart parking lots.
Finding a free parking spot when and where needed can be a real challenge, especially in large cities with sustained vehicular traffic. Not being able to easily find an available spot results in wasted time for drivers, increasing fuel consumption, CO2 emissions and traffic congestion.
Various software and hardware vendors are proposing integrated parking management solutions with the purpose of controlling and optimizing the use of parking spots. These solutions can be based on different types of sensors to detect parking space availability, for example ground sensors mounted at every parking spot, cameras attached to street lighting poles or tall buildings, and parking payment machines.
Beside the obvious advantages for drivers who are able to know if and where there are free spots in a given area at a given time, the availability of parking data in a central management system allows for other useful applications: detecting parking violations, analyzing and extracting patterns in parking space use, optimizing revenue from parking lots, etc.
This guide will demonstrate an example of how IoTIFY network simulator can be used to simulate parking lots that periodically send parking space availability data to a central server, and how these data can be displayed in an online dashboard.
We will use Losant to create a simple parking space monitoring application. From the home page of your Losant account, click on the Applications tab in the upper menu and then Create Application; in the next screen, choose an application name (for example “Parking”) and then click the Create Application button.
Any remote device communicating with the Losant server must be modeled in a Losant application, so that it is properly identified and the data it sends can be properly parsed. In our parking application, each device will cover a fixed number of parking spots, like for example a parking garage where cars are detected when entering and exiting the area. Let’s create first a device recipe that models a generic parking lot, then we will instantiate devices from the recipe. To create a new recipe, click on the Recipes tab in the application home page, then click the Add Recipe button. In the New Device Recipe screen, give a name to the recipe (for example, “Parking Lot”), and select the option “Set my own default names, tags and attributes”:
Click Create Recipe; next, in the DEVICE TYPE section select Standalone.
We want our simulated parking lot to send both fixed data such as its physical location and total number of parking spots, and dynamic data such the current number of available spots and the number of cars that entered and left the area since the last update. This information can be useful for a parking management solution not only to know how many spots are available at any given time, but also to analyze parking space usage patterns. Our Losant device recipe will model all this information in the form of attributes: in the DEVICE ATTRIBUTES section, define five attributes as shown in the following screenshot:
After saving the recipe, we can create devices from this recipe: click the Devices entry in the upper menu, then Add Device; in the New Device screen, select the Parking Lot recipe and click Create from Recipe, then choose a name for the device and click Save Device:
You can create additional devices from this recipe, to monitor multiple parking areas; in this example we will simulate two parking lots, and for this we need to create two Losant devices.
To define the authentication credentials needed by a simulated device to connect to the Losant platform, we need to create an access key. Refer to other articles in this section, such as the article describing a waste management application, for more information on how to create an access key.
To visualize graphically parking space usage data, we are going to set up a dashboard in Losant. From the home page of your Losant account, click the Dashboards item in the top menu, then click Create Dashboard; choose a name for your dashboard, then click again Create Dashboard.
Since each simulated parking lot sends its physical location coordinates, in our dashboard we insert a map where this location is shown. In the Add Block screen, click Customize in the GPS HISTORY block; in the block definition screen, select the Parking application, select “Last received data point” from the Duration drop-down list, select “DeviceRecipe=Parking Lot” from the “Device IDs/Tags” drop-down list, and then select the “location” attribute:
With the above settings, tha map will show the location of each parking lot that is sending data to the Losant application. In order to display additional information in a popup when a parking lot shown in the map is clicked by the user, we need to edit the popup template; to display the parking lot name, its total number of parking spots and the current number of free spots, insert the following content in the popup template:
Finally, click Add Block to add the map to the dashboard.
Among the various widgets offerd by Losant to populate a dashboard, there is the time series graph, which visualizes historical data coming from one or more devices; we can use this widget to monitor the usage of our simulated parking lots. From the dashboard page, click Add Block, then select the time series graph widget; in the block settings screen, insert the name of a simulated parking lot in the header text and select the Parking application, then select the time range and granularity of the graph:
Now we need to define what will actually be displayed in the graph; this is done by defining the contents of one or more segments in the dashboard block. For example, to insert in the graph the number of free spots in the parking lot, define a segment as in the following screenshot:
To add a visualizaton of the number of cars entering and leaving the parking lot, define two additional segments where the relevant attributes of the Losant device are selected, and add the segments to the graph.
Finally, add the graph to the dashboard by clicking the Add Block button.
If you want to simulate more parking lots, you can define additional graphs and add them to the dashboard in the same way.
Now we are going to create simulated parking lots in IoTIFY network simulator. As always, the behavior of a simulated device is defined by a template: to create a new template, go to the IoTIFY network tool, click on the Templates tab and then click Create new Template. In the template definition screen, insert a unique name, and select MQTT as network connection type; in the MQTT parameters section, select mqtt (TCP) as protocol, insert “broker.losant.com” as endpoint, and copy to the ClientID field the device ID of the first parking lot device you created in the previous steps in the Losant application:
In the Credentials section, insert a valid Losant access key in the Username field, and the corresponding access secret in the Password field:
In the MQTT message section, insert a string of the form “losant/<device_id>/state” (where “<device_id>” is the identifier of the Losant device) in the Topic field. The message contents field will contain the data our simulated parking lot is going to send to the Losant server; as required by the Losant API, the message contents must be formatted in JSON, may optionally contain a “time” attribute with the current time, and must contain an attribute named “d”, which includes the real data of interest, i.e. in our case the location of the parking area, the number of parking spots and other relevant information.
To create data that simulates the usage of the parking lot by drivers, we use the
chance.integer() random number generation function to generate the number of cars entering and leaving the area during the time interval between two successive updates sent by the parking lot, then adjust the number of free spots based on this. So our template will look like the following:
In the above text, our parking lot has a capacity of 150 spots, and simulates between 0 and 12 cars entering and between 0 and 10 cars exiting at each time interval (so the parking lot will tend to fill up with time, since the average number of cars entering will be slightly higher than the number of cars exiting).
Now, save the template and you are ready to start simulating a parking lot. If you created two or more devices in the Losant application and want to simulate them all, just create other similar templates in IoTIFY network simulator, keeping in mind that each template must use a different Losant device ID.
In our example we are going to simulate two parking lots, one with a capacity of 150 spots, and a larger one with 250 spots.
In IoTIFY network simulator, go to the Simulate tab, select a template representing a parking lot, select 1 as number of clients, and adjust the message repetition count and interval to your preferred values:
Hit the START GENERATION button and the simulated parking lot will start sending data to Losant.
To simulate a second parking lot, repeat the above procedure, this time selecting the template for the second lot.
Now that our simulated devices are running, we can go to the Losant dashboard we previously created and see the data coming from the parking lots:
When clicking on the icon for a parking lot in the map, a popup is shown, with information on the total number of spots and the currently available spots:
If we hover the mouse pointer over any time point in a time series graph, data received from the corresponding parking lot at that time is displayed:
You can play with different parking lot capacity values, or devise your own algorithm to model the behavior of drivers entering and exiting the parking area, for example taking into account the time of day and adjusting the number of cars accordingly; IoTIFY network simulator templates are fully customizable and allow writing arbitrary expressions to model complex scenarios.