domingo, 27 de agosto de 2017

The 1sheeld Virtual People Counter

eferemail
shared this article with you from Inoreader

 

A virtual shield and a smartphone, with the addition of ultrasound sensors that allow us to detect passage and direction of anyone crossing a passage.

Most of Arduino's success is also due to the fact that the base features of this board can be expanded by simply adding shields, which are boards containing hardware that is specific for each application. The possibility to add new hardware on the existing base board also provides almost countless development options and encouraged the most important manufacturers of components and electronic devices to propose an innovative and interesting solution.

Do you want satellite localization? Add a shield with a GPS receiver! Do you want an application with a graphic display? All you have to do is add a shield with a GLCD (Graphic Liquid Crystal Display). Nowadays, for each function, there is a dedicated shield, which is commercially available in numerous options based on the manufacturer. In this scenario, the team of Integreight had an absolutely genius idea, thinking about the potential of interaction between an Arduino board and a recent smartphone.

Actually, many functions carried out by the shield are already present in a smartphone, which is well equipped in terms of built-in sensors; besides, it has a sophisticated communication section ranging from Bluetooth to 3G. Finally, in integrates a high-res display. Well, Integreight team thought that every feature of a smartphone could be represented on a shield for Arduino; all they had to do was establish a communication with Arduino and they were set. That's where the idea for 1Sheeld came from, that is a unique Arduino shield that allows taking advantage of all the features of a smartphone; the pun is intended and it indicates that it's just one single shield for many functionalities.

 

 

So, if we need satellite localizer in our project, instead of buying a specific shield, we can take advantage of the GPS receiver of the smartphone, and when we need a graphic display we can use the smartphone's one. Naturally, communication sections and support for sending emails, SMS or excessive social networks is also available for our applications.

In total, Integreight was able to implement more than 40 virtualized shields with 1Sheeld; the complete list is available here.

 

1Sheeld is composed of two hardware blocks, one being the smartphone; the other one is a specific interface shield based on an Atmel ATmega162 microcontroller and a Bluetooth module that is simply used to allow our Arduino board to communicate with the smartphone. The biggest effort by the developers was to develop an application to run on the smartphone, trying to obtain a very user-friendly product that has at the same time the maximum operational flexibility possible to allow the user, with just a few taps on the display, to customize the desired interface. The Bluetooth shields interconnect Arduino to a smartphone, where the active application initializes and uses the sensors required, which act just like they are on Arduino and can be accessed anyways; this is remarkably convenient.

 

 

Unique shield and virtual hardware

Now, let's take a more in-depth look at this product and how it can be employed, by also making use of the electric diagram illustrated in the previous pages. 1Sheeld is proposed as an absolutely standard shield for Arduino Uno/Arduino Mega. Its power voltage can manually be set to 3,3 V or 5 V through the POWER-SW deviator, which allows the shield to also function with 3.3 V boards, provided their pins are compatible with Arduino. Anyway, the shield's logics also works with voltage picked by the deviator's slider: when POWER-SW is 5 V, the U1 regulator takes the 3.3 V necessary for the Bluetooth module, which has to work at 3.3 V., The board uses a standard Bluetooth module (Bluetooth 2.1) labeled BT-HC06 in the electric diagram, allowing it to communicate with a smartphone up to around 10 m distance.

 

 

The Bluetooth module is normally reset through R7; using the Q1 MOSFETs, when the microcontroller puts its PE0 line to a logic level high, the RST terminal of the module goes low and reset is deactivated. The UART inside the Bluetooth module is interfaced with the virtual serial implemented in U2 by PB2 and PB3 I/Os and through two 74LVC1G125 buffers used as level adapters when the shield works at 5 V: in this case, in fact, PB3 line of the microcontroller provides TTL impulses that are adapted to 3.3 V by the IC1, while the module's UTX provides 0/3,3V impulses which are then translated to 0/5V by the IC2.

1Sheeld communicates with the Arduino board using the internal UART module, therefore we want to be able to use the Serial Monitor feature of Arduino while it's working. PIO1 line of the Bluetooth modules drives, through the R3 resistor, the BT-LED providing signals on connection activity.

 

 

In order to allow Arduino to be programmed by PC, the shield has the UART-SW deviator that allows excluding communication between Arduino's UART and 1Sheeld. The LEDs labeled TXD and RXD (pins PA6 and PA7 of the micro U2) regulate the activity on the serial port.

On the board, there is also a reset button that replicates the functionality of the reset button on the Arduino board.

Now, let's see how to activate this shield: first things first, we have to go on the reference website where we can find a section dedicated to tutorials and one dedicated to community projects. The first step is to download the Arduino library, that can be found under the Download page; we can also use the dedicated tool provided with the latest version of the Arduino's IDE (version 1.6.7 or later) and go to sketch> library inclusion> library management and then select onesheeld and install it ; all the sketches in this post refer to version 1.8.0 of the library.

 

 

You can get to know the shields right from the start by trying out the numerals sketches already available in the examples.

 

OUR PROJECT

