13. Networking and Communications

This week, I worked on communication between several microcontrollers.

Master Board

Since I had used I2C in previous weeks for the OLED screen, and I wanted to include other modules along with it, I decided to network using I2C. I wasn’t entirely sure of how it could communicate with multiple devices, so I looked at a couple of tutorials such as this one.

Designing Master

Once I had a general idea of how I2C worked, I quickly designed a master board with multiple headers for SDA, SCL, 5V, and GND connected. I also included an LED to test reading from the slave modules. I used a Xiao RP2040 chip as the microcontroller because I plant to use that for my final project.

INSERT KICAD STUFF

Looking back at the board design, I probably should have placed the LED on an analog pin for easier reading of sensors, and I could have allowed more ports connected to headers to get more use out of the board. However, this would work well for the week.

I milled and stuffed the board, and it seemed to work well. Here is the final board: The Flubben Master:

INSERT FLUBBEN MASTER

Testing and Programming

I wanted to use my Connor Cruz 2.0 :) board and my Connor Cruz :) board to connect to the SDA and SCL lines the Xiao RP2040 was connected to. Alas, when I was handling the Connor Cruz 2.0, I accidentally removed one of the headers, which caused 3 pads to rip. Since they were connected to multiple traces, I decided to simply remake the board.

SHOW DEAD CONNOR CRUZ 2.0

While that board was broken, I tried testing the Connor Cruz (1.0) with the Flubben Master. I needed to write code for both microcontrollers to determine their function. For both, I used the Wire library, which is a library for communication between I2C devices.

For the master board, I wrote two separate functions depending on whether I wanted to receive input from the slave modules or output to the slave modules. For receiving input, I used the requestFrom() and read() functions to obtain data from the slave modules.