Hack N Roll 2022

🕒 2 min read

Once again, I attended the NUS Hack N Roll 2022, which is held virtually again (unfortunately) due to the COVID-19 Pandemic, which is still widespread across the world (and the number if cases are increasing exponentially too due to the highly transmissible Omicron variant). Nevertheless, it is still a hackathon with an open theme, similar to the previous editions. Without waiting any further, let’s explore what was created this year

Idea

For this year theme, I decided to go with a non contact way of interfacing with devices that displayed information. With that in mind, "The PSI" was conceptualize, which is an acronym that refers to "The Pollutant Standard Index Swiping Index" (aka PSI Swiping Interface, acronym in an acronym).

For this device, it would display the various aspects of the PSI values available from the National Environment Agency (NEA) API, and user would use corresponding gestures to change the information on the screen.

Prototype

For the prototype, there would be 3 main components that are required to accomplished the said functionality:

  • Micrcontroller: To process and handle the data from the API, and then show the relevant data according to the identified gestures. It would also need to be able to get the data from the internet.
  • Display: To show the PSI data to the user.
  • Gesture sensor: For interacting with the user interface of the display.

With that in mind, the following components were selected:

  • ESP32 Microcontroller
  • 1.44" TFT LCD screen
  • APDS9960 Gesture sensor

Gesture

As there are various data types collected from the different region of Singapore (for example, the 24h PSI, Particulate Matter 10 (PM10), etc), we would utilise the gestures to allow the user to select the data they are interested in. Henceforth, the following gesture scheme was implemented.

Gestures Action
Gesture Left / Gesture Right Switch between the different type of data available (24h PSI, PM10, PM2.5, S02)
Gesture Up Update/Pull the latest data
Gesture Down Switch between the different regions (National, North, South, East, West, Central)

The gestures could be summarised as follows:

                        Update data
                              ^
                              |
Switch between data type <- Sensor -> Switch between data type
                              |
                              V
            Switch between the different regions

Processing

The ESP32 will first establish a connection to a local router to enable internet access. Once connected, it will send an HTTP GET request to the NEA API endpoint to retrieve relevant data. Upon receiving a JSON response from the server, the ArduinoJson Library will be utilized to deserialize and parse the incoming data. The data would then be stored in a 2D array, which would be accessed with the specified index.

After the data is stored in the 2D array, the system will continuously monitor for input from a gesture sensor. When a gesture is detected, the index of the selected data will be updated accordingly. This change in index will update the display of the newly selected data, ensuring that the output is updated according to the user gesture.

Code

The code is available here: https://github.com/cyaninfinite/the-psi

Demo

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *