Leanpub Header

Skip to main content

Using Sensors with the Raspberry Pi Pico

Want to use sensors in your next Raspberry Pi Pico but don't know which sensor to use, how to connect it or how to use it in your code? This book is for you!

Here you will find detailed explanations of how sensors work, how to connect them to the Pi Pico and how to use them in C/C++, MicroPython and CircuitPython.

Free With Membership

The author is letting you choose the price you pay for this book!

Pick Your Price...

Buying multiple copies for your team? See below for a discount!

PDF
EPUB
WEB
84
Readers
531
Pages
About

About

About the Book

In this book, you will learn about sensors and how to use them with the Raspberry Pi Pico. You will find detailed explanations of how sensors work, how to connect them to the Pi Pico, and how to use them with C/C++ (using the official SDK or the Arduino IDE), MicroPython, and CircuitPython.

The book is now complete.

Price

Pick Your Price...

With Membership

Free!

$13.99

You pay

$13.99

Author earns

$11.19
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 0)

0
The author will earn $0.00 from your purchase!
You can get credits monthly with a Reader Membership

Team Discounts

Team Discounts

Get a team discount on this book!

  • Up to 3 members

    Minimum price
    $27.00
    Suggested price
    $42.00
  • Up to 5 members

    Minimum price
    $43.00
    Suggested price
    $67.00
  • Up to 10 members

    Minimum price
    $76.00
    Suggested price
    $118.00
  • Up to 15 members

    Minimum price
    $109.00
    Suggested price
    $169.00
  • Up to 25 members

    Minimum price
    $164.00
    Suggested price
    $254.00

Author

About the Author

Daniel Quadros

Hi, my name is Daniel Quadros.

I am an Electronic Engineer, but I have always worked as a software developer. Hardware is a hobby for me, and for the last two decades, I had a lot of fun with microcontrollers and participating in the Garoa Hacker Clube.

I have a blog and YouTube channel, both in Portuguese (I live in Brazil).  More recently, I started a blog (in English) about my experiences with the Raspberry Pi Pico (and other boards based on the RP2040).

In the 80s I wrote a few books about programming the IBM PC in Assembly language. It took me a long time, but I've started writing books again!

Translations

Translations

Contents

Table of Contents

Introduction

  1. The Raspberry Pi Pico
  2. Getting the Example Code
  3. Using the Examples
  4. Organization of This Book
  5. Acknowledgments
  6. How to Send Feedback

Using Sensors

  1. Measuring What We Really Want
  2. A Sensor Can Affect What You Are Measuring
  3. Accuracy and Resolution
  4. ADC Errors
  5. Averaging Readings
  6. Calibration
  7. Readings Validation

Programming the Raspberry Pi Pico

  1. Libraries
  2. The Official C/C++ SDK
  3. The Arduino IDE
  4. MicroPython
  5. CircuitPython
  6. Thonny IDE
  7. Seeing Program Output
  8. Which Environment Should I Use?

Interfaces and Protocols

  1. A Little Bit of Electronics
  2. A General View of Interfaces
  3. The ADC - Analog to Digital Converter
  4. Connecting Digital Signals from Sensors to the Pico
  5. GPIO - General Purpose (Digital) Input and Output
  6. UART - Universal Asynchronous Receiver and Transceiver
  7. SPI - Serial Peripheral Interface
  8. I2C

Basic Digital Sensors

  1. Read This Before Trying the Examples
  2. Buttons
  3. Reed Switch
  4. Keypads
  5. Vibration Sensor (SW-420)
  6. Presence Sensor (PIR)
  7. Flame Sensor
  8. Digital Sound Sensor
  9. MQ Gas Sensors
  10. Digital Hall Effect Sensors

Analog Sensors

  1. Potentiometers
  2. Analog Joysticks
  3. Light-Dependent Resistors (LDR)
  4. Phototransistor
  5. Using LEDs as a Light Sensor
  6. Gas Sensor
  7. Analog Hall Effect Sensor

Temperature Sensors

  1. Thermistor
  2. LM35D and TMP36
  3. DS18B20
  4. DHT11 and DHT22
  5. LM75A
  6. HDC1080
  7. MCP9808
  8. AHT10
  9. Sensors Comparison Table

Atmospheric Pressure Sensors

  1. BMP085 and BMP180
  2. BMP280 and BME280
  3. BMP390
  4. Sensors Comparison Table

Electronic Compass, Accelerometers, and Gyroscopes

  1. HMC5883L, HMC5983, and QMC5883L 3-Axis Magnetic Sensor
  2. ADXL345 3-Axis Accelerometer
  3. MMA8452 3-Axis Accelerometer
  4. MPU6050 3-Axis Accelerometer and Gyroscope
  5. Sensors Comparison Table

Miscellaneous Sensors

  1. HC-SR04 Ultrasonic Sensor
  2. Rotary Encoder
  3. Load Cell (Strain Gauge)
  4. iButton

Fingerprint Sensors

  1. Fingerprints Basics
  2. FPM10A Sensor Protocol
  3. Sensor Configuration
  4. Enrolling a Fingerprint
  5. Identifying a Fingerprint
  6. Transferring the Image and the Template
  7. Fingerprint Sensor Example

RFID

  1. RFID 125kHz
  2. MIFARE and NFC

Conclusion

  1. Choosing Sensors and Using Them Correctly
  2. Using a New Sensor
  3. Writing Code and Using Libraries
  4. What’s Next?

Appendix A - Other Boards Based on the RP2040 Microcontroller

  1. Adafruit Feather RP2040
  2. SeeedStudio XIAO RP2040
  3. Arduino Nano RP2040 Connect
  4. Raspberry Pi Pico W

Appendix B - Non-Original Sensors

  1. Non-original DS18B20 Temperature Sensors
  2. Conterfeit MPU6050 Accelerometer

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub