An IoT idea direct from my summer vacation in Florida. Real-time information from swimming pools in Dynamics 365 Business Central for a pool cleaning company business.
Lots of Microsoft Technology – D365BC, Azure IoT, VS Code with cool extensions, no hardware for IoT but PowerApps and Flow – Let’s see, what I used to setup this example.
Setup of Dynamics 365 Business Central
The pool cleaning company is a small business like each other service-oriented business. The company offers services to its customers. Dynamics 365 Business Central includes processes to support such service business. The functionality is currently included in the premium user experience.
To keep it simple, we can use following features:
- Customers, Vendors and Items
- Service Contracts, Service Items and Service Orders
- Invoices and … the power of Financials
Well, if this is more interesting to you, than contact me and my colleagues from COSMO CONSULT. In my case, I want to focus on the combination with IoT for this example.
Setup the IoT related Tasks
Where can IoT support the pool cleaning company? This question is much more interesting to me. Let`s look at the tasks and see what we have:
- Measure the water quality
- Detection of green edges or increased amounts of algae in the pool water
- Informing the pool cleaning service (urgent service) without calling the house owner
Water Quality and Pool Parameter
To measure something is a “home run” for IoT. There exist lots of sensors to measure pool parameters: temperature, pH, turbidity, Chloride, oxidation reduction potential (ORP) and others like water level and water flow of the pump system.
Setup and connect sensors to the IoT device and write a little program to send this information to an IoT Hub in Azure. Each device (the ID) needs to be attached to a monitored swimming pool and the Service Item in Dynamics 365 Business Central. This is a task for Modern Development / Microsoft AL (add new fields, tables and Pages) and extend the ERP System with an embedded App.
Green edges or the “Raise of the algae”
A little bit tricky and I`m not sure how to solve. I believe the detection of increased number of algae could be measured with the turbidity of the water. Another option is to analyze images of the pool with Artificial Intelligence to detect the green edges. If you have a better idea – contact me!
Call the Pool Service
The normal procedure is to inform the house owner. He calls the pool cleaning company and they schedule a service order. In real live, this procedure takes a lot of time. The house owner may have an ongoing problem with his pool and unsatisfied customers.
IoT devices provides a simple solution – buttons on the device. Each problem is represented by a button. If the house owner or guests detect such a problem, they can alert and send a defined code to the IoT Hub in Azure for e.g.:
- Green Edges
- Broken Heater / Pump
- Other Problems
First, I focus on collection of information. I need an IoT device with sensors. Than the device measure parameters and send this data to Azure. It’s a little bit like “IoT with MS Dynamics 365 Business Central on Azure“, but…
“Houston, we have an IoT problem!”
I have no pool here in Germany, I have no sensors for my IoT device, I can`t demonstrate my example. MISSION ABORT! – WHAT?!? – NO!!!
Simulation is the secret, I send specified messages to my IoT Hub and I can simulate my IoT devices.
Specify the IoT Device Data
Let’s keep it simple and define a simple structure of the IoT Device data as JSON. The data require a unique identifier for the device (later needed to identify the pool), a version for maintenance, maybe a GPS location and the measured parameters. An example is:
This scenario works also for sending action information to the IoT Hub. An additional parameter “Action” can be included instead of the measured parameters.
Setup and Simulate IoT Devices
- Azure IoT Toolkit can be used to setup the IoT Hub and IoT Devices. Finally, it`s perfect to monitor messages between devices and hubs (D2C / C2D) during development and testing.
- REST Client is great to send Http messages to the IoT Hub and simulate the IoT devices.
- If you have a suitable IoT Device with sensors, Arduino as VS Code extension helps to develop the code in VS Code.
I created the IoT Hub and attached some IoT Devices. Than, I defined test information for each device in a JSON file and copied these data into a special format for the REST Client extension to send a Http Message with curl to the IoT Hub. This is fine for development – but not sexy, not handy enough for demo.
Another IoT Device Simulator – PowerApp
“Hmm … a simple and portable User Interface for simulation and demo, where I can change the parameters and send the data to the IoT Hub?”
Let`s use a PowerApp!
The great thing about PowerApps is, you are so quick in writing and deploying an App! You can use lots of existing connectors, to consume or produce data in an App. The PowerApp is able to communicate with endpoints like Dynamics 365 Business Central. When needed, you have the option to add own custom connectors.
In my example, I need such a custom connector to send the simulated IoT data from PowerApp to IoT Hub.
Custom Connector – Azure Function as API
Technically, there is a Button in the PowerApp. By clicking on this button an event invokes a Flow, which uses the Custom Connector API to execute an Azure Function by Http-Trigger. Nothing really special!
Starting from behind. My function is written in C# and hosted in Azure with a App-Service-Plan (e.g. Consumption). The Visual Studio Code extension Azure Functions, provides the functionality to write and deploy the function to Azure.
An API definition (e.g. with Swagger) helps the PowerApp / Flow to transfer parameters to the Azure Function. This definition is used during the registration of the API in Azure.
As soon as the API is registered, the PowerApp can use a Flow to call the Azure Function. The simulated IoT Data of the selected “Pool Device” in the PowerApp are transfered to the IoT Hub.
Tested and Deployed – now I have a “Sexy” Pool Device Simulator on my Smartphone. Perfect for my next demo!
Business Insides from IoT in Dynamics 365 Business Central
It`s time to finalize the example. I showed the simulation of IoT Device data without the IoT Hardware in several ways. Once, I used Visual Studio Code to send handmade “Http-Messages” to the IoT Hub. As second option, I created a PowerApp as mobile “Pool Device Simulator”.
All simulated IoT information are processed as described in “IoT with MS Dynamics 365 Business Central on Azure” (by Azure Stream Analytics form IoT Hub to Azure Function and finally to a Dynamics 365 WebService). The Embedded App for Dynamics 365 written in Microsoft AL (a little bit of customizing the “Service Item Card”) shows the pool information in a factbox.
Finally, an added Page “IoT Pool Sensor List” helps the pool cleaning company to plan on-site maintenances. The last information of each swimming pool related to the active service contracts is presented. If water quality parameters are critical, a new Service Order can be scheduled direct from this page.
Yeah – we have IoT Insides! – What are the next steps?
This business can be analyzed and optimized in the future, when enough measured pool parameters and service contracts are available. Now, this “pool of Information” needs to grow. I consider continuing this example in the future…
Another interesting option is to automate this process. Using a Logic Apps to schedule Service Orders for on-site maintenances is possible now. Threshold violations of measured IoT parameters can be used to invoke this. Customer alerts, “Green Edges” or “Broken Heater”, fits also in this scenario. Sounds good for me.
Finally, an IoT Edge Devices at the swimming pool can control the pool heater and the pumping system to reduce the energy demand. The automated water treatment, system controlled be an IoT Edge Device, is also possible.
A good final question for me and my next example(s). Should I dive into Business Intelligence, Business Automation or Artificial Intelligence. What is most interesting – what do you think? Your feedback and proposals are welcome!