The story of a Korean student who received an award from the Ministry for the queue monitoring system

When I was in elementary school in high school (from March to December 2016), I was very annoyed by the situation that developed in our school cafeteria.

Problem One: Too Long Waiting Time in Queue

What problem am I seeing? Like this one:

The story of a Korean student who received an award from the Ministry for the queue monitoring system

A lot of students accumulated at the distribution and they had to stand for a long time (five to ten minutes). Of course, this is a common problem and a fair service pattern: the later you arrive, the later you will be served. So you could understand why you have to wait.

Problem two: unequal conditions for those waiting

But, of course, that's not all, I had to observe another, more serious problem. So serious that I finally decided to try to find a way out. High school students (that is, everyone who studies at least a grade higher) and teachers went to the distribution without a queue. Yes, yes, and you, as a primary school student, could not tell them anything. Our school had a pretty strict policy regarding the relationship between classes.

So my friends and I, while we were freshmen, were the very first to come to the cafeteria, we were about to get food - and then high school students or teachers would appear and simply push us away (some, who were kinder, let us stay in our place in line). We had to wait an extra fifteen or twenty minutes, although we arrived earlier than everyone else.

We had a particularly bad time at lunchtime. During the day, absolutely everyone (teachers, students, staff) rushed to the canteen, so we, as elementary school students, never enjoyed lunch.

Usual ways to solve the problem

But, since the newcomers had no choice, we came up with two ways to reduce the risk of being thrown to the back of the line. The first is to come to the dining room very early (that is, literally before the food even starts to be served). The second is to specifically kill time for ping-pong or basketball and come with a big delay (XNUMX minutes after the start of lunch).

To some extent it worked. But, to be honest, no one was eager to rush as fast as he could to the dining room just to be able to eat, or to finish the cold leftovers after the others, because he was among the last. We needed a solution that would let us know when there are few people in the dining room.

It would be great if some fortune-teller predicted the future for us and told us exactly when to go to the dining room so that we would not have to wait long. The trouble was that every day everything turned out differently. We couldn't just analyze patterns and find the best moment. We had only one way to find out how things were in the dining room - to walk there on our feet, and the path could be several hundred meters, depending on where you were. So if you come, look at the line, come back and continue like this until it gets short, you will lose a lot of time. In general, the life of the elementary class was disgusting, and there was nothing to be done about it.

Eureka - the idea of ​​​​creating a Dining Room Monitoring System

And suddenly, already in the next academic year (2017), I said to myself: β€œWhat if we make a system that will show the length of the queue in real time (that is, identify the β€œtraffic jam”)?”. If I succeeded, the picture would be like this: elementary school students would simply glance at the phone to get up-to-date data on the current level of workload, and would conclude whether it makes sense for them to go now.

Essentially, this scheme smoothed out inequalities through access to information. With its help, younger students could choose for themselves how best to act - to go and stand in line (if it is not too long) or to spend time with greater benefit, and later choose a more opportune moment. I was very excited by this thought.

Dining Room Monitoring System Design

In September 2017, I had to submit a project for an object-oriented programming course, and I declared this system as my project.

The story of a Korean student who received an award from the Ministry for the queue monitoring system

Initial System Plan (September 2017)

Equipment selection (October 2017)

The story of a Korean student who received an award from the Ministry for the queue monitoring system

A simple tactile switch with a pull-up resistor. Scheme with five shields in three rows to recognize the queue in three lines

I ordered only fifty membrane switches, a Wemos D1 mini board based on ESP8266, and several ring clips, to which I planned to attach enameled wires.

Prototyping and development (October 2017)

I started with a breadboard - I built a circuit on it and tested it. I was limited in the amount of materials, so I limited myself to a system with five footboards.

For software that I wrote in C++, I set the following goals:

  1. Work continuously and send data only during those periods when food is served (breakfast, lunch, dinner, afternoon tea).
  2. Recognize the situation with the queue / traffic jams in the canteen at such frequencies that the data can then be used in machine learning models (say, 10 Hz).
  3. Send data to the server in an efficient manner (packet size should be small) and at short intervals.

