There is a wide variety of sensor0s. A sensor can be used to measure all manner of different things including temperature, light, vibrations… heck even air quality and your heartbeat! By connecting a sensor to Arduino board you can easily read sensor values and have your own code to process them. If you connect your Arduino to the internet you can monitor it from anywhere and share it with your friends.
This article is about interfacing sensors to Arduino boards.
Interfacing with Hardware article cover the hardware and software setup required to connect an Arduino device with a variety of electronic parts, chips and devices.
You can wire various sensors diretly to Arduino pins or use Arduino shields. Wiring one or two sensors directly to Arduino pins works OK, but with greater number of sensors this is not very convient as you have easily a hard to manage wiring mess.
Arduino Sensor shield
One way to easily connect many sensors to one Arduino board without hige wiring mess is to use Arduino Sensor Shield. Arduino Sensor Shield v4.0 is an easy way to connect input and output devices to Arduino. Arduino Sensor Shield provides three pin (ground, voltage, signal) interface for connecting all kinds of sensors (potentiometer, button, LDR etc.) and output devices (relay cards, servos etc..) to Arduino. The signal pins map directly to the different Arduino, so testing sensor shield can be done for example with StandardFirmata and toolduino.
Arduino sensor shield article has a good overview of the features:
Sensor Shield is an easy way to connect INPUT DEVICES and OUTPUT DEVICES to Arduino. The Sensor Shield’s purpose is make it easy to connect cables and devices to the correct Arduino pins: It is a passive circuit board that simply connects the Arduino pins to many connectors. Those three pin connectors are ready to use to connect to various devices like Servos and Sensors with simple cables – allows you to connect to various modules like sensors, servos, relays, buttons, potentiometers just plug and play!
Each Port has 3 pins named with GVS letters:
G = Ground (cable code black)
V = Voltage +5V (cable color red)
S = Signal (cable color white or yellow)
By the way pinout is same as used in RC servos:
SIGNAL WIRE: Yellow, Orange or White (brand specific)
PLUS WIRE: RED
MINUS WIRE: Black or Brown
Those three pin ports are available as pin rows on the top of the circuit board. There are 13 ports prepared for Digital IO: digital input modules, digital output modules or servos. Depending on the programming different ports can be used as inputs and outputs. The digital ports have 5V power and TTL level digital signal pin (that can be depending on Arduino programming be used as input or output). A typical digital sensor outputs TTL level signal (logic 0 or 1) that connects to Arduino pin that is configured as input. Typical output devices either take digital 0/1 output signal from Arduino (for example relays, SSRs, on/off LEDs,. etc) or PWM signal (LED dimming, RC servo motors etc..). There are also applications where some sensors with built-in “smart” is connected to sensor port, and with suitable software the port can be used as one wire serial bus for input (1-wire DS1820 temprature sensor, DHT11, DHT22, etc.) or output device (LED with WS2812)
In addition to digital ports there are analog ports. There are 6 analog inputs that accept normally 0..5V DC input voltage (voltage range can be adjusted with Arduino programming and/or reference voltage setting). Typically Arduino sensors are designed such that they give out voltage in that 0..5V range. The pinout is same as in digital ports. In addition to pin rows on the circuit board those same analog inputs are also available as Buckled Analog Ports on the side of the circuit board to connect sensors with matching connectors.
In addition to those ports the sensor shield has Buckled Communication Port that is selectable between I2C and UART. It can be used to connect devices that use serial port communications or I2C bus to Arduino board.
This shield doesn’t do anything magical, and you won’t find any smoke and mirrors. It does provide easy, plug-in connectivity to the data pins on your Arduino. The connectors are grouped in a logical manner and are well-labeled
These shields are great and make it so much easier to work with Arduino when you need to connect input and output devices (and who doesn’t need to do that?). The digital and analog ports are broken out and it makes it so much easier to connect devices and cables using flat simple cables or buckled connectors.
So what kind of circuits those Arduino sensors are? Typicaly they are are usully quite simple circuits. Here is an example analog sensor circuit from Adafruit article Using a Photocell:
The more lights hits LDR, the smaller it’s resistance gets and higher voltage goes to the alogue input. When there is no light the voltage is almost 0V and when LDR is in bright light the output is alsmot 5V. Similar LDR sensors are available cheaply.
When building digital sensors check out this example circuit from Pushbuttons and tilt sensors/switches: how they work and some Arduino usage examples article. On the left side ircuit you see a simple switch circuit that gives out logic 0 (0V) when switch is open and logic 1 (5V) then button is pressed. On he circuit the button and 10 kohm resistor are pretty normal for this kind of circuit, but please take a none on the 220 ohms resistor: is a protection component that avoid damaging Arduino in case the button is pressed and Arduino I/O pin is accidentally configured to be output (the resistor limits the current that flows to pin to safe value that does not damage anything).
The Arduino sensor shield system is originally designed for systems that use 5V. There are also 3.3V systems that use the same pin-out for sensor connection and supply 3.3V instead of 5V (for example ARM based Arduino or ESP8266 NodeMcu breakout board). If you plan to use 3.3V system, you need to check case-by-case per sensor if the specific sensor you plan to use really works well also with 3.3V – some sensors only work with 5V and some work well with both 3.3V and 5V.
Here is one introduction video to using Arduino sensor shield:
There is another popular Arduno sensor system besides Sensor Shield. It is called Grove System. Grove compatible modules feature special 4 pin locking connectors with standardized pinouts for use with a variety of microcontroller GPIO pins. Grove system allows easily connecting Grove modules to your Arduino compatible microcontroller. – or Raspberry Pi.
Grove is a modular, ready-to-use tool set. Much like Lego, it takes a building block approach to assembling electronics. The Grove system consists of a base shield and various modules with standardized connectors. The Grove uses 4 pin connector that contains ground, power (5V or 3.3V) and two signal pins. There are different types of ports: Digital ports, Analog input ports and I2C ports.
Seeed Studio’s Grove is an ingenious way to create hardware interoperability between accessories made for maker. It uses a standard socket & pinout, supports more than 100 accessories already (from sensors to output, from displays to wireless communication). Usually these are accessed via a special shield (Grove base shield): those breakout boards make several microcontroller & computer platforms to be able to use these accessories (full scale Arduinos, Raspberry Pi, Intel Edison and Galileo, VIA VAB-820, and so on).
The Base shield allows for easy connection of any microprocessor input or output from the Grove modules, and every Grove module addresses a single function, such as a simple button or a more complex heart rate sensor. Check out Introduction to Grove for some more details.
Here are some details of Grove – Base Shield V1.3 for Arduino:
- SeeeduinoV2.21(168p and 328p),Arduino UNO and Duemilanove compatible
- Compatible with all Grove modules
- 7 Digital connectors (D2-D8)
- 4 Analog connectors (A0-A3)
- 4 I2C sockets
- NO SPI socket
- UART/D0-D1 connector
- ISP/ICSP header
- Green Power indicator LED
- Right angle reset button with red LED reset indicator
- Stacking connectors
- Simplified screen printing
Grove sensors use a special socket, a 4 pin JST with two power lines and two data. You can see that each of the connectors has two digital pins connected to it and then V (5V) and G (GND). The data pins are the pins you connect to the pins that are used in your sketch. Depending on the sensor type the sensor can use one of the data pins or both data pins.
To my understanding Grove system started as 5V system but nowdays mostly supports both 5V and 3.3V voltages. Every Grove connector has four wires, one of which is Vcc. However, not every micro-controller main board needs a supply voltage of 5V, some need 3.3V. Depending on the microcontroller platform you use, the voltage your Grove shield supplies to the sensors is 5V (for exmaple with Arduino Uno) or 3.3V (for example ARM based Arduinos and Raspberry Pi).
Sensor Shield vs. GROVE System
Both Sensor shield and Grove systems seem to be nice tools to connect sensors to Arduino and other microcontroller boards.
Sensor shield cheaper is cheaper and very many cheap sensors from many suppliers – but more messy wiring (can plug wires easily on on wrong way, some differences on different sensors 3 pin pinouts so direct 3 pin cable not always right.. etc.)
Grove seems to be to me more “ready product” but more expensive. The connectors have well defined pinouts and you can’t plug then wrong way. Grove shields are nowdays available for many other mcrocntroller platforms than just Arduino (for example Raspberry Pi).
Those Grove and Sensor shield systems are in many ways similar, so it is possible to adapt many sensors from one to another with converter cables (for example connect Sensor shield sensor to Grove).
I think both of those systems have their their places on the market.