Sensors

10. Sensors#

It is of no use to be able to connect to a microprocessor and log values from it if we can’t make measurements.

This section will cover how to use sensors to measure some type of input, be that temperature, light levels or something else.

There are two main types of sensor you will meet

  1. Analog

  2. Digital

Analog require an input voltage and then return a voltage which is proportional to the signal that is measured.

Digital also require an input voltage but the microprocessor then talks to the sensor over a digital interface, for example I2C.

Voltage levels

Sensors often use different voltage levels. Very common is the 5 V level. Arduinos also work with 5 V so there is rarely an issue.

Picos on the other hand work with 3.3 V levels. At best connecting a 5 V sensor to a Pico won’t work. At worst it has the potential to damage the Pico as too high a voltage is applied. We will explain about potential dividers and level shifters later

Sending data digitally#

Most of the time, storing data requires us to use some external device. Often times, we need to use communication protocols to send and receive data from these external devices.

There are several different protocols for digitally transmitting data between devices. At their cores, they all involve sending a series of HIGH/LOW voltages to represent 1s and 0s in binary. These binary bits are then read and converted to numbers, letters or symbols.

The main communication protocols used by more advanced sensors and data transmission devices are:

  • SPI

  • UART

  • I2C

Get with the protocol

To get a better understanding of how this digital communication works, you can check out these really helpful guides:

(Note: For SPI, the acronyms MOSI and MISO are outdated and have been replaced by TX and RX respectively.)

Microprocessors can handle these type of communication protocol to send and recieve data. However, they normally do so with specific pins