Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING
Free library / Schemes of radio-electronic and electrical devices

Arduino. Connecting simple sensors. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Radio amateur designer

Comments on the article Comments on the article

The built-in ADC of the microcontroller, considered in the previous part of the review, makes it easy to connect various analog sensors to the Arduino board, which convert the measured physical parameters into electrical voltage.

An example of a simple analog sensor is a variable resistor connected to the board, as shown in Figure 1. 3. It can be of any type, for example, SP33-32-2 (Fig. 10). The value of the resistor in the diagram is indicated approximately and can be either less or more. However, it should be remembered that the smaller the resistance of the variable resistor, the more current it consumes from the power supply of the microcontroller. And when the resistance of the signal source (in this case, a variable resistor) is more than XNUMX kOhm, the ADC of the microcontroller works with large errors. Please note that the resistance of a variable resistor as a signal source depends on the position of its slider. It is equal to zero in its extreme positions and maximum (equal to a quarter of the nominal resistance) in the middle position.

Arduino. Connecting simple sensors
Rice. 1. Scheme of connecting a variable resistor to the board

Arduino. Connecting simple sensors
Rice. 2. SP3-33-32

It is convenient to use a variable resistor when you want to change the parameter smoothly, and not in steps (discretely). As an example, consider the work given in Table. 1 program that changes the brightness of the LED depending on the position of the variable resistor slider. The string U = U/4 is needed in the program in order to convert the ten-bit binary number returned by the ADC to an eight-bit number, accepted as the second operand by the analogWrite () function. In the case under consideration, this is done by dividing the original number by four, which is equivalent to discarding the two least significant bits.

Table 1

Arduino. Connecting simple sensors

A variable resistor of an appropriate design can serve as a rotation angle or linear displacement sensor. Similarly, many radio elements can be connected to it: photoresistors, thermistors, photodiodes, phototransistors. In a word, devices whose electrical resistance depends on various environmental factors.

On fig. 3 shows a diagram of connecting a photoresistor to the Arduino. When the illumination changes, its electrical resistance changes and, accordingly, the voltage at the analog input of the Arduino board. The photoresistor FSK-1 indicated in the diagram can be replaced by any other, for example, SF2-1.

Arduino. Connecting simple sensors
Rice. 3. Wiring diagram for Arduino photoresistor

In table. 2 shows a program that turns an Arduino board with a photoresistor connected to it into a simple light meter. While working, it periodically measures the voltage drop across the resistor connected in series with the photoresistor, and transmits the result in arbitrary units through the serial port to the computer. On the Arduino debug terminal screen, they will be displayed as shown in Fig. 4. As you can see, at a certain moment the measured voltage dropped sharply. This happened when a brightly lit photodiode was obscured by an opaque screen.

Table 2

Arduino. Connecting simple sensors

Arduino. Connecting simple sensors
Rice. 4. The image on the screen of the Arduino debugging terminal

To obtain illumination values ​​in lux (standard units of the SI system), you need to multiply the results obtained by a correction factor, but you will have to select it experimentally, and individually for each photoresistor. This will require an exemplary light meter.

A phototransistor [1] or a photodiode (Fig. 5) is connected to the Arduino in a similar way. Using several photosensitive devices, it is possible to design the simplest vision system for a robot [2]. It is also possible to implement many classical designs known to a wide range of radio amateurs at a new technical level - a cybernetic model of a night butterfly [3, p. 134-151] or a model of a tank moving towards the light [4, p. 331, 332].

Arduino. Connecting simple sensors
Rice. 5. Scheme for connecting a photodiode to Arduino

Similarly to the photoresistor, a thermistor is connected to the Arduino (Fig. 6), which changes its electrical resistance depending on temperature. Instead of the MMT-4 thermistor indicated on the diagram, the main advantage of which is a sealed case, you can use almost any other, for example, MMT-1 or imported.

Arduino. Connecting simple sensors
Rice. 6. Diagram of connecting thermistor to Arduino

After an appropriate calibration [5, p. 231-255] such a device can be used to measure temperature in all kinds of home weather stations, thermostats and similar structures [6].

It is known that almost all LEDs can serve not only as light sources, but also as light receivers - photodiodes. The fact is that the LED crystal is in a transparent case and therefore its pn junction is accessible to light from external sources. In addition, the housing of the LED, as a rule, has the shape of a lens that focuses external radiation on this transition. Under its influence, for example, the reverse resistance of the pn junction changes.

