spirosgyros.net

# Maximizing Raspberry Pi Pico's Potential with ADS1115 Multiplexing

Written on

Chapter 1: Introduction to Raspberry Pi Pico and Its Challenges

The Raspberry Pi Pico stands out as a robust and adaptable microcontroller that has won over electronics and programming enthusiasts alike. However, it does come with a notable constraint: the limited number of analog input pins. This limitation can impede the development of more intricate projects. Fortunately, there is a sophisticated workaround: employing signal multiplexing through the ADS1115.

Understanding Signal Multiplexing

Signal multiplexing is a valuable method that permits the switching between several signal sources using a single analog input. For instance, if you wish to track the temperature from multiple sensors but your Raspberry Pi Pico has only a single analog input pin, you would be restricted to monitoring one sensor at a time without multiplexing. This is far from ideal for numerous applications.

By using multiplexing, your Raspberry Pi Pico can toggle between different analog input signals and read them in a sequential manner. This allows the connection of multiple sensors or data sources to the microcontroller, even when only one analog input pin is available.

The ADS1115 Analog-to-Digital Converter (ADC)

To implement signal multiplexing, an Analog-to-Digital Converter (ADC) like the ADS1115 is essential. This ADC connects to the Raspberry Pi Pico via the I2C bus and boasts features such as a 16-bit resolution, high accuracy, and the capability to handle up to four analog input channels.

The ADS1115 acts as a smart switch, enabling your Raspberry Pi Pico to choose the analog input channel it wishes to read at any moment. It converts the analog signal into a digital value that the Raspberry Pi Pico can process.

ADS1115 ADC Overview

Expanding Input Channels with ADS1115

With a grasp of signal multiplexing and the introduction of the ADS1115, let’s delve into how to further increase input channels. This expansion is vital for projects that require monitoring various sensors or data sources.

A notable feature of the ADS1115 is its ability to incorporate multiple converters into your project. Each ADS1115 can be individually addressed using ADDR pins (A0, A1), allowing for different I2C addresses. This means multiple ADS1115 devices can connect to the same I2C bus without any address conflicts.

Additionally, incorporating resistors and capacitors into your setup is crucial. Pull-up resistors on the SDA and SCL lines are necessary for stable I2C communication between the Raspberry Pi Pico and the ADS1115. Capacitors can help smooth the analog signal, reducing noise and enhancing measurement accuracy.

Chapter 2: Practical Application — Smart Irrigation System

To demonstrate the effectiveness of signal multiplexing with the ADS1115, let’s examine a practical application: a smart irrigation system. In this scenario, monitoring soil moisture at multiple locations is key to ensuring that plants receive adequate watering.

Imagine having five soil moisture sensors spread throughout your garden. Without signal multiplexing, you would require five separate analog input pins on your Raspberry Pi Pico, which may not be feasible. However, with the ADS1115 and multiplexing, these five sensors can connect to a single Raspberry Pi Pico, allowing for sequential readings of soil moisture data from each zone.

This streamlines the setup of your smart irrigation system while facilitating efficient water management for your plants.

The first video titled "How to Connect ADS1115 to Raspberry Pi - Measure Analog Signals with MQ135 (Part 1)" offers insights on connecting the ADS1115 to the Raspberry Pi, showcasing how to measure various analog signals effectively.

Implementation in MicroPython

To bring signal multiplexing with the ADS1115 to life on your Raspberry Pi Pico, we will leverage the MicroPython library “uads1115,” created by David Goncalves. This library simplifies the use of the ADS1115 with MicroPython. You can download the library from the following link: Python ADS1115.

Once the library is downloaded, you can integrate the following script to manage two ADS1115 devices and read data from multiple soil moisture sensors. Ensure to import the “uads1115” library into your MicroPython project:

import machine

from machine import ADC, Pin

from stepper import Stepper

import uads1115

import machine

import time

from time import sleep

def get_moisture():

i2c = machine.I2C(1, freq=100000, scl=machine.Pin(15), sda=machine.Pin(14))

i2clist = i2c.scan()

for z in i2clist:

print('Found Controller on I2C-Bus 2 at: {:s}'.format(hex(z)))

chip_01 = uads1115.uads1115(i2c)

chip_01.__ads_address(i2clist[0])

chip_02 = uads1115.uads1115(i2c)

chip_02.__ads_address(i2clist[1])

start = time.ticks_us()

dec_t = 30000000

nmbr_iteration = 0

get_data = [0,0,0,0,0,0,0,0]

while (time.ticks_us() - start) < dec_t:

sleep(3)

sens_01 = [chip_01.ReadSingleEnded(port=x, fsr=6144, sps=32) for x in range(0,4)]

sens_02 = [chip_02.ReadSingleEnded(port=x, fsr=6144, sps=32) for x in range(0,4)]

get_sensor = sens_01 + sens_02

get_data = [get_data[i] + get_sensor[i] for i in range(len(get_sensor))]

print("***********************")

nmbr_iteration += 1

return ([get_data[i]/nmbr_iteration for i in range(len(get_data))])

while True:

sleep(1)

print("###########################")

get_values = get_moisture()

print(get_values)

This script utilizes two ADS1115 devices to collect data from eight soil moisture sensors, averaging multiple readings for accuracy. Customize the script as needed for your specific application.

The second video titled "Video Request: Read multiple ADCs ADS1115 PI Pico Micropython" provides further insights on using multiple ADS1115 units with the Raspberry Pi Pico, demonstrating effective data reading techniques.

Conclusion

In summary, signal multiplexing using the ADS1115 is a potent technique that enhances the functionality of your Raspberry Pi Pico. Whether engaged in environmental monitoring, device control, or data collection projects, this approach allows for the full utilization of your microcontroller's capabilities.

Feel free to delve deeper into this technique and adapt it to your projects. The ADS1115, with its high resolution and accuracy, presents endless opportunities for Raspberry Pi Pico enthusiasts.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

# 7 Key Life Lessons Inspired by Oprah Winfrey's Wisdom

Explore seven valuable life lessons inspired by Oprah Winfrey, focusing on personal growth, self-acceptance, and the importance of wisdom.

Understanding the Theory of Relativity: More Than Just a Theory

Explore why the theory of relativity is more than a mere theory, addressing common misconceptions about scientific theories.

Grasping With Common Sense: Leveraging LLMs for Robotics

Exploring how large language models can enhance robotic grasping and manipulation through common sense reasoning.