1

I live in Portugal, and I have bought my RPi3 model B. Now I want to get started, but I don't really know what type of specifications to look for when buying useful sensors to start some projects with the new machine.

For example: If I need to buy some random LED or even a wireless adapter for my RPi, do I have to write "wireless adapter for Raspberry Pi 3 Model B"? Or is there some gear that is not specifically built for RPi, but I can use it too? I'm new to this world and I'm trying to educate myself in how to look for what I need.

Can somebody help me please?

Aurora0001
  • 6,308
  • 3
  • 23
  • 38
xyax
  • 11
  • 4
  • just in case you do not know The MagPi Magazine: https://www.raspberrypi.org/magpi/issues/ (you can download every issue for free). I recommend https://www.raspberrypi.org/magpi/issues/essentials-gpio-zero-v1/ and the three project books – Fabian Jan 30 '18 at 19:07

3 Answers3

2

You don't need sensors specific to the Raspberry Pi, no.

Your specific mention of wireless adapter is confusing since the Pi 3 has wifi built-in, but for other models, every USB wifi adapter that I've tried has worked since the most common wifi chipsets are supported. I've also never had an issue using keyboards or mice, including wireless ones from Logitech.

As for sensors, it would help to know what you're trying to sense. Most sensors output an analog value-- a variable voltage-- which you cannot read directly with a digital input on the Pi. You will need to interface through an ADC (analog-to-digital converter) via the SPI or I2C protocol, or you may find sensors that do that already, so you won't need a separate ADC. Sensors might use SPI, I2C, or 1-wire. I'd start with a simple example using I2C, since I2C is a fine way to communicate with many devices, both input and output.

salsaman
  • 46
  • 2
2

As has already been said, no you do not need to buy things made specifically for the Pi -- and note that occasionally things are sold "for the pi" which are not easily compatible, so even if this is claimed, you need to know a few things you can check to make sure.

Most of the information here applies to specifically to sensors and gadgets; the issue of voltage (discussed first) applies to just about anything.

Logic Level

The GPIOs on the Pi use 3.3V logic. If you are connecting a sensor, it must also use 3.3V logic. That and 5V are common, but do not connect a 5V device directly to a Pi. If there is such a thing you really want to use, you need a level shifter in the middle.

There is a difference between input (power) and logic voltage. Devices that require 5V power but operate with 3.3V logic are common (the Raspberry Pi being an example of such). Not all of the 40 pins on the Pi breakout are actually GPIO ("general purpose input/output") pins; some of them are power (either 3.3V or 5V) or ground. The GPIOs are low current, perhaps 15-20 mA each and not more than 50-100 mA in total. However, the 3.3V and 5V power pins can provide much more than this, in the range of 1 amp total.

Some devices use dual logic, e.g., either 3.3V or 5V. Sometimes this is dependant on the input voltage, sometimes it is switchable.

Digital vs. Analog

The Pi GPIOs are digital, meaning they read either a high or low value (there is a third state that applies to an input not connected to anything called "floating", aka. high impedance or high-Z, but it will read arbitrarily and unpredictably as either high or low). This is important because many sensors are analog, meaning they are controlled by, or output, a linear voltage value within a range (e.g., between 0 and 3.3V). Generally there is a number of significant bits applied to the range; you may understand this concept from programming. For example, an 8-bit precision integral (as in, whole numbers) value ranges from 0 to 255, and a 10-bit precision value ranges from 0 to 1023.

Digital logic is equivalent to a 1 bit value, which is either 0 or 1. Obviously this is not much good for interfacing with analog devices directly. To do so, you need an ADC (analog to digital converter) and/or a DAC (digital to analog converter). These most often connect to one of the serial buses.

Serial Buses

The Pi is equipped with a number of different serial buses implemented in hardware and broken out on GPIO pins. Many sensors also use such buses; they can be used for complex, relatively high speed data exchange (although not nearly as fast as the USB, which is also a style of serial bus). These are:

  • UART: (Universal Asynchronous Receiver Transmitter) This is a minimal protocol that is easy to program with and highly adaptable to a wide range of purposes. The Pi's UART is full duplex, but does not have hardware flow control. It uses two pins (RX = receiver, TX = transmitter). Although it is not impossible to daisy chain or connect more than two UART devices through a simple hub, the relationships are genrally one to one, i.e., you can only connect one thing to the UART at a time.

    Sensors generally don't use UART, probably because it is very unstructured, meaning it would require complex additional circuitry to work (which is more or less what the next two bus types are). However, microcontrollers commonly do.

  • I2C: (Inter-Intergrated Circuit) I2C is a more highly structured and standardized protocol than UART used for exchanging short, simple messages with simple devices such as many sensors. It is master/slave based, and uses 7-bit addressing to allow for multiple slaves. The Pi is generally the master, and you may connect quite a few slaves to the same two I2C (SDA = data, SCL = clock) pins simultaneously providing they all use different addresses. Some devices can have an address set, so that more than one can be used simultaneously, and some are hardwired to use only one address.

  • SPI: (Serial Peripheral Interface) SPI essentially uses three pins, in, out, and clock, meaning it has an advantage in transfer speed to I2C (where the same data line must alternate sending and receiving), plus two more "chip select" pins. The latter are used to toggle connected devices, meaning in a basic configuration there can only be two things connected to the SPI bus at a time.

There is a bit more to the GPIOs hardware wise; for example, there are several PWM (Pulse Width Modulation) clocks available. However the serial buses are the primary means of communication with sensors.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
1

I suggest you always add raspberry pi to your search terms.

E.g. if you are interested in temperature sensors search for "raspberry pi temperature sensors". That should give you a short list of potential sensors.

Then when you have a sensor in mind also include raspberry pi.

E.g.if you are interested in the DHT22 temperature sensor search for "raspberry pi DHT22". That should give you a list of implementations on the Pi.

Of course if you are interested in a particular programming language or library also include that in the search terms.

joan
  • 71,024
  • 5
  • 73
  • 106