Use Case
My project is separated in three different location, which are typical for a domestic garden. Each location has different scenarios where some actions are triggered according to the presence of different agents. The agents are: an adult, a child, a postman, an autonomous car, a cat and a dog. The following scenarios have been implemented.
Scenario 1
In the first scenario I want to model a smart light outdoor system. Depending on the agent, which is present at the terrace the lighting scheme will change accordingly. The terrace will be equipped with a RFID-Sensor to read the corresponding tag of an agent. The sensor will send their data to an Arduino board, which will trigger the appropriate reaction. On the terrace five agents can be present: An adult, a child, a dog, a cat and a postman, each represented by a unique tag. Following rules apply to the lighting system:
- If the adult or the child is alone at the terrace the green light is turned on.
- If the cat or the dog is alone at the terrace the yellow light is turned on.
- If the postman is alone at the terrace the red light is turned on and an SMS is send to the owners Smartphone.
- All other scenarios won’t invoke any action.
Scenario 2
The second scenario is modelling a smart driveway of a house. The driveway will consist of two RFID-Sensors to be able to recognize tow agents at the same time on the driveway. The data will be again received by the Arduino board which will send SMS to a mobile phone to inform the owner about the current situation on the driveway. On the driveway all six agents can interact with each other, therefore following rules can be triggered:
- If the car is not present on the driveway and an adult, a child, a dog or a cat is on the driveway no action is triggered.
- If the postman is at the driveway an SMS should be send to inform the owner that the post is arriving.
- If the car is standing at the driveway and a child, a dog or a cat is blocking the garage a SMS will be send to the owner containing information which agent is blocking the garage
- If the car is in front of the garage a SMS will be send to the owner to inform him, that the car has parked successfully.
- In all other cases no action will be triggered.
Scenario 3
The last scenario will focus on access management for a swimming-pool. The pool will also be equipped with a RFID-Sensor. The pool will manage access control for five agents like the terrace since I can assume that the car will never be at this place. The pool should have a small closing mechanism. The closing mechanics will adhere to following rules:
- The pool opens when the adult (owner of the house) is there.
- The pool will keep on being closed for all other agents.
- If the pool is opened it will close when a postman, a cat, a child or a dog is at the pool.
- In all other cases no action will be triggered.
Experiment
To implement my scenarios, I needed to connect different modules to my Arduino board. I used following modules:
- 4 RC522 RFID Sensors
- Stepper Motor 28BYJ-48 + Driver Platine ULN2003 Modul
- SIM900 GPRS/gsm Shield Development Board Quad-Band Module with Antenna
- 3 LED in different colour
- 5V power supply that can provide 2A
In the following pictures you can be seen how the modules can be connected to an Arduino Uno:

Source: https://circuits4you.com/2018/10/03/interfacing-of-rfid-rc522-with-arduino-uno/

Source:http://osoyoo.com/2017/07/10/arduino-lesson-stepper-motor/

Source:https://randomnerdtutorials.com/sim900-gsm-gprs-shield-arduino/
After having the hardware all ready and connected to the Arduino I needed a rule engine to evaluate the input from the sensors. During my research I found the possibility to let Prolog communicate with an Arduino board. Unfortunately, the library was hard to install on a Windows operating system, hence I decided to use Java with the Drools plugin. Drools provides a core Business Rule Engine, which can be used to evaluate rules based on different input. To accomplish the communication between the Arduino Board and the Drool engine, running on Java, I used the serial port to exchange data. The communication process starts with the Arduino receiving date from a RFID sensor which is currently reading a tag. Depending from which sensor the data was sent the micro controller sends a string containing the object name and agent name to the java program. The program fetches all incoming data with the help of an event listener and forwards the input to the rule engine. The rule engine processes the input and writes an integer to the serial port, which the microcontroller reads and triggers the appropriate action.
In the last step I used ADOxx to create a model of the environment to show live what happens in the garden. The interaction between the java program ADOxx was quite cumbersome and was solved over an small REST API. The Java program sends PUT-Request to the endpoint to update the incoming date which it is receiving from the microcontroller. I then used AdoScript to update my model with GET-Requests.
Results
As we can see in the Video the rule engine evaluates different agents and objects and triggers different actions. The experiment was a success in general, however there is room for improvement.
First, as it is seen the microcontroller can’t really determine how long an agent is on an object. Therefore, I programmed a time out which is triggered when no data is received for 10 seconds. The only way of determining the duration of an agent with a RFID sensor is constantly reading the UID of the tag. When the tag is not available anymore it can be assumed that the agent is gone. The crucial problem with this approach is that one reader will block the whole microcontroller CPU and no other reader can take in action. The solution would be multithreading, which is not supported by the Arduino Uno since it only has one core. My recommendation to solve this problem would be a better microcontroller. In general should future work concentrate on the thread management of all component so that no data will be lost.
The next point would be the ADOxx model. The model should be improved to not only received data rather it should also provide data for the rule engine which can’t be measured with the connected sensors. One example would be defining specific daytimes in the model when the pool should be accessible. In general, the model should enable the user to decide with different object which services should be provided in the garden.