This project is a submission under Infineon's Connect Things with Code! contest. Radar was something I was very interested in, and seeing that an Arduino compatible radar was offered, I submitted a proposal to use the radar for activity detection and was thankfully chosen for free hardware (Bundle B).
In this article, I explain the need to detect the time a user is spent working and resting and how it could with analyzing and improving productivity. From there, I document how the creation a proof-of-concept of an embedded solution for productivity tracking.
After, I provide the full tutorial for getting started with the PSoC™ 62S2 Wi-Fi BT Pioneer Kit with the ModusToolBox software. I show how I configure its GPIO Pins to connect to the S2GO RADAR BGT60LTR11. From there, the presence of a user can be detected. I configured Microcontroller to send this data via UART to my computer and I wrote a custom script in python to read this data and save it.
A case was modelled via Fusion360 and 3D printed. I show the insights I have gained from recording my work and rest data and suggest ways on how this project can be further expanded. Lets get started!
Problem StatementI came upon this problem while I was studying. I realized that I had a habit of taking breaks and wondered how much of my time was actually spent studying. I could tell people I spent 2 hours of my time on a project, but how much of those 2 hours were spent doing meaningful work, and how much was spent walking around or lying in bed?
For some projects on the other hand, I could get absorbed and sit at my desk for more than an hour straight. But I realized that could leave me burnt out. I would suddenly feel really tired and feel like I needed a huge amount of time, maybe 20 minutes to even feel like I could even think again.
To me, it seems like I faced 2 opposite problems. Either I was spending too much time doing work in one sitting leading to burnout at the end, or I lacked the discipline to sit down and do work continuously. In both cases, I was less productive than I really wanted to be.
According to automatic Time Tracker DeskTime, their most productive 10% of users take effective breaks, by working for 52 minutes at a time and taking a break for 17 minutes. However, each person differs, and we might all have varying optimal times to work before our productivity sees a drop. Hence, there is a need to be able to record such data.
Components & IdeationGiven the problem statement, I decided to create an embedded solution to track my productivity.
Of course, the main sensor behind my embedded solution would be the S2GO RADAR BGT60LTR11 which was provided with the hardware bundle. Radar is the perfect sensor, because of its ability to track motion which can detect if someone is at his desk working, or has left his desk to take a break.
I decided to use the PSoC 62S2 Wi-Fi BT Pioneer Kit that was given with the free hardware, as there wasn't any documentation on integration. As of writing this article, only an Arduino Library was provided for interfacing with the Radar Sensor. Personally, I wanted to challenge myself by using the ModusToolbox to program the PSoC, as I had only worked with Arduino IDE in the past. Finally, although my competition submission did not use WiFi or Bluetooth, starting the project with the PSoC would allow me to add IoT capabilities in the future.
Another part of the project would be a 3D printed case. It would be necessary to test out different ways and locations of mounting the radar, for the best results.
Getting Started with Modus Tool BoxInfineon has provided documentation to install ModusToolbox and some tutorials.
- Infineon ModusToolbox Installation Guide
- Getting started with ModusToolbox
- ModusToolbox™ Software Training Level 1 Getting Started
After installing ModusToolbox, the next step is to create a project using project creator. The steps are well documented in the Getting started with ModusToolBox guide, but I will list the rough steps here.
- Open project creator
- Select the board. In my case, the board name is CY8CKIT-06S2-43012
- Select an example application. I used Hello World, which is the cleanest
- Note that you should select the Target IDE based on your preference and what you have already installed. I went with Eclipse IDE for ModusToolbox
- Then click create!
To compile and upload the program, connect your USB wire to J6. This connects it to KitProg which is used to program the board. Select the project and then click run.
A good practice is to look at the Quick Panel and check that you have selected the correct application as you might have multiple applications in the workspace. The panel should show the name of your project. In the case below, I have clearly selected "radar_gpio_test" as the project and clicking on the various icons will debug, run or build that project.
You can then upload and run the example code by clicking on the green arrow. Note that for a windows system, the build process is extremely long and this is normal. For my computer, it took around 3 to 4 minutes. I have raised this issue up in discord, and the best solution is to run ModusToolbox on Ubuntu, a mac of VM. As such, the project was quite time consuming due to the long build time.
I connected the PSoC to the PD and TD pins of the Radar. From the Radar Datasheet, the value at these pins tell us the direction of motion and presence of motion. Note that it is possible to communicate with the Radar Chip directly in SPI mode, but I could not find any existing resources on doing so. I managed to find the BFT60LTR11AIP MMIC User Guide, which documents the SPI interface for communicating with the radar, but due to time constraints, I decided to simply use the TD and PD pins. However, it would be challenging but also fulfilling to create a library to communicate with the chip in SPI mode, and it is a possible expansion of the current project.
According to the Radar schematic, the TD and PD pins are directly connected to the LEDs and are active low. Hence, in the code, we simply configure the pins as input pins, without any pull up or pull down.
cyhal_gpio_t RADAR_TD = P12_2; //D13
cyhal_gpio_t RADAR_PD = P12_1; //D12
//Configuration
result = cyhal_gpio_init(RADAR_TD, CYHAL_GPIO_DIR_INPUT,
CYHAL_GPIO_DRIVE_NONE, CYBSP_LED_STATE_OFF);
result = cyhal_gpio_init(RADAR_PD, CYHAL_GPIO_DIR_INPUT,
CYHAL_GPIO_DRIVE_NONE, CYBSP_LED_STATE_OFF);
I measured the dimensions of the radar PCB with a vernier callipers, modelled it in Fusion360 and designed a case around it. The STL and STEP files are provided below for anyone to 3D print or to modify. I used M3 screws to join the top and bottom part of the case, and also used it as a pivot, which allowed me to adjust the vertical viewing angle of the case.
This was then printed using a 3D printer and assembled.
The full software codes and instructions can be found on Github here and at the bottom of the page. I will also give a rough overview of my thought process in designing the software architecture.
In order to study the data over time, the PSoC was programmed to sample the Radar every 1s and send the TD and PD data over UART. I also wrote a python script to read the data, and save it to a CSV file for analysis.
AnalysisData was collected when I myself was doing work. The CSV Files were opened and analyzed in excel.
For this case, the radar was placed close to my keyboard. Hence the value fluctuated quite abit, as my wrists were not constantly moving. However, it seemed to be the most stable during my breaks, as there was zero motion. As such, when the TD value is HIGH for 10 or more seconds, we can assume that the user is taking a break and we can stop recording time spent on working.
I tested the positioning and angle of the Radar and found that I got the most accurate results when it was facing body part of high movement. When I was studying with pen and paper that was in front of me. When I was using the computer that the radar was just above my keyboard, and far enough to detect movement from both hands on the keyboad. The potentiometers were also tuned such that the user could be detected, but it did not detect other movements in the background.
This was an interesting and challenging project, where I got to handle both the embedded data collection and the 3d design of the case. It was my first time using ModusToolbox and designing a pivot mechanism.
The project can be expanded in many ways. I have set up a system to record and analyse data from the Shield2Go. An algorithm can be designed to detect the amount of time someone has been working. Additional peripherals can be used to alert the user to take a break, or he could retrieve a report about his productivity after a session.
Current solutions are mostly online, and track the time you spend on each app. However, a solution can be catered for offline work, and this solution can be used by students who desire to know more about their productivity and be informed when they should take a break to avoid burnout.
Comments