Occupancy Detection & Visualization IoT Project

Leonard Wong
6 min readApr 10, 2021
Poster of Occupancy Detection and Visualization

Background

Hog: keep or use all of something for oneself in an unfair or selfish way

Hogging is a problem faced by anyone who provides resources for others to use. It is an undesirable behaviour in society when one decides to use the resources in an unintended way for its purposes. Some examples of such actions include reserving the table for revision but went out for hours instead of using the tables and seats, to buying all the foods and drinks despite not having the ability to finish. These actions are selfish and wasted resources that can use by others who need them.

Existing Problems & Solutions

At Singapore Management University’s (SMU) Li Ka Shing (LKS) Library, this is a troubling issue that the librarians and students face.

Hogging of seats deprive resources to students who need it

Some students came to the LKS library to reserved the seats for themselves and their friends, even though his/her friends might not be coming for the next several hours. Others leave their bags or items before attending their classes. Thus, providing them to the seats once their classes end. Others might leave their belongings and go out with their friends for hours. These are just some instances of how some students deprive the resources of others to benefit themselves.

To resolve these issues, some libraries use a camera to monitor the entire library. They will only take actions when the potential hogging of seats cause conflicts among students. However, such solutions can be costly, time-consuming and could lead to serious violation of individual privacy. We need to be able to deliver a solution that is about S$1/seat.

Violation of Safe Management Measures (SMM)

The other problem face by the campus is the violation of Safe Management Measures(SMM). As we are in a pandemic world, the government had been trying to contain the virus. In Singapore, the government had rolled out a slew of measures known as SMM. These measures include the mandatory of masks wearing, 1m safe distancing with one another, a maximum of 8pax per group among others. These measures aimed to ensure the safety and well being of the whole nation. In fact, due to these stringent measures and the fact that peoples are following them, Singapore had at most a couple of community infections per week. Violation of these SMM brings about risks of spread as the possibility of large cluster forming. Thus, everyone must follow it.

Currently, for a violation to be spotted and reported, it either relies upon a report from faculty members or students or surveillance by the campus appointed Safe Management Ambassador. But this is not an efficient way as violations may go unreported because Safe Management Ambassador couldn’t be at the scene as and when a violation happens. Moreover, faculty members or students might also opt not to report the violations.

Difficulties locating available seats across various level and zone

Finding an available seat had always been a pain point for students, especially during peak period like study week. With the implementations of SMM, the lack of seat was further exacerbated.

At the current stage, students have to repeatedly search every floor and zone to try to find an available seat for them to use. To make it worse, some of the seats are taken by hoggers and the students have no idea how long it had been in that situation. Officially, the library termed hogging as leaving unattended items for 1 hour. Therefore, students can make wild guesses and remove the items if they think they exceed that timing. However, they do not have the data to back them up if a conflict arises. As such, students tend to avoid hogged seats altogether. Ultimately, this leads to a time consuming and bad experience process.

Requirements & Constraints

Based on the problems and existing solutions detailed above, our team develop a set of requirements & constraints that our solution should be able to deliver.

  1. Non-invasive tools or systems to detect hogging behaviours in a more efficient way.
  2. Protect students’ health and safety
  3. An easy way to find suitable available seat(s)
  4. The tool or system should be non-invasive, in other words, camera should not be used except for initial testing
  5. The solution should be cheap and easy to deploy

System Design & Scenarios

To develop the system, we used these hardwares to kickstart our project

  1. Aluminium Foil
  2. MPR121 Proximity Capacitive Touch Sensor Controller
  3. Raspberry Pi 3 Model B+ or Raspberry Pi Zero WH

How are the hardware connected

Disclaimer: As I did not write the algorithm for the sensor to do the calculations, but made modifications to the code to get it to work for the UI. I had an NDA* with the developer that prevent me and my team to share the code publicly or describe in details on how everything works. But I will be able to briefly describe how we connect the hardware together and will be able to open source the code I had written for the UI portion in the references section. (It’s nothing much to be honest)

*We didn’t actually sign an NDA document but a promise is just as important to us.

The hardware are quite straightforward to setup. Once you set it up, it is really easy to repeat the process multiples times.

To begin, solder the pins that came with each MPR121. This is to ensure a snug fit and to prevent having to do the pins connection every time. Upon completion, we will move to Raspberry Pi 3 Model B+. Raspberry Pi 3 Model B+ is way overkill for what we are doing. A cheaper and just as capable alternative Raspberry Pi Zero WH would be more than enough. But we will be using Raspberry Pi 3 Model B+ as that’s what we have.

Tip: Get the Headers version so you don’t need to do soldering on the Raspberry Pi too!

Install Raspberry Pi OS, do the necessary updates that is required for inital setup & configuration such as

sudo apt-get update && sudo apt-get upgrade -y
sudo raspi-config

Thereafter, enable SSH & GPIO. There are literally too many guides on how to do these configurations on the internet. Thus, I will skip them.

The connection between MPR121 & Raspberry Pi are straightforward though need to be careful to prevent shorting the MPR121, said the author who shorted 2 MPR121. Oops🤭

There are 6 pins on 1 side of MPR121 & another 12 pins on the other side.
To connect between MPR121 to Raspberry Pi, you need 4 Female-to-Female Jumper Wire. The pins that should be connected are GND (Ground), SDA, SCL & 3.3V.
Each of these pins should connect to the same connection on Raspberry Pi.

Raspberry 3 Model B+ GPIO Layout

As mentioned above, be careful on the connections as it can potentially short the MPR121.

Lastly, for the 12 pins on the other side of MPR121, each pin can be represented as 1 seat. As such, each MPR121 can track up to 12 seats.
Cut 1 end of the jumper wire to expose some of the copper wire. Then, use masking tape to tape it on a sheet of aluminium foil. Connect the other end of jumper wire to MPR121. Repeat the process up to 12 times.
Run the code and that’s all!

Based on how the users use the seat, the data will be computed by Raspberry Pi. If there are any changes to the occupant status, it will update the database & dtweet.io and this will relay to the dashboard or send SMS accordingly, depending on the scenarios. User will also be able to query on the availability of seat more easily.

Conclusion

To conclude, the team had an invaluable insight and experience to the world of IOT and how it can be used to solve real world problems. Personally, I also learnt a lot on how to use and troubleshoot the GPIO and did my first few soldering, though still trying to not scald myself in the process. Overall, I am glad I took on this project despite its challenges.

--

--

Leonard Wong

SMU Final🎓 | Tech Technologist👨🏻‍💻 | Developer⚒ | (Un)qualified Analyst for everything🤷🏻‍♂️ | Writings are my own opinion😬