To achieve them I had to do the following:

  1. Use the RTC (Real Time Clock) module to continuously monitor the time and determine when food is served in the dining room.
  2. Use a data compression method to write the state of the shield in one character. Considering the data as a XNUMX-bit binary code, I mapped the various values ​​to ASCII characters so that they represented data items.
  3. Use ThingSpeak (IoT tool for analytics and online charting) by sending HTTP requests using the POST method.

Of course, there were some bugs. For example, I did not know that the sizeof( ) operator returns 4 for a char * object, and not the length of a string (because it is not an array and, accordingly, the compiler does not calculate the length) and I was very surprised why my HTTP requests contained only four characters from the entire URL!

Also, I left out the parentheses at the #define stage, and this led to unexpected results. Well, let's say:

#define _A    2 * 5 
int a = _A / 3;

Here one would expect that A would be equal to 3 (10 / 3 \u3d 2), but in fact it was calculated differently: 2 (5 * 3 / 2 \uXNUMXd XNUMX).

Finally, another noteworthy bug I've dealt with is Reset on the watchdog timer. I struggled with this problem for a very long time. As it turned out later, I was trying to access the low-level registry on the ESP8266 chip in the wrong way (by mistake I wrote the NULL value for the pointer to the structure).

The story of a Korean student who received an award from the Ministry for the queue monitoring system

A footboard that I designed and assembled. At the time the picture was taken, he had already experienced five weeks of trampling

Hardware (pedestals)

In order for the shields to be able to survive the harsh canteen conditions, I set the following requirements for them:

  • Shields must be strong enough to support human weight at all times.
  • Shields should be thin so as not to interfere with people in line.
  • The switch must necessarily work when stepped on.
  • Shields must be waterproof. The dining room is always damp.

To meet these requirements, I settled on a design with a two-layer structure - laser-cut acrylic went to the base and top cover, and I used cork as a protective layer.

I made the shield layout in AutoCAD; dimensions - 400 by 400 millimeters.

The story of a Korean student who received an award from the Ministry for the queue monitoring system

On the left is the design that went to work. On the right is an option with a Lego type connection

By the way, I eventually abandoned the right design because with such a fixation system it turned out that there should be 40 centimeters between the shields, which means that I could not cover the required distance (more than ten meters).

The story of a Korean student who received an award from the Ministry for the queue monitoring system

The story of a Korean student who received an award from the Ministry for the queue monitoring system

To connect all the switches, I used enameled wires - they took more than 70 meters in total! I placed a membrane switch in the center of each shield. Two clips protruded from the side slots - to the left and to the right of the switch.

Well, for waterproofing, I used electrical tape. Lots of electrical tape.

And it all worked!

November XNUMXth to December XNUMXth

The story of a Korean student who received an award from the Ministry for the queue monitoring system

Photo of the system - all five shields are visible here. On the left is the electronics (D1-mini / Bluetooth / RTC)

On November XNUMX at XNUMX am (breakfast time), the system began to collect up-to-date data on the situation in the dining room. I couldn't believe my eyes. Just a mere two months ago, I was sketching out the outline while sitting at home in my pajamas, and lo and behold, the whole system works without a hitch...or not.

Software bugs during the testing period

Of course, there were enough bugs in the system. Here are the ones I remember.

The program did not check for available Wi-Fi points when trying to connect a client to the ThingSpeak API. To fix the error, I added a Wi-Fi availability check as an additional step.

In the setup function, I constantly called β€œWiFi.begin” until a connection appeared. Later I found out that the connection is established by the ESP8266 firmware, and the begin function is used only when setting up Wi-Fi. I corrected the situation by calling the function only once, during the setup.

