Hello,
In this project I show how nurses can receive updates when patients walk inside a room.
Currently nurses in hospitals and elderly care locations need to ask patients to wear a watch which they use to track people within the building. Here are some privacy concerns. The Walabot will easily fix this since no patient data will be asked or can be generated. The Walabot will detect if people walks inside a room and if a nurse is present; also can nurses receive notifications when a person enter or leaves a room.
I use the scenario with nurses since I work at a company where we make hardware for exactly this scenario: In some rooms patients may not enter. (for example in storage, computer rooms etc.) Nurses need to be aware if a patient is in a room where they aren't allowed.
That's why I use doctors and nurses in this project, but many scenarios can be used:
- Only let people enter when they are companied with a supervisor.
- Integration with smart-doors (that can be locked automatically) when a specific person want to get in/out.
- Count the number of people that arrive in a building (without counting the own staff of the company)
Sorry for vertical filming... :(
This project is based on the MQTT sample provided by Walabot. Their sample implementation of a MQTT server on the Raspberry Pi and Android application as a client. This sample project can be found on Github here: https://github.com/Walabot-Projects/WalabotMQTT
This project consists of 3 parts:
- 1. Raspberry Pi (with Walabot)
- 2 Android application
- 3. MQTT service
The flow of the Raspberry Pi code contains the following steps:
- Connect to Walabot
- Setup Walabot configuration
- Login on MQTT server
- Start scanning for persons
- When 'door movement' is detected:
---- 1: Generate Alarm (Turn on LED)
---- 2: Start bluetooth scanning
---- 3: Try to find any nearby 'known devices' (nurses)
---- 4: Send data (that contains the number of people, nurse presence and other information)
- Continu scanning
[TODO: Add code explanation, photos]
Android AppThe Android application does the following steps:
- if you're a nurse:
---- 1. enable bluetooth discovery
---- 2. Change the device's name so it contains 'nurse'
- Open the app
- Start communcation with MQTT server (manually click the start button)
- The output will now be showing the number of people in the room and if a nurse is nearby that room.
The datastring, received by the Application is in the following format:
{"energy": ["people:", 1, "#nurse:", "No", "#IP:", "192.168.0.126 192.168.0.125 ", "#version:", "1.2.0_b49aa759bf65888ffeb5cb4d08b237999cb0f4dd", "#"]}
This data is filtered to show the number of People, if a nurse is available, the IP address of the Raspberry and the Software version of the Walabot.
if (message.contains("people:")) {
TextView peopleCountstring =
(TextView)findViewById(R.id.NumberOfPeopleTextview);
peopleCountstring.setText(
message.substring(message.indexOf("people:\", ") + 12, // start substring
message.indexOf(",\"#"))); // end substring
}
[TODO: add Code, photo's, video if installing the application]
MQTT ServiceTo communicate with between both devices, different options have been explored. My first approach was to setup a Bluetooth communication between the Raspberry Pi and Android application, however this caused a lot of errors and took a lot of time to debug. Provided in the Walabot's Github their WalabotMQTT sample did me switch to this service and implementation. I'm not an expert on this part, but the documentation on the WalabotMQTT projectpage is well documented with steps to reproduce.
For the MQTT service cloudmqtt is used. This is a free service (although paid options with more support, an increased number of devices and faster connections are available) with an easy setup process.
Person CounterTo count the number of patients within their room I used the provided sample of WalabotThe People Counter sample is integrated in the main program of the MQTT program. Now when a person enters/leaves the room, new data will be send with the actual number of people inside the room.
This counter sample can be found on Walabot's Github: github.com/Walabot-Projects/Walabot-PeopleCounter
[TODO: Code explanation, draw image of how the Walabot scan's and which configuration is used]
Nurse Presence (Based on Bluetooth)Silence alarms when there is a nurse nearby. That is the functionality where bluetooth is used for. A patient doesn't require any hardware. Nurses require a phone with bluetooth enabled. (for nurses it is in theory not required to have the Walabot Android app installed in this scenario I've implemented).
In this way the patient doesn't have to worry any privacy or location tracking concerns. The nurse works at the place an her location-tracking based on her location (or at least the location of their phone).
If the number of persons on a room changes (both increases or decresase) a scan will be done on the Raspberry Pi to see if there is a nurse availabe within the room. The nurses can be scanned and detected through their mobiles ID (MAC address and Phone detection name). For example: the detected bluetooth name of my personal phone is: "FF:FF:FF:FF:FF:FF - Samsung S8 Marcel".
The Raspberry Pi can scan for available and nearby bluetooth devices. In this project the location will de determined if the phone (with a recognizable and known name) is found if it is detected by the Raspberry. This raspberry can link their found devices with it's position; in this way we know if the nurse is present in the room.
To scan and detect MAC addresses and device names from nearby devices, the following Python code is implemented:
import bluetooth
import time
while(1):
# search for bluetooth devices that are discoverable
nearby_devices = bluetooth.discover_devices()
for bdaddr in nearby_devices:
# loopup_name: this is the configured Device's name
print str(bluetooth.lookup_name(bdaddr))
# bdaddr: this is the found's device MAC address
print str(bdaddr)
# if the device's name contains the text "Nurse": Do something.
if "Nurse" in str(bluetooth.lookup_name( bdaddr )):
print "The Nurse is nearby the room!"
#action: Cancel the alarm
time.sleep(0.5)
Of course the 'if' statement can be changed to easily find a device based on their device name or MAC address. In this case only one specific device can be found. It is possible to set the Discovery name of a phone from multiple phones to "nurse's phone", so all the nurses can have access to a room.
Information flow diagram- Nurse present:
[ 1 ] In this case the bluetooth of my phone was on. [2] Someone enters the room. [ 3 ]. The raspberry Pi scanned for this specific device and found it. [ 4 ] It then sends a different command through the MQTT server to my phone (this is the output text on in the screenshot above).
- No nurse present
[ 1 ] Here I turned off bluetooth of my phone. [ 2 ] Someone enters the room. [ 3 ] The Raspberry Pi didn't found any known devices, so there weren't any 'nurses' nearby. [ 4 ] Then the send command didn't included the 'nurse presence'.
AlarmTo add some functionality, when a person enters/leaves the room an alarm will be generated (in my demo a LED will turn on). Only when a nurse is nearby the Alarm will be silenced (the LED wil turn off).
It's just a scenario how other services can react on movement within the room.
Android GUII provided the APK file in the download section below. Keep in mind that this is a debug-version. I've only tested the application on my two Android phone that are running Android 8.0.
If you want to simulate the 'nurse' capabilities change your Device name to a name that includes the text 'nurse'. Keep in mind that your device is not always discoverable. (on my private phones I need to have the Bluetooth settings page open to make my phone discoverable)
Connect a LED to GPIO port 19 on the Raspberry Pi.
Automaticaly statup the server code:
With the following steps the PersonCounter.py will be automatically started when booting the Raspberry.
- 1.
If you don't have a screen connected to the Raspberry, login through a VNC viewer. The Raspberry's IP address is shown on the Android application (if there is already a connection made)
Things to Be Done- Integrate push-notifications.
- Add users in a database: option in the Android application to add/remove users that have access.
- Make the range of bluetooth detection variable. This can be done based on the RSSI value of the wireless signal.
Comments