Everybody knows what an "escape room" is. You gather some friends, go to place where you will be locked up and then.. you have to find a way to escape What if.... instead of bringing the players to the game, we would bring the game to the players ? What if... the challenge would be to 'escape the pandemic" ?
This project aims to design and build a kit. The kit is used by people used to gather in a common (and usually crowded) place. Once deployed, players will monitor the place and help people to escape a potential risky situation.
There are 3 roles:
- The "Registrar" : it is located at the entry. It allows visitors to register themselves, in order to be notified later.
- The "Counter": its mission is to figure out how crowded the place is
- The "Sniffer": its mission is to measure CO2 levels and to figure out how "closed" the space is
Data is uploaded to AWS, along with metrics (local temperature,..) Participants will get notifications as well, like "run, go way, this is not a safe place !
Let's have a look under the hood:
- All items are based on the AWS Edukit. The initial configuration has been done by following the tutorials here
- The "Counter": an ultrasonic sensor (HR04) is connected to port B. It detects any object up to 5m and as close as 2cm. The best is to place it an angle (90 degrees), so you can count people intercepting the beam. People count is uploaded to to AWS (using Device Shadow). If count exceeds a threshold, a notification is sent to registered visitors.
- The "Sniffer": a CO2 sensor is connected to port C. Communication is based on UART protocol. Measurements are uploaded to AWS (using Device Shadow). If value exceeds a threshold, a notification is sent to registered visitors.
- The "Registrar" : a QR code is displayed on the panel at the entrance. Visitor scan the QR code using their smartphone and enter a web page (not implemented for this initial prototype, due to SNS SMS sandbox limitations) where they can enter their name and phone number. Once registered, they can be notified by text message any time later if something goes wrong.
Here are some rules: (there is absolutely no science backing this, this is just a demo)
- CO2 level over 1000 will trigger an immediate alarm but only if people count is > 0. CO2 level over 5000 will trigger an immediate alarm regardless of the people count
- As soon as people count is > 10, masks/noMasks are taken into account. An alarm is triggered when the proportion is "more than 20% without masks"
Measurements and user-input are captured on the device and sent to the Cloud. Then, decisions are taken (based on the data coming from all devices) and an action is triggered back to the device (if needed)
The "shadow" looks like:
- Temperature/ sound: not used but it was there, so I kept it, for future use
- PeopleCount : each time the beam is crossed, it increases by 1
- Emergency: turns into 1 when the button is pressed, 0 otherwise
- CO2 : as mesured by the CO2 sensor
- masks/noMasks values based on how many times the observer clicked on those choices
- mustEscape: when value is set to 1 (by the rules running on the Cloud), AWS Edukit is instructed to display an alarm message, buzz and to turn the LEDs red.
Start from the "Smart thermostat" code sample
People detection (see attached video)
Add support for GPIO based peripherals (i.e the ultrasonic sensor and the mushroom button)
- Add 2 components (ultrasonic and esp-idf_lib_helpers)
- Update the existing code to add the new measured values and to update the message sent to the back-end
- Update the code to implement a callback (similar to the hvac_Callback) that triggers when the "mustEscape" desired state changes. Turn the LEDs an Buzzer On/Off accordingly
CO2 measurement (see attached video)
Add support for Support UART based peripherals (i.e the CO2 meter). See the library here. Add that component to your project.
See here for a tutorial on science on CO2
- 350~450ppm: General outdoor environment
- 350~1000ppm：The air is fresh and breathing smooth
- 1000~2000ppm：The air was stagnant and feel asleep
- 5000ppm：Permissible exposure limit for an 8h work day
Manual crowd check (see attached video)
- Start from an image like the following one and resize the image to 320 by 240 pixels
- Convert it to a True Color C array using this tool
- Copy the masks.c file to your main folder and update your makefile to include it
- In a C file of your application declare the image as: LV_IMG_DECLARE(my_image_name);
- Load the image:
lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
See here for more information on the topic
On the Cloud side, data is gathered from the various connected devices. Each device has a digital twin ("shadow") with the most up-to-date data.
Then we have a model...
When there are more than 10 people in the room, we want to send an alarm to participants (Note: since we are using SNS SMS sandbox, it is limited to a number we hard coded but in a real system, people could register when then enter the monitored room)
This is our Model. There are two states (Idle/Alarm). Transition between the states is based on the "peopleCount" input parameter value
Here are the Actions triggered when we enter in "Alarm" state
And here is the notification on my smartphone
- People counting : a better solution should be to have 2 sensors at 1m distance to count people entering (i.e crossing beam #1 and then beam #2) and people leaving (i.e crossing beam #2 and then beam #1) the area.
- Fleet management: currently, the demo is based on two devices. If we had more devices, it would be better to leverage fleet management features
- A "snooze/cancel" button could make sense... Currently, the only way to get rid of an alarm is to restart the devices
- Text message: a custom format would be nicer..
- When you follow AWS instructions, you will be asked somewhere to start an app (menuconfig) to... configure things. For unknown reasons, arrows (up/down) do not work. It took me a while to figure out you have to use "j" and "k" keys instead. Counterintuitive, isn't?
- There is limited documentation on the "ports' (there are 3 ports on the AWS Edukit. Do not forget to "enable" them using menuconfig
- port A is located on the yellow part is is intended to connect I2C devices
- port B and C are on the black part. I used port B to connect generic GPIOs (like the HR-04 ultrasonic sensor or the mushroom button) and port C to connect UART device (the CO2 sensor)