I found that the command line interface I created (it was designed to set the time, change network settings) does not work at rest (that is, outside of breakfast, lunch, dinner and afternoon tea). I also saw that when no logging occurs, the internal loop speeds up excessively and the serial data is read too quickly. Therefore, I set a delay so that the system waits for additional commands to arrive when they are expected.

Ode to the watchdog

Oh, and after that about that problem with the watchdog timer - I solved it at the stage of testing in the "field" conditions. Without exaggeration, this was all I thought about for four days. Every break (lasting ten minutes) I rushed to the cafeteria just to try out the new version of the code. And when the distribution opened, I sat on the floor for an hour, trying to catch a bug. I didn't even think about food! Thanks for all the good things, ESP8266 watchdog!

How I figured out WDT

The story of a Korean student who received an award from the Ministry for the queue monitoring system

The code snippet I've been working on

I found a program, or rather an extension for Arduino, that analyzes the data structure of the software when a Wdt-reset occurs, referring to the ELF file of the compiled code (correlations between functions and pointers). When this was done, it turned out that the error can be fixed as follows:

The story of a Korean student who received an award from the Ministry for the queue monitoring system

Damn it! Well, who knew that fixing bugs in a real-time system is so difficult! However, I removed the bug, and it turned out to be a dumb bug. Out of inexperience, I wrote a while loop, in which the array was out of bounds. Phew! (index++ and ++index are two big differences).

The story of a Korean student who received an award from the Ministry for the queue monitoring system

Hardware issues in testing

Of course, the equipment, that is, foot shields, was far from ideal. As expected, one of the switches stuck.

The story of a Korean student who received an award from the Ministry for the queue monitoring system

On the seventh of November, during lunch, the switch on the third shield stuck

Above, I have provided a screenshot of an online chart from the ThingSpeak website. As you can see, around 12:25 something like this happened, after which shield number three went down. As a result, the queue length was defined as 3 (the value is 3 * 100), even when in fact it did not reach the third shield. The fix was that I added more padding (yes, duct tape) to give the switch more room.

Sometimes my system was literally uprooted when the wire clung to the door. Trolleys were brought into the dining room through this door and packages were brought in, so that it dragged the wire behind it, closing itself, and pulled it out of the socket. In such cases, I noticed an unexpected failure in the flow of data and guessed that the system was disconnected from the power source.

Dissemination of information about the system throughout the school

As already mentioned, I used the ThingSpeak API, which visualizes data on the site in the form of graphs, which is very convenient. In general, I, in fact, just threw a link to my schedule to the school group on Facebook (I searched for this post for half an hour and did not find it - very strange). But then I found a post on my Band, the school community, dated November 2017, XNUMX:

The story of a Korean student who received an award from the Ministry for the queue monitoring system

The story of a Korean student who received an award from the Ministry for the queue monitoring system

The reaction was wild!

I posted these posts to spark interest in my project. However, even just looking at them in itself is quite entertaining. Let's say here you can clearly see that the number of people jumped sharply at 6:02 and practically fell to zero by 6:10.

The story of a Korean student who received an award from the Ministry for the queue monitoring system The story of a Korean student who received an award from the Ministry for the queue monitoring system

I have attached a couple of charts above that refer to lunch and afternoon tea times. It is interesting to note that the peak load at lunchtime was almost always at 12:25 (the queue reached the fifth shield). And for an afternoon snack, a large crowd of people is generally uncharacteristic (the queue is a maximum of one shield long).

You know what's funny? This system is still alive (https://thingspeak.com/channels/346781)! I logged into the account I used before and saw this:

The story of a Korean student who received an award from the Ministry for the queue monitoring system

On the chart above, I saw that on the third of December the influx of people is significantly less. And no wonder, it was Sunday. On this day, almost everyone goes somewhere, because in most cases only on Sunday you can leave the school grounds. It is clear that on the weekend you will not see a living soul in the dining room.

How I got the first prize from the Ministry of Education of Korea for my project

As you can see for yourself, I did not work on this project because I wanted to earn some kind of award or recognition. I just wanted to apply my skills to a chronic problem I had in school.

