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.

1. Set up a Losant application

We will use Losant to create a simple parking space monitoring application. From the home page of your Losant account, click the Applications button on the left bar, then select Add 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 Device Recipes from the left menu in the application home page, then click the Add Device 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 left 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.

2. Set up a Losant dashboard

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 left menu, then click Add Dashboard; choose a name for your dashboard, select "Parking" as the owner application, then click 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 “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, the 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:

{{format deviceName}}

Capacity: {{format data.parking_spots}}

Free spots: {{format data.free_spots}}

Finally, click Add Block to add the map to the dashboard.

Among the various widgets offered 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:

In the Duration section, select the duration and resolution 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 visualization 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.

3. Create IoTIFY network simulator templates

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 simulator, click on the Templates tab and then click New Template. In the new template screen, select MQTT(S) as connection protocol, insert a unique name for the template, and click on CREATE; in the template editor screen, in the MQTT parameters section, select mqtt (TCP) as protocol, insert “” as endpoint URL, insert a string of the form “losant/<device_id>/state” (where “<device_id>” is the identifier of the first parking lot device you created in the previous steps in the Losant application) in the Topic field, and copy the device ID to the ClientID field:

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 next section, 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 using 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 message contents will look like the following:


  if (state.capacity === undefined){
    state.capacity = 150; = state.capacity;
  var myret = {};
  myret.time = { "$date" : };
  var entering = chance.integer({min: 0, max: 12});
  var leaving = chance.integer({min: 0, max: 10}); = - entering + leaving;

  if ( < 0 )  = 0;
  if ( > state.capacity )  = state.capacity; = {
    location: "48.1353, 11.5819",
    parking_spots: state.capacity,
    cars_entering: entering,
    cars_leaving: leaving,
  return JSON.stringify(myret, null, 2);

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.

4. Simulate a smart parking system and see it in action

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 number of iterations and the gap between iterations to your preferred values:

Hit the START SIMULATION 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.

Last updated