Sensors exist in many shapes and forms. This makes it hard to find the right sensors to build, for instance, a robot. In this document, we provide some information on different types of sensors and how to connect them to the Dwengo Board.

Light sensor

Types: Vishay TEPT5600 (NPN phototransistor)


What: The phototransistor conducts current in relation to the light falling into the sensor. If you place a resistor in series with the phototransistor, you can read out the amount of light by measuring the voltage over the sensor, as shown in the schematic. This is ideal to make a robot that responds to light, have a solar panel orient itself towards the sun, etc.


How: The phototransistor is a semiconductor that is sensitive to daylight. Under influence of incident light, a base current is generated that is proportional to the light intensity. This base current is amplified by the transistor into a larger current between its emitter and collector. Due to this internal amplification, phototransistor are very sensitive. By placing this component in a voltage divider configuration, the light intensity is converted into a voltage drop over the transistor. This voltage can be measured by the Dwenguino board A/D convertors (pins A0 to A5). More information can be found in the light measurement tutorial.

Connect: The phototransistor needs a resistor connected to the collector, this is the short pin. A 22-kOhm resistor is a good value for phototransistors of this type. You can now connect the sensor to the Dwenguino board's expansion connector by connecting the emitter (the long pin) to ground, the free pin of the resistor should be connected to the positive power supply (+5V). Finally, connect the collector (short pin) to an analog input (pins A0 to A5) of the expansion connector.

Proximity sensor

Types: Avago APDS-9104 of Vishay TCRT 5000

Proximity sensor

What: This sensor consists of an infrared LED (IR-LED) which sends out light, and a phototransistor. The phototransistor conducts current in proportion to the IR-light that is reflected by an object in close proximity to the sensor. After soldering the right resistors, this sensor can be used to measure small distances (up to 1 cm) to objects, or detect contrast differences on a surface. This makes this type of sensor ideal to make for instance line-following robots. In scouting robots it can be used to detect obstacles or the end of a table. Due to its limited range, the sensor should be placed at most about 1 cm above the ground.

Proximity sensor

How: The sensor consists of an IR-LED and a phototransistor. By sending a current through the IR-LED, it emits light that can be reflected by close-by surfaces. The amount of reflected light that reaches the sensor again depends on the distance of the surface, its color and its smoothness. The phototransistor collects this light and will conduct current depending on the received light's intensity. The current throught the IR-LED must be limited by using a 220-Ohm resistor. The phototransistor, just like its discrete counterpart described above, can be placed in a voltage division configuration in combination with a 10-kOhm resistor.

Connect: To connect this sensor you first need to solder two resistors to it, just like shown in the schematic. Watch for the cut-off corner, which is also present on the sensor. The pins marked by 5 V should be connected to the 5-V pin of the expansion connector of the Dwenguino Board. The ground pins connect to the expansion connector's ground pin, while the pin marked Vout in the schematic goes to one of the analog inputs (pins A0 to A5) of the Dwenguino Board. More information can be found in the light measurement tutorial.

Sonar sensor

Types: SR-04 and other sonar modules

What: A high frequency sound wave is send out by a speaker while the echo which is received back is analysed. Based on the time interval between sending the sound wave and receiving the wave, the distance to an object can be measured. The principle is very similar to how bats or submarines locate objects.


How: Ultrasonic waves have a velocity of 340 m/s in air. If we measure the time t between triggering a sound wave and receiving its echo we can calculate the distance d based on the following formula: d=340t/2. The sensor can be triggered through the trigger (Trig) pin while the echo is received back on the echo pin.

Connect: The sensor has four pins. Connect the 5V and GND pin to the + and the - of the Dwenguino board respectively. The trigger and echo pin can be connected to any digital I/O available on the Dwenguino expansion connecter. The example code in Arduino IDE File > Examples > Dwenguino > SensorsPlus defines the following:

#define ECHO_PIN     11
#define TRIGGER_PIN  12

Long range Sharp sensor

Types: Sharp GP2D12 (10 cm - 80 cm), GP2D120 (4 cm - 30 cm), GP2Y0A41 (4 cm - 30 cm)

What: These long-distance sensors contain their own internal preprocessing circuitry, which makes them very easy to use. The sensor's output is an analog voltage that is directly proportional to the distance of an object from the sensor. The sensor's accuracy decreases for longer distances. This sensor is ideal to make a robot aware of obstacles in its neighborhood, so it can avoid them -- or drive towards them.

How: The sensor emits infrared light, which is reflected by an object. An optical lens inside the sensor focusses this light onto a sensor array. The distance of the object determines the sharpness of the angle under which the reflected light is received, which in turn determines the position on the sensor array that the light is received. This type of sensor is therefor insensitive to the amount of reflected light, and to ambient light.

Sharp GP2D12 sensor

Connect: This sensor has three pins that you can connect to the Dwenguino expansion shield. The sensor receives its supply power thorugh two pins (5 V and GND). To make the sensor less sensitive to noise on these power lines, you should place a decoupling capacitor of 1 uF close to the sensor. The distance to the object can be measured by reading the voltage on the third pin (Vout), which again can be connected to one of the analog inputs (A0 - A5) of the Dwenguino.


If you discover an interesting type of sensor that you used on your Dwenguino, please let us know!

Related Post