# How schoolchildren and I made a Raspberry alarm for their own school

In October last year, two events coincided: the first - UPS brought me three Raspberry Pi from England and the same number of PiFace, of which I intended to make an alarm at the cottage; the second - I suddenly remembered about my native school, and for some reason I really wanted to give out informal debts and go to teach children something. A logical solution was born out of this: I collected all the pieces of iron in the box and went to show them to the school principal ...

Before I give a detailed description of further events, I’ll tell you a little background from the early nineties.

At that wonderful time, all schools had a lot of fun, and most parents did not want to give their children there. This practice was born in some places, when the parents of a dozen future first-graders got together, found a room and organized classes there, often they taught themselves. I was lucky: then just turned 6 years old and my parents organized such a school. At first, there were only seven of us, and we were engaged in the premises of the children's club. Then our younger brothers and sisters grew up, organized another class and moved to the premises of the kindergarten, then we scored a couple more classes. In total, up to a dozen such institutions were created in Yekaterinburg at that time. Closer to the two thousandths, they all either dissipated or turned into large commercial schools. This has not happened with my school,

... At first, I was allocated four hours instead of computer science lessons for the tenth and eleventh grades. It so happened that in these two classes in the current school year in total only 10 people - 3 boys and 7 girls, I had to teach them.

I thoroughly prepared for the classes, wrote two training manuals:

To begin with, it was supposed to implement the simplest automatic inclusion of light: a Diode flashlight and an IR motion sensor were connected to Piface, then a python script was launched, which polled the sensor in a cycle and turned on the flashlight when triggered (six lines). Manage - through SSH.

The day before the lesson I asked to distribute manuals to the students. The next day I collected all the junk (Raspberry, Piface, motion sensors, diode flashlights, power supplies for 5 and 12 volts, wiring harnesses) and went to classes.

At first I showed what a cool thing we are going to do - I turned on / off the flashlight from my computer in the python interpreter. It seems like it. Further, I generally explained what I did and how I did it, the boys began to connect the devices to the two remaining Disassemble, and the girls sat down on computers and began to reproduce my actions using manuals.

Since I wrote manuals from my head, a jamb immediately appeared - the lack of asterisks when entering a password in Putty was perceived as nothing more than a hang. But we figured it out and until the end of the first pair of classes everyone managed to turn on the flashlight and read the data from the motion sensor.

On the next pair we studied python, wrote simple scripts. Then I made a big mistake in preparing for classes - I did not test the work with mc, on which I was supposed to do all this. It turned out that when working through Putty, the entire mc screen was filled with garbage. In addition, python for some reason does not perceive the double tab in the mc editor as a double indent, I could not catch it for a long time and understand what was the matter. As a result, by the end of the class, everyone had written the simplest scripts that polled the sensors; everyone seemed to like it.

I didn’t write manuals, I decided that along the way we would formulate problems and solve them. To begin with, let them still study python. I installed Linux Mint on two computers (it seems to me to be the most suitable system for training), it contains IDLE. I came to the lesson, the first thing that got into my head was to solve the quadratic equation. And even let the equation be given as a string. Done.

It is too simple to make a normal alarm system: in each room by a sensor, connect to Disassemble, to Disassemble a script in seven lines. Need a task more interesting. For example, by triggering sensors to determine the number of people in the room - and the algorithm is more complicated, and the sensors need to be smarter to place. We need to think about how this will work. And here we are hacked ... The bottom line is that the triggering of conventional IR motion sensors, which are used in alarms that we used, does not depend on the number of people in sight. Therefore, the only way to solve the problem is to process the sequence of sensors, that is, the movement of people, since people move more often alone. The task was also complicated by the inertia of the sensors: with a one-time operation, the sensor opens the contact for ~ 10 seconds. I suspect, that in mathematics there is a special section for solving such problems, but we didn’t bother with that, we went by simple peasant logic, as a result, spending a total of 10 hours on a brainstorming session, we formulated some algorithm. In short - they decided to stupidly sort through all possible sequences of people moving and determine at what minimum number of people these sequences are realized. Among other things, we came to the conclusion that with a typical simultaneous stay in the room of more than 50 people with conventional IR sensors, we can’t determine their number in any way. And then the next milestone of our project begins. In short - they decided to stupidly sort through all possible sequences of people moving and determine at what minimum number of people these sequences are realized. Among other things, we came to the conclusion that with a typical simultaneous stay in the room of more than 50 people with conventional IR sensors, we can’t determine their number in any way. And then the next milestone of our project begins. In short - they decided to stupidly sort through all possible sequences of people moving and determine at what minimum number of people these sequences are realized. Among other things, we came to the conclusion that with a typical simultaneous stay in the room of more than 50 people with conventional IR sensors, we can’t determine their number in any way. And then the next milestone of our project begins.

I immediately decided that 4 people for classes is not enough, it is necessary to attract the eighth grade. They need something simpler, let it be cars for boys and addressable RGB garlands for girls. Made a corresponding order on ebay. Among other things, 3 more distance sensors came to me. High school students and I decided to install them in the opening of the front door to accurately determine the number of people who entered.

Actually this is what we have reached to the present moment, to be continued ...

Before I give a detailed description of further events, I’ll tell you a little background from the early nineties.