By connecting the LED to the Arduino board according to the diagram shown in fig. 7, one and the same LED can be used both for its intended purpose and as a photosensor [7]. The program illustrating this mode is shown in Table. 3. Her idea is that first, a reverse voltage is applied to the pn junction of the LED, charging its capacitance. The cathode of the LED is then isolated by configuring the pin of the Arduino it is connected to as an input. After that, the program measures the duration, dependent on ambient light, of discharging the capacitance of the pn junction of the LED by its own reverse current to a logic zero level.

Arduino. Connecting simple sensors
Rice. 7. Scheme for connecting the LED to the Arduino board

Table 3

Arduino. Connecting simple sensors

In the above program, the variable t is declared as unsigned int - an unsigned integer. A variable of this type, unlike an ordinary int that takes values ​​from -32768 to +32767, does not use its most significant bit to store the sign and can take values ​​from 0 to 65535.

The program calculates the discharge time in the while(digitalRead (K)!=0)t++ loop. This loop is executed, incrementing t by one each time, until the parenthesized condition is true, i.e., until the LED cathode voltage goes low.

Sometimes it is required that the robot not only receive information about the illumination of the surface on which it moves, but also be able to determine its color. A color sensor of the underlying surface is implemented, illuminating it alternately with LEDs of different luminescence colors and comparing, using a photodiode, the levels of signals reflected from it under different illumination [8]. The connection diagram of the color sensor elements with the Arduino board is shown in fig. 8, and the program serving it - in table. 4.

Arduino. Connecting simple sensors
Rice. 8. Scheme of connecting the elements of the color sensor with the Arduino board

Table 4

Arduino. Connecting simple sensors

The procedure for measuring the signals received by the photodiode under different illumination of the surface is repeated many times, and the results obtained are accumulated in order to eliminate random errors. The program then selects the largest of the accumulated values. This allows you to roughly judge the color of the surface. To more accurately determine the color, it is necessary to complicate the processing of the results, taking into account not only the largest of them, but also its ratio with the smaller ones. It is also necessary to take into account the real brightness of LEDs of different luminescence colors, as well as the spectral characteristics of the applied photodiode.

An example of a color sensor design consisting of four LEDs and a photodiode is shown in Fig. 9. The optical axes of the LEDs and the photodiode should converge at one point on the surface under study, and the devices themselves should be located as close as possible to it in order to minimize the effect of extraneous illumination.

Arduino. Connecting simple sensors
Rice. 9. An example of the design of a color sensor of four LEDs and a photodiode

The assembled sensor requires careful individual calibration on surfaces of different colors. It is reduced to a selection of coefficients by which the measurement results obtained under different illumination should be multiplied before comparison. A robot equipped with such a sensor can be taught to perform interesting motion algorithms. For example, he will be able to move around the working field of one color without violating the boundaries of "forbidden" zones painted in a different color.

The programs discussed in the article can be found at ftp://ftp.radio.ru/pub/2016/10/asensors.zip.

Literature

  1. Kholostov K. Garden on the windowsill. - Lefty, 2014, No. 11, p. 12-14.
  2. Kholostov K. Do not be surprised: a robot is simple. - Lefty, 2012, No. 11, p. 12-14.
  3. Otryashenkov Yu. M. Young cyberneticist. - M.: Children's literature, 1978.
  4. Borisov V. G. Young radio amateur. - M.: Radio and communication, 1992.
  5. Revich Y. Entertaining electronics. - St. Petersburg: BHV-Petersburg, 2007.
  6. Kholostov K. We regulate the temperature. - Lefty, 2013, No. 8, p. 12-14; No. 9, p. 12-14.
  7. Practical Arduino/CraftDuino Programming - LED Sensor. - URL: robocraft.ru/blog/arduino/70.html.
  8. Homemade color sensor. - URL: robocraft.ru/blog/sensor/395.html.

Author: D. Lekomtsev

See other articles Section Radio amateur designer.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

A New Way to Control and Manipulate Optical Signals 05.05.2024

The modern world of science and technology is developing rapidly, and every day new methods and technologies appear that open up new prospects for us in various fields. One such innovation is the development by German scientists of a new way to control optical signals, which could lead to significant progress in the field of photonics. Recent research has allowed German scientists to create a tunable waveplate inside a fused silica waveguide. This method, based on the use of a liquid crystal layer, allows one to effectively change the polarization of light passing through a waveguide. This technological breakthrough opens up new prospects for the development of compact and efficient photonic devices capable of processing large volumes of data. The electro-optical control of polarization provided by the new method could provide the basis for a new class of integrated photonic devices. This opens up great opportunities for ... >>

Primium Seneca keyboard 05.05.2024