However, our high school dietitian, Ms. O, with whom I became very close while planning and developing my project, once asked me if I knew about the competition for ideas for the dining room. Then I thought that this was some kind of strange idea - to measure ideas for the dining room. But I read the information booklet and found out that the project must be submitted by November 24th! Well well. I quickly brought the concept, data and graphics to mind and submitted the application.

Changes to the original idea for the contest

By the way, the system that I eventually proposed was slightly different from the one already implemented. In fact, I adapted my original method (measuring queue length in real time) for much larger Korean schools. For comparison: in our school there are three hundred students, and in some others so many people study in only one class! I needed to figure out how to scale the system.

Therefore, I proposed a concept based more on "manual" control. Now Korean schools have already introduced a meal order for all classes, which is strictly adhered to, so I built another signal-reaction framework. It was supposed that when the group visiting the dining room in front of you reaches a certain limit in the length of the queue (that is, the queue becomes short), they will manually send you a signal using a button or switch on the wall. The signal will be transmitted to the TV screen or through LED lights.

I just really wanted to solve a problem that arose in all the schools of the country. I became even stronger in my intention when I heard a story from Miss O - I will tell it now. It turns out that in some large schools the queue extends beyond the canteen, into the street for twenty to thirty meters, even in winter, because no one can properly build the process. And sometimes it happens that for several minutes no one appears in the dining room at all - and this is also bad. In schools with a large number of students, the staff barely manages to serve everyone even if not a single minute of the time allotted for food is wasted. Therefore, those who are the very last to distribute (usually primary school students) simply do not have enough time to eat.

So, even though I had to send my application in a hurry, I still thought very carefully about how I could adapt it for wider use.

The message that I won the first prize!

In short, I was invited to come and present my project to government officials. So I put all my Power Point talents to the test and came and introduced!

The story of a Korean student who received an award from the Ministry for the queue monitoring system

Beginning of the presentation (on the far left is the minister)

It was an interesting experience - I just came up with something for a canteen problem, and somehow ended up in the winners of the competition. Even standing on the stage, I kept thinking: β€œHmm, what am I doing here anyway?”. But in general, this project brought me great benefits - I learned a lot about the development of embedded systems and the implementation of projects in real life. Well, he won a prize, of course.

Conclusion

There is some irony here: no matter how much I participated in all sorts of competitions and scientific fairs, which I purposefully signed up for, nothing good came of it. And then the opportunity just found me itself and gave good results.

It made me think about the reasons that motivate me to take on projects. Why do I start work - to β€œwin” or to solve a real problem in the world around me? If the second motive is at work in your case, I strongly urge you not to abandon the project. With this approach, you can encounter unexpected opportunities along the way and you won't feel the pressure of the need to win - your passion for what you do will become your main motivator.

And most importantly, if you manage to implement a decent solution, you can immediately try it out in the real world. In my case, a school has become a platform, but over time, experience accumulates, and who knows - maybe your application will be used by a whole country or even the whole world.

Every time I look back on that experience, I'm kind of proud of myself. I can’t explain why, but the process of implementing the project simply brought me great pleasure, and the prize was an additional bonus. In addition, I was pleased that I was able to solve a problem for my classmates that spoiled their lives every day. Once one of the students came up to me and said: "Your system is very convenient." I was in seventh heaven!
I think even without any awards, I would feel proud of my development for this alone. Maybe it was helping others that gave me such satisfaction… in general, I love projects.

What I hoped to achieve with this article

I hope that by reading my article to the end, you have been inspired to do something that will benefit your community or even just yourself. I encourage you to use your skills (programming is certainly one of them, but there are others) to change the reality around you for the better. I can assure you that the experience you will gain in the process is incomparable.

It can also open paths for you that you did not expect at all - it happened to me. So please do what you love and make your mark on the world! The echo from a single voice can shake the whole world, so believe in yourself.

Here are some links related to the project:

Source: habr.com

Add a comment