In this post, we propose instead a general utility application, a people counter. If you don't know what this is, we can tell you it's a system capable of detecting both the passage of people through an opening and the direction of said passage; this way we can have both a visual and acoustic indication of the passage and specifically count who goes in and who goes out in order to verify a possible difference and understand if someone is still inside a business establishment after working hours.

So, our application can be useful for the business owner in order to receive an acoustic signal on his or her smartphone to know if someone enters the shop when the owner is in the back; but it can also be a simple way to count people going in during a trade show or an event, everything on a device that we don't always have to remember picking up or adding to our equipment because it's always with us.

We have also designed a domestic application because we can also use our project to know if someone enters in a room or to know if your child has just trespassed a forbidden zone, the applications are really countless.

However you choose to employ it, the most interesting part of the project is that the information related to the passage of a person is directly provided on your smartphone, along with an indication of a number of people passed through and a vibration and acoustic modification.

We provided two options, one if you just want to know the number of people passing and one if you want to keep a record of people going in and out. So, let's suppose there is a passage and we want to count people crossing it, we could've also used some photoelectric barriers and run the wires to the transmitter and the receiver from both side of the passage, on the other hand, in this project we wanted to use some simple (and cheap) ultrasound sensors capable of identifying the passage of people based on the distance measured.

As a sensor, we have used the affordable MISDIST04 which is an ultrasound meter with a 1 cm precision from a distance of a few meters. By placing this sensor on a door jamb facing the opposite door jamb, based on the measure provided by the sensor we will be able to evaluate if a person or an object has crossed the passage.

 

In the figure you can find the electrical wiring needed.

 

 

 

 

 

As for powering the system, we recommend using a small switching, high performance 5 V output power supply and a type B USB email port compatible with Arduino. You can power Arduino also through its plug connector provided you use a power supply with a voltage between 7 and 12 V, better if it's a switching power supply for higher performances, such as a 12 V switching power supply available in our store with code AL12V1A2.

The technique used for this application involves reading the measure provided by the sensor at set intervals and comparing it with the previous measure: if the measure provides a sensibly reduced value, it means that an object passed in front of the sensor. For better accuracy, we are going to discard all the measures considered unreliable, such as those less than 10 cm and over 150 cm; moreover, we are going to prevent successive readings for a prefixed period after deducting the crossing of one person.

The core code lines, in this case, are those setting the parameters described above, which are the working parameters of the sketch:

long maxDistance=150;

long triggerDistance=50;

long deadTime=1000;

 

Where maxDistance represents the maximum reliable measure, over that value the reading is discarded, while the triggerDistance parameter indicates the measure's limited variation besides which we consider that a person certainly crossed the passage; deadTime parameter is inhibition time between one reading and the next one, which is useful in order to avoid that fluctuation in distance measured lead to errors when detecting the crossing of a person. The program section referred to counting passing people is listed here.

Listing1

inUS();   if ( currentDistance>10 && currentDistance < maxDistance)   {   if (previousDistance-currentDistance > triggerDistance && millis()-triggerTime > deadTime)   {   triggerTime=millis();   count++;   -> gestione 1sheeld <-   }   previousDistance=currentDistance;   }

 

The inUS() function is used in order to read distance measured by the sensor; correspondent value is then placed in the variable currentDistance. Only when the crossing of one person is detected, the variable count is incremented by one. During our tests, in order to display this value on the PC we used a virtual serial port implemented but they library softSerial which data were sent to the DC through a USB/serial converter; this because when 1Sheeld is active the UART module of Arduino cannot be used to communicate with the personal computer.

 

Now, let's get to the more interesting part, how to integrate 1Sheeld's features in this project. In order to make everything ready we have to work on the smartphone side and first of all we're going to install the official 1Sheeld application directly from Google store on Android.

 

The app can also be downloaded from your web browser by visiting the page download where you can get the Android version and libraries.