Keyboards are an integral part of our daily computer work. However, one of the main problems that users face is noise, especially in the case of premium models. But with the new Seneca keyboard from Norbauer & Co, that may change. Seneca is not just a keyboard, it is the result of five years of development work to create the ideal device. Every aspect of this keyboard, from acoustic properties to mechanical characteristics, has been carefully considered and balanced. One of the key features of Seneca is its silent stabilizers, which solve the noise problem common to many keyboards. In addition, the keyboard supports various key widths, making it convenient for any user. Although Seneca is not yet available for purchase, it is scheduled for release in late summer. Norbauer & Co's Seneca represents new standards in keyboard design. Her ... >>

The world's tallest astronomical observatory opened 04.05.2024

Exploring space and its mysteries is a task that attracts the attention of astronomers from all over the world. In the fresh air of the high mountains, far from city light pollution, the stars and planets reveal their secrets with greater clarity. A new page is opening in the history of astronomy with the opening of the world's highest astronomical observatory - the Atacama Observatory of the University of Tokyo. The Atacama Observatory, located at an altitude of 5640 meters above sea level, opens up new opportunities for astronomers in the study of space. This site has become the highest location for a ground-based telescope, providing researchers with a unique tool for studying infrared waves in the Universe. Although the high altitude location provides clearer skies and less interference from the atmosphere, building an observatory on a high mountain poses enormous difficulties and challenges. However, despite the difficulties, the new observatory opens up broad research prospects for astronomers. ... >>

Random news from the Archive

Scholars love short headlines 05.09.2015

High citation is considered a sign of the success of a scientific work: the more other researchers have referred to the article, the more interesting and promising its results. But in a publication, not only the content is important, but also the form: it is unlikely that anyone will read a very badly written text - they simply cannot, even if a discovery of incredible importance is described there. What formal, stylistic parameters influence the popularity of the study?

For example, title length. Adrian Letchford and colleagues at the University of Warwick compared the citations of 140 articles published between 000 and 2007 with the length of their titles. This is not the first work of its kind, but so far the results here have been somewhat contradictory. Some of the controversy may have arisen because different scientific journals use different standards. For example, Science requires authors to limit the title of an article to 2013 characters, while journals in the PLoS (Public Library of Science) group allow up to 90 characters - however, in terms of citation rate, articles in Science, on average, are far ahead of articles in PLoS. That is, in order to study the relationship between the popularity of a work and its title, one must compare publications published in the same journal or publishing group.

This time, the researchers did just that, with a somewhat predictable result: citations were higher for papers with short titles. There were exceptions, though: papers in The Lancet and The Lancet Oncology failed to find a relationship between title length and popularity, and in the Journal of High Energy Physics, publications with short titles tended to garner few self-citations. (By the way, The Lancet found two articles that were in the top five shortest titles: one of them was simply called "Myopia", that is, "Myopia", and the second - "Measles", that is, "Measles".) Fully about the results research can be read at the Royal Society Open Science.

Employees at some publications - Karl Ziemelis, science editor of the physics department at Nature, and Meghan Byrne, senior editor at PLoS One - say that this is true: a short headline attracts more attention, so it increases the likelihood that the article under it will be read to the end. Huge statistics from 140 thousand analyzed publications speak in favor of the new work, however, of course, no one says that a short title is the only key to success. This, rather, is only one of the factors, especially since, for example, the scientific profile of the article and the name of the head of the laboratory were not taken into account here.

It may well be that physicists and doctors have different attitudes towards the length of headlines, and an article published by the staff of a Nobel laureate will, by definition, attract increased attention. However, the results obtained should not be dismissed. After all, scientists love taciturnity not at all out of laziness of the mind, they simply, like no one else, understand the validity of Shakespeare's well-known expression "... brevity is the soul of the mind ...", which is akin to Chekhov's no less famous "brevity is the sister of talent."

Other interesting news:

▪ The longest-lived vertebrate identified

▪ Sunspots affect the climate

▪ Jupiter doesn't revolve around the sun

▪ Global warming is causing coral bleaching

▪ Telephone conversation excites the cerebral cortex

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ section of the site Home workshop. Article selection

▪ article Principles of organization and tasks of the disaster medicine service. Basics of safe life

▪ article Why are there no numbers in IKEA product names? Detailed answer

▪ article Asphalt concrete worker-welder. Standard instruction on labor protection

▪ article Lightning protection of buildings. Encyclopedia of radio electronics and electrical engineering

▪ article Decoder of a simple telecontrol system. Encyclopedia of radio electronics and electrical engineering

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024