At that wonderful time, all schools had a lot of fun, and most parents did not want to give their children there. This practice was born in some places, when the parents of a dozen future first-graders got together, found a room and organized classes there, often they taught themselves. I was lucky: then just turned 6 years old and my parents organized such a school. At first, there were only seven of us, and we were engaged in the premises of the children's club. Then our younger brothers and sisters grew up, organized another class and moved to the premises of the kindergarten, then we scored a couple more classes. In total, up to a dozen such institutions were created in Yekaterinburg at that time. Closer to the two thousandths, they all either dissipated or turned into large commercial schools. This has not happened with my school,

... At first, I was allocated four hours instead of computer science lessons for the tenth and eleventh grades. It so happened that in these two classes in the current school year in total only 10 people - 3 boys and 7 girls, I had to teach them.

I thoroughly prepared for the classes, wrote two training manuals:

To begin with, it was supposed to implement the simplest automatic inclusion of light: a Diode flashlight and an IR motion sensor were connected to Piface, then a python script was launched, which polled the sensor in a cycle and turned on the flashlight when triggered (six lines). Manage - through SSH.

The day before the lesson I asked to distribute manuals to the students. The next day I collected all the junk (Raspberry, Piface, motion sensors, diode flashlights, power supplies for 5 and 12 volts, wiring harnesses) and went to classes.

#### How did this happen

I had only three sets, and 10 students, so we made up desks with the letter “P”, put another desk in the middle and laid out a piece of iron on it with a bunch of wires (three more twisted pairs were added to the above to connect Disassemble to the network; photos, Unfortunately, no more). The children sat down two at a computer, two pairs worked with one Disassemble.At first I showed what a cool thing we are going to do - I turned on / off the flashlight from my computer in the python interpreter. It seems like it. Further, I generally explained what I did and how I did it, the boys began to connect the devices to the two remaining Disassemble, and the girls sat down on computers and began to reproduce my actions using manuals.

Since I wrote manuals from my head, a jamb immediately appeared - the lack of asterisks when entering a password in Putty was perceived as nothing more than a hang. But we figured it out and until the end of the first pair of classes everyone managed to turn on the flashlight and read the data from the motion sensor.

On the next pair we studied python, wrote simple scripts. Then I made a big mistake in preparing for classes - I did not test the work with mc, on which I was supposed to do all this. It turned out that when working through Putty, the entire mc screen was filled with garbage. In addition, python for some reason does not perceive the double tab in the mc editor as a double indent, I could not catch it for a long time and understand what was the matter. As a result, by the end of the class, everyone had written the simplest scripts that polled the sensors; everyone seemed to like it.

#### Continuation

I wasn’t allowed to attend computer science lessons anymore, and I suggested the children study optionally, four people volunteered. It was necessary to formulate a task for them. It was then that the school played a non-profit school, and the children did not have a consumer attitude towards it: when I proposed to make a smart alarm for my home school, they agreed.I didn’t write manuals, I decided that along the way we would formulate problems and solve them. To begin with, let them still study python. I installed Linux Mint on two computers (it seems to me to be the most suitable system for training), it contains IDLE. I came to the lesson, the first thing that got into my head was to solve the quadratic equation. And even let the equation be given as a string. Done.

It is too simple to make a normal alarm system: in each room by a sensor, connect to Disassemble, to Disassemble a script in seven lines. Need a task more interesting. For example, by triggering sensors to determine the number of people in the room - and the algorithm is more complicated, and the sensors need to be smarter to place. We need to think about how this will work. And here we are hacked ... The bottom line is that the triggering of conventional IR motion sensors, which are used in alarms that we used, does not depend on the number of people in sight. Therefore, the only way to solve the problem is to process the sequence of sensors, that is, the movement of people, since people move more often alone. The task was also complicated by the inertia of the sensors: with a one-time operation, the sensor opens the contact for ~ 10 seconds. I suspect, that in mathematics there is a special section for solving such problems, but we didn’t bother with that, we went by simple peasant logic, as a result, spending a total of 10 hours on a brainstorming session, we formulated some algorithm. In short - they decided to stupidly sort through all possible sequences of people moving and determine at what minimum number of people these sequences are realized. Among other things, we came to the conclusion that with a typical simultaneous stay in the room of more than 50 people with conventional IR sensors, we can’t determine their number in any way. And then the next milestone of our project begins. In short - they decided to stupidly sort through all possible sequences of people moving and determine at what minimum number of people these sequences are realized. Among other things, we came to the conclusion that with a typical simultaneous stay in the room of more than 50 people with conventional IR sensors, we can’t determine their number in any way. And then the next milestone of our project begins. In short - they decided to stupidly sort through all possible sequences of people moving and determine at what minimum number of people these sequences are realized. Among other things, we came to the conclusion that with a typical simultaneous stay in the room of more than 50 people with conventional IR sensors, we can’t determine their number in any way. And then the next milestone of our project begins.

I immediately decided that 4 people for classes is not enough, it is necessary to attract the eighth grade. They need something simpler, let it be cars for boys and addressable RGB garlands for girls. Made a corresponding order on ebay. Among other things, 3 more distance sensors came to me. High school students and I decided to install them in the opening of the front door to accurately determine the number of people who entered.

Actually this is what we have reached to the present moment, to be continued ...