As college students, we found that we spent a lot of our time in lines--whether it was the line at the dining hall entrance, in front of the squat rack, or into the big basketball game. While getting lost in some of these crowds is inevitable, a lot of frustration and waiting could have been avoided if we simply knew how congested these places were before we left our dorm rooms. If we had a way to monitor everyone on campus, we could figure out when to head to the gym, find the ideal quiet studying spot, and determine when to line up at our favorite campus eatery.

Of course monitoring everyone is not feasible--but perhaps we could get close. We decided that all we needed to do was monitor all of the doors going in and out of each of these places of interest. This would allow us to compute the population of our favorite places in real time -- and with this, help us plan our days better. Ideally, we would like to have something to the effect of placing a turnstile near each of these doors. However, conventional turnstiles are big and bulky, and no one likes having to walk through them everywhere they go. Was there a way to do this in a less intrusive manner?

We had previous experience using ultrasonic sensors and accelerometers in a biomedical devices laboratory in college, and we decided to combine these sensors into a more advanced occupancy sensor device. The Arduino 101 was simply the best device to develop on. The internal inertial motion unit, Bluetooth low-energy communications, I2C bus connectivity, Arduino community, and sensor module libraries all came together to produce a cohesive device for us.

What it does

Please refer to our GitHub repo README for all instructions.

An Ultrasonic Turnstile

Our device is an IoT ultrasonic turnstile that records the number of people in a building or room by detecting when people leave or enter. It uses a combination of sensors that, to our knowledge, has not been used simultaneously in this way. It allows us to help fight crowding and congestion in a non-invasive way, with no contact or interaction required by the people passing through. It also detects movement in an anonymous way and preserves the privacy of the people it detects.

Live Updating

Our current build of the device streams population data directly to a mobile application and web application. Within a second of sensing movement in a doorway, it updates those applications and visualizations immediately. The speed at which this data is transferred improves the ability for further development of the device and the services it provides without appreciably reducing the speed at which it can deliver those services. Furthermore, the Turnstyle can be used as a security feature if the door is unexpectedly opened -- perhaps outside of business hours. Turnstyle seeks to serve both building managers -- in the form of a mobile application they can use to manage and monitor their Turnstyle -- and the general public -- with a widely available web application -- by providing both with valuable real time data.

Powerful Analytics

Turnstyle provides live population monitoring, helping people make educated decisions about where to head in the current moment. It also provides aggregate measurements such as most popular times and general traffic trends to give people a general sense of how crowded places will be in the future. We hope that the analytics that Turnstyle has to offer will help us better plan as a society and allow us to lead more efficient lives. Just as people check the weather each morning, checking Turnstyle's data will encourage people to head to work at less busy times or eat at their favorite restaurants during slow hours -- saving us all from the pain of traffic jams, stalled roads, and wasted time.

How we built it

Turnstyle Unit

  • A magnetic contact switch is used in conjunction with the Arduino 101’s internal motion sensing to determine when the door opens.
  • The precise angle that the door makes with the wall is computed using the Madgwick Filter. When the door is opened beyond a threshold angle, the ultrasonic sensors on each side of the door start firing. Depending on which sensor detects motion first, the directionality of people travelling through can be determined.
  • The Arduino 101's internal BLE capabilities communicate with the mobile application.
  • The Serial output of the Turnstyle is sent into a Node.js server to plot the results in real time.
  • Any of these variables-- the threshold angle, the distance at which the ultrasonic sensors maximally operate, the directionality of traffic, can all be tuned to match the specific needs of each door.

Real Time Plotting

  • A Node.js server uses streams and plotly's streaming API to generate the plots in real time. It parses the population data from Turnstyle's serial output and creates the plots on the fly.

Mobile Application

  • Our mobile application is built using Evothings, a platform designed for creating IoT applications. Evothings allowed us to write applications that could be run on Android, iOS, and Windows Phone in pure HTML/CSS/JavaScript. We used Evothings's BLE libraries to allow the application to send and receive messages with the Arduino.

Challenges we ran into

  • We built an entire functional Android application on Android Studio, but it would only work for android 5.0 because of Bluetooth permission issues associated with 6.0+, so we had to scrap it and learn how to use Evothings in the span of two days
  • We hit the API stream limit multiple times (at least 5) on
  • Twelve-hour time zone difference caused difficulties in testing and collaborating - two of us were in a different country for an entire month.
  • Lots of difficulties getting Bluetooth to communicate in real time; we had no experience with it and had to learn a lot from the limited documentation.

Accomplishments that we're proud of

  • Using many features of the Intel Arduino 101 in our hack, including the built-in accelerometer, gyroscope, and Bluetooth modules. We really felt like we were getting the most out of the hardware.
  • Providing both an application and a web service for real time tracking and analyzing data - seeing how quickly our phones and computers responded to the Turnstyle was insanely satisfying.
  • Inertial motion units are accurate within several minutes from baseline but have a strong tendency to “drift,” causing the device’s reported motion to be much different from its actual motion. This is troublesome in the case of tracking an object over a long period of time, but we were able to cleverly navigate around this by using the magnetic contact switch to notify when a baseline position in space was met. That way, “drift” over time doesn’t affect the device’s measurement of the door’s motion as we reset the drift to 0 each time the door is closed.
  • Finishing without drinking any coffee

What we learned

  • Bluetooth is a lot more complicated than we initially gave it credit for -- we had to learn a lot about subscription models and UUIDs and the like. It was also extremely difficult to debug, and the most unexplainable issues are often best solved by resetting the Bluetooth on the phone.
  • Different versions of Android have different problems with Bluetooth -- we need to be more considerate of different versions of the same platform when developing future projects.
  • All of Evothings and! This was a great first experience with IoT, and we were surprised to see so many tools and technologies specifically designed for IoT projects.
  • Each of us also became better hackers in general; other than Arduino, there was not a single technology we used for this project that all of us have used before!

What's next for Turnstyle

  • The biggest feature we have yet to implement is support for multiple simultaneous Turnstyles. Since most large places have multiple doors, this is a very important feature. Right now, we could probably implement support for a couple devices at a time (using BLE communication protocols and streaming Node servers), but support for extremely large public spaces (think museums and monuments) would require engineering for scalability.
  • Building applications for specific use cases. For example, a building manager could have a monitor that tells them when to call in maintenance after a certain number of people have used the building, a more reliable metric for needing repairs as opposed to a regular time interval. Another example would be having a live update on specific websites of the number of people at a particular library, post office, or grocery store, so consumers can avoid long times and plan accordingly.
  • A better detection procedure would be helpful; although the population counting is quick robust and accurate, it can be fooled, especially if someone is trying to intentionally deceive the detector. A possible (but complicated) solution would be to use computer vision to identify faces, but this would defeat part of Turnstyle's purpose -- to be relatively cheap, mass-producible, and non-intrusive. We would like to look into finding a happy medium between sensor overkill and cost.
  • Creating alternate Turnstyles to accommodate different doors, such as sliding doors, revolving doors, or two-way doors. You would be surprised by how many different kinds of doors are out there.
+ 8 more
Share this project:


posted an update

8/3/2017: We now have a .apk Android application package file for ease of testing. It is identical to the application we initially released, but allows you to directly install the application on an Android device instead of having to use Evothings Studio. You can find it in the root directory of our GitHub repo!

Log in or sign up for Devpost to join the conversation.