Next, let's activate the smartphone's Bluetooth functionality (if it's not already activated) and launch the app: first, the app will ask us to detect 1Sheeld (figure shows the research app for 1Sheeld devices via Bluetooth);

 

 

then we will have to connect (figure shows the screen once a connection is established).

 

 

Now we can choose the suitable virtual shields for our application:

 

 

since we want to see the tally on the smartphone's display, we need an LCD Shield;

 

 

we also want an acoustic notification with each passage, so we are going to use a Buzzer Shield.

 

 

Next, we want to be able to manually reset the tally, so we can use a Button Shield ;

 

 

finally, we want to implement a light vibration, therefore we select the Vibration Shield.

 

 

In case we want to use the system in order to detect intrusions or unauthorized passages, we also have the chance to send a notification to the smartphone using a dedicated Notification Shield.

 

 

In Listing2 we report the code lines to include the 1Sheeld library and enable the functionalities requested. As suggested by the developers, it's recommended to only enable (via the command #include) the shield you are going to use, in order to save energy. In Listing 1, under the voice "1Sheeld management" we are going to insert the program lines that allows to interact with the smartphone.

Listing2

#define CUSTOM_SETTINGS   #define INCLUDE_VIBRATION_   #define INCLUDE_LCD_   #define INCLUDE_BUZZER_   #define INCLUDE_PUSH_BUTTON_   #define INCLUDE_NOTIFICATION_   /* Include 1Sheeld library. */   #include <OneSheeld.h>

 

As you can see in Listing 3, the lines allowing to send data to the smartphone are really simple and basically are a call to the decide function.

Listing3

Buzzer.buzzOn();   Notification.notifyPhone("Someone pass!");   LCD.clear();   String stringOne = String(count, DEC);   String dataText = "Count= " + stringOne;   char charBuf[16];   dataText.toCharArray(charBuf, 16);   LCD.print(charBuf);   delay(50);   Buzzer.buzzOff();   Vibration.start(1000);

 

In order to display the numeric value, however, we have to convert it into a char array; other than that, instructions are pretty intuitive.

Some functions can be omitted as needed, e.g. notification is useful only in case of occasional although important passages, however, it has the advantage to let us know the exact time when the crossing took place. The tally reset management is operated by the following code lines:

 if(PushButton.isPressed())       {         count=0;         LCD.clear();            LCD.print("Count= 0");         }

 

 

As you can see, tally reset management takes place by reading the status of the button implemented in the smartphone.

 

LET'S GET TO WORK

Very well, now that we have established how the firmware works and how we can work from the app, let's get to the core of the project: on the application main screen, all we have to do is tap on the icon on the left to include the shield in the project; by clicking on the shield icon in the top right corner we will start the communication with the shield and system will be operative: really simple and intuitive!

In the shield, the blue LED called BT-LED will go from blinking to steady to indicate that communication has been activated and the system is ready. You can select it by swiping the shield you want, passing from tally visualization to volume regulation for the buzzer, to a screen where you will find the button to reset the tally value.

 

DETECTING PASSAGE DIRECTION

For specific applications, we thought about a system variant that involves using two ultrasound sensors placed at a distance of around 25 cm one from the other. This way, upon the passage of a person one sensor, will be activated first and then the second one, and the sequence depends on the direction; this way, we can understand if the person is going in or out. In other words, the ultrasound sensors will detect an increase and a decrease of distance from the body of the person in sequence.

 

 

Taking figure as a reference, we can say that a person going in will first encounter sensor 1 and then sensor 2, vice versa the person will first encounter sensor 2 and then sensor 1 if they are going out. All we have to do is check both sensors and memorize which one provided the signal first, then wait for the signal from the second sensor in order to determine if the person is going in or out; the functioning principle is really similar to the one used by rotation encoders to determine rotation direction of a knob.

 

 

Of course, if the second reading doesn't arrive within a prefixed time period, the system will decide that the person has not crossed the passage completely and therefore will not count them.

 

 

The sketch written for this variant of the system is called contapersone2US.ino and the visualization on Serial Monitor of debug data is available in the previous figure; the result on the smartphone's display can be seen in the figure , showing us the representation of alphanumeric virtual display implemented by the LLC Shield.

 

 

In this last case, since we have implemented it, passage direction can also be indicated, meaning if the subject is going in or out; the tally will increase by one if the person is going in and will decrease by one if the person is going out.

By placing such a system at the entrance of a room we will be able to know the number of people inside, of course with some limitations which are due, for instance, to more people overlapping or disturbances of various nature due to clothes flapping in the air because of air gusts or strong ventilation in the room. In fact, the system cannot detect the simultaneous crossing of more people, in that if there is no space between the one in the front and the one in the back, only one passage will be detected.

 

Conclusion

We conclude here our analysis of 1Sheeld and a couple of applications made possible by it.

We think we managed to make you understand, in these pages, the potential and the features of the product, so much so that you can easily imagine what applications you can implemented by taking advantage of the numerous virtual shields you have at your disposal, especially those hard to implement with a classic hardware shield for Arduino, for instance the message sending through social networks (which would require a Wi-Fi shield and a lot more hardware) or vocal recognition. With 1Sheeld, on the other hand, you can immediately use a Voice Recognition Shield to identify vocal commands, or a Camera Shield to acquire and analyze video clips.

 

 

In conclusion, based on what we have explained, you can experiment by yourself on the possibilities offered by a solution portfolio containing over 40 virtual shields.

Enjoy!

 

From openstore

Switching power supply 12 V-1,2 A

Arduino Shield for Android smartphones

Ultrasonic range finder 2-450 cm

OpenElectronics?d=yIl2AUoC8zA OpenElectronics?d=qj6IDK7rITs OpenElectronics?i=BVzLPd8uT1o:DRUY2ejbwy OpenElectronics?i=BVzLPd8uT1o:DRUY2ejbwy OpenElectronics?i=BVzLPd8uT1o:DRUY2ejbwy OpenElectronics?d=dnMXMwOfBR0 OpenElectronics?d=7Q72WNTAKBA
View on the web
Inoreader is a light and fast RSS Reader. Follow us on Twitter and Facebook.

No hay comentarios:

Publicar un comentario