Raspberry Pi
There are multiple ways to take advantage of the DUELink ecosystem with the entire Raspberry Pi product line.
RPI and RPI Zero
For Raspberry Pi and Raspberry Pi Zero, we recommend using DuePi Hat.
This hat uses UART Intrface. It includes a display, buzzer, terminal block for wiring, and a Downlink socket to extend your RPI with hundreds of available sensors and actuators.
Everything is accessible through any of the RPI supported Coding Languages, such as Python .
# Show IP address on display
import sys
import serial
import time
import socket
from DUELink.DUELinkController import DUELinkController
def get_ip_address():
try:
# Get all IP addresses associated with the hostname, filtering out 127.0.0.1
ips = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")]
if ips:
return ips[0] # Returns the first non-loopback IP address found
else:
# If no non-loopback IP is found, try connecting to an external server to determine the IP used
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80)) # Connect to Google's DNS server (doesn't send data, just sets up connection)
ip = s.getsockname()[0]
s.close()
return ip
except socket.error:
return None
myip = get_ip_address()
# DUELink connection
availablePort = DUELinkController.GetConnectionPort()
duelink = DUELinkController("/dev/ttyAMA0") # uart port define
# DUELink graphics
# Show IP address on screen
duelink.Graphics.Clear(1)
duelink.Graphics.Text("--DUELink--", 0, 33,5)
duelink.Graphics.Text("My IP:" + myip, 0, 1,20)
duelink.Graphics.Show()
# Beep once a second
while True:
duelink.Sound.Beep(14,1000,100)
time.sleep(1)
See the Python language page for more examples.
Another option is to use use breakout boards that bring the RPI’s I2C bus to a standard JST socket, like the Sparkfun Qwiic Shim for Raspberry Pi or Sparkfun Qwiic pHat.
Unlike DuePi, these acessories connect to the I2C bus. Here is the same code as before but we are now using the I2C Interface.
When using the Qwiic pHat, only use one JST connectors as Downlink. You can still use the other sockets to connect other, non-DUELink I2C things!
Raspberry Pi Pico
Using Raspberry Pi Pico is easily achievable done using DuePico. It includes several things, such as a display to help you with printing diagnostics info.
And of course it includes a Downlink socket to help you Daisylink modules.
Visit the MicroPython page to see how Raspberry Pi Pico can be used with DUELink.
RP2350 & RP2040
Beyond the official RPI Pico, using any board with a RPI microcontroller is possible. We recommend ones with a JST connector, like Adafruit QT Py RP2040 or Sparkfun Pro Micro RP2350. You can as well use the Breakout to wire a Downlink connection to any board.
Pay attention to how much power these little circuits can provide. Consider adding a Power Inject module to add more juice!
See the MicroPython for code examples.