Arduino sensors interfacing

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:

 

GROVE System

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).

Introduction video to Grove system starter kit:

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.

 

13 Comments

  1. Tomi Engdahl says:

    Arduino Tutorial: Temperature Sensor
    https://www.raywenderlich.com/38841/arduino-tutorial-temperature-sensor

    The problem is, standard weather apps tell you about the temperature in a nearby city or suburb – but not necessarily about extremely local conditions. And what about that aquarium you would like to monitor, or your mini indoor greenhouse?

    This is a job for the latest open source microcontroller – the Arduino.

    In this tutorial, you’ll build an Arduino project for the iPhone that lets you connect multiple temperature probes you can place in different locations and query for their readings.

    This tutorial requires some specific hardware components to interface with the temperature probes. You’ll be making use of a microcontroller (the Arduino), an Ethernet interface, and connecting status and temperature probes.

    You might have initially thought about plugging the Grove Shield in first, then placing the Ethernet Shield on top of that. Unfortunately, this won’t work due to the Grove Shield not passing the 6 pins on the back through to the front.

    To install the Grove Shield, first turn off your Arduino by disconnecting it from the USB connector.

    Carefully place the Grove Shield board in place onto the stackable headers without bending or missing any pins.

    Reading Temperatures

    Open the LEDBlinkAndEthernetFakeTemperatureJSON sketch

    Earlier in the JSON section, you had two variables, temperatureIndoor and temperatureOutdoor, that for testing purposes had hard-coded temperature values. Now comes the magic of the sensors: you’ll use these same variables, but store real temperatures in them.

    Now comes the iOS! You will build an iPhone app to get your temperatures.

    Reply
  2. Tomi Engdahl says:

    Seeed’s Grove

    dscf8958Meanwhile in China, Seeed Studios makes open-source modules, and makes them cheap. Their Grove connector uses only four pins, with power and ground among them. The have standard pinouts for UART, I2C, and for servo motors. Sensors and other analog peripherals are allocated one “primary” pin and one “secondary” and it’s assumed that you know what you’re doing. The idea behind their system is that you add a shield to your microcontroller board, and they break out the relevant pins into these four-pin Grove headers.

    This is great for small things and I2C devices, which is Seeed’s catalog, but there just aren’t enough signal pins to run SPI or an analog RGB LED, for instance. But because of the small number of pins, they use very inexpensive polarized cables and shrouds that you can’t plug in the wrong way, and that take up relatively little board space. That’s Grove’s design trade-off.

    Source: http://hackaday.com/2016/11/09/my-life-in-the-connector-zoo/

    Reply
  3. Tomi Engdahl says:

    Grove System
    http://wiki.seeed.cc/Grove_System/

    Grove is a modular, standardized connector prototyping system. Grove takes a building block approach to assembling electronics. Compared to the jumper or solder based system, it is easier to connect, experiment and build and simplifies the learning system, but not to the point where it becomes dumbed down. Some of the other prototype systems out there takes the level down to building blocks. Good stuff to be learned that way, but the Grove system allows you to build real systems. It requires some learning and expertise to hook things up.

    The Grove system consists of a base unit (stem) and various modules (twigs) with standardized connectors.

    The Base unit, generally a microprocessor, allows for easy connection of any input or output from the Grove modules. And every Grove module typically addresses a single function, such as a simple button or a more complex heart rate sensor.

    You don’t need a Base unit to connect up to Grove modules. You can use a cable (Grove to Pin Header Converter) to run from the pins on the Raspberry Pi or Arduino to the Grove connectors.

    Grove Projects

    Reply
  4. Tomi Engdahl says:

    Hobby servo motors need three wires: voltage, ground, and a signal to tell them where to point. There are three distinct ways to arrange these wires, but Futaba, HiTec, Tower, GWS, and JR servos all chose to put them in SVG (or GVS) order, and there’s no reason to buck the trend. (Airtronics, what were you thinking?!)

    SVG is also a handy pinout to use for all sorts of one-signal sensors or actuators where space is a premium

    Source: http://hackaday.com/2016/11/09/my-life-in-the-connector-zoo/

    Reply
  5. Epson Support says:

    Hii, Thanks for the sharing nice posting with us. i’m really impressed.

    Reply
  6. Contact Mcafee Antivirus Support says:

    very awesome article, thanks for the sharing with us.

    Reply
  7. Sumantha Black says:

    Hey! Nice post thanks for sharing this…..if you want any solution related to windows than visit here:

    Reply
  8. Acer Customer Service says:

    Hello there, just became aware of your site via
    Google, and discovered that it’s truly useful. I’ll be happy if you
    continue this in future.

    Reply
  9. Tomi Engdahl says:

    The 4-20 mA Current Loop
    http://hackaday.com/2017/07/19/the-4-20-ma-current-loop/

    The I/O capabilities built into most microcontrollers make it easy to measure the analog world.

    Now put a twist on it: you need to mount the sensor far from the microcontroller. The longer your wires, the bigger the voltage drop will be, until eventually your five-volt swing representing a 100° range is more like a one-volt swing. Plus your long sensor leads will act like a nice antenna to pick up all kinds of noise that’ll make digging a usable voltage signal off the line all the harder.

    Luckily, industrial process engineers figured out how to deal with these problems a long time ago by using current loops for sensing and control. The most common standard is the 4-mA-to-20-mA current loop

    The now standard 4-20 mA current loop for process control descends directly from an early innovation in industrial automation, pneumatic process control.

    While pneumatic systems are very much still in use today, especially in industries where things tend to go boom around electricity, 4-20 mA current loop systems became a de facto standard in the 1940s and 1950s.

    Current loops aren’t limited to sensors, of course. A wide range of actuators, from valves to motor drives, can be controlled by a 4-20 mA loop. Data acquisition and display are also possible, with chart recorders, gauges, and indicators all available for the loop.

    So how do you incorporate a 4-20 mA device into your latest Arduino project? Changing the current back to a voltage by putting a resistor in the loop and measuring the voltage drop across it is really all it takes. [AvE] does the math to show us that a 250-ohm resistor gives us a one-volt to five-volt swing, which is perfect for an Arduino’s analog input

    4-20mA Industrial Sensor + Arduino
    https://www.youtube.com/watch?v=6di24oIdISs

    How to build a simple 4-20mA transducer circuit on Arduino. It’s easy: add a 250 ohm resistor. If you want more protection for the Arduino, you’ll need to add zener diodes and a 10k resistor to the Arduino analog pin

    Reply
  10. Tomi Engdahl says:

    PobDuino Makes the Most of Grove
    http://hackaday.com/2017/07/27/pobduino-makes-the-most-of-grove/

    The chassis of a toy robot serves as the base of a robot built by [Jean Noel]. Called #PobDuino, the robot features two Arduino-compatible boards under the hood.

    First, a Seeeduino Lotus, a Arduino board peppered with a dozen Grove-compatible sockets. The board, which is the size of an UNO, is mounted so that the plugs project out of the front of the robot, allowing ad-hoc experimentation with the various Grove System modules.

    Robot #PobDuino
    https://hackaday.io/project/26009-robot-pobduino

    A bicephale robot, taking the best from Arduino & grove ecosystem, augmented with Flowcode graphical progamming

    Reply
  11. Tomi Engdahl says:

    Arduino Sensor Kit 37 In 1
    http://www.epanorama.net/newepa/2017/07/21/arduino-sensor-kit-37-in-1/

    Arduno neeeds sensors. Geekcreit® 37 In 1 Sensor Module Board Set Kit For Arduino Plastic Bag Package promises to give many sensors cheaply.

    Reply
  12. HP Contact Number says:

    This is my first time to visit here. I found countless interesting
    stuff in your weblog, especially in its discussion. I guess I’m not the only one having
    all the entertainment here!

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*