Skip to content

14. Networking and communications

This Week’s Bread bread this week

washtub bass pic

Assignment

This week we explored networking in many forms.

Physical Layer: wire, radio, light

Communications protocols: I2C, SPI, UART

Individual Assignment:

Design, build, and connect wired or wireless node(s)
with network or bus addresses

Group Assignment:

Send a message between two projects

Evaluated on

  • Linked to the group assignment page and reflected what you learned individually of the group assignment.
  • Documented your project.
  • Documented what you have learned from implementing networking and/or communication protocols.
  • Explained the programming process/es you used.
  • Outlined problems and how you fixed them.
  • Included design files (or linked to where they are located if you are using a board you have designed and fabricated earlier) and original code.

Individual Assignment

I decided to make a relay board for the solar electric toaster oven, my final project. I will communicate with the main controller board through I2C. This will allow me to isolate solar power from the controller board.

Here’s some images of making the relay board. The relay connects solar power to the oven heating element based on a temperature sensor in the oven. The temperature sensor is connected to the main control board (Sunduino) and communicates to the relay board via I2C. I did it this way to isolate the high voltages (up to 60 volts) and current (up to 10 amps) of the solar panel from the main control board.

Screenshot of KICAD schematic

Photo of board milling

Milled Board

stuffed board

At one point bringing the board back and forth to the lab I broke off the I2C jack in a way that was unrepairable (in the opinion of the responsible adults in the lab - Josep and Eduardo) and had to mill and stuff another board.

The second relay board didn’t work at first - I needed to do some troubleshooting and repairs. I found a broken trace that I repaired with solder. I made a design error - I misread the schematic of the relay and used the wrong pins. I repaired this with a jumper wire.

Repairs needed on relay baord

Repairs made on board

As I went through the process of getting the relay board to work for this assignment, I found that I had forgotten to solder a zero ohm resistor on one of the I2C leads and I used the wrong pin on the samd for one fo the I2C leads. Both problems were easily fixed with a zero ohm resistor, some wire for jumpers, and some solder.

Sunduino Board

I completed several versions of the controller for my final project as part of earlier assignments - I call it the Sunduino. It uses the 20 pin version of the Samd microcontroller.

Sunduino Board

Test With Arduino

Before I got started on the assignment with my Samd based boards, I decided to try making I2C communication work between two arduino boards. I used this tutorial, which uses a potentiometer on the master board to control the brightness of an LED on the slave board. It was pretty smooth working with the arduino boards - they reliably load programs from the Arduinio IDE on my computer and I had everything working in about 15 minutes.

However, for me the Samd boards are highly unreliable when I attempt to program them from the Arduino IDE on my computer (2010 macbook pro running Catalina). I have had an extremely frustrating week trying to get them to work and I am still not done. The work done by Quentin to make the Samd boards work with the arduino IDE seems really unreliable, meaning sometimes it works and sometimes it doesn’t and even simple programs using the libraries we were given fill the 16 k memory of the samd while on an arduino with an older microcntroller, 10% of the memory of the microcontroller is used. Ugh. Not sure why this fetish with the SAMD boards when they are the software we work with is so buggy.

Sure, I could program the functions directly but the whole point of this is that I want to build stuff, not dick around with low level programming tasks that have been reliably solved a long time ago by others for other boards and controllers.

OK my rant is over. For now.

Using my Samd Boards

For this assignment, I decided to simulate controlling the oven heater element with a temperature sensor in the oven. The idea is to connect a temperature sensor to the Sunduino (master) and have a relay on the relay board (slave) turn on an LED to simulate the heater element.

For the test, I used a potentiometer connected to the main control board (Sunduino)to simulate a temperature sensor based voltage divider. This way I could simulate a wide range of temperatures without having to bother with the oven at this point. I used an LED connected to the relay board to simulate the oven heating element.

Here’s a circuit diagram:

circuit diagram

Testing Each Board Separately

I decided to get each board working separately before I networked them together with I2C.

Here’s the relay board blinking an LED:

oven blink test setup

video of relay board test

relay board test computer screen

Here’s the Sunduino board reading voltages as I turn the potentiometer:

video of the Sunduiono board test

Everything Together

Next I hooked the Sunduino to the relay board via I2c.

The oven elements will be on all the time unless the oven overheats, so I implemented a maximum temperature limit. When the max temperature is exceeded, the LED goes off. Adjusting the potentiometer simulates higher or lower temperatures in the oven.

The Sunduino sends the potentiometer voltage (simulating the variable resistance of a temperature sensor) to the relay board via I2C, The relay board checks to see if the voltage represents a temperature higher than the maximum temperature fo the oven. If it does, the relay board activates a relay. The opening and closing of the relay contacts provide power to an LED, which represents the heating element in the oven.

Here’s what the setup looks like:

image with labels fo the final thing

The ESP board is only there to provide a 3.3 volt power supply

back up image of the whole thing

Note the soldering station board I made with the CNC cutter and some scrap lumber, a piece of bamboo, and one of the bamboo connectors I 3d printed.

Moving to the ESP 32 Board

I continued to have trouble getting samd based boards to program reliably with my computer and the arduino IDE. I switched out the Sunduino board for an ESP 32 based Wrover development board. In the process of doing this, I found and fixed a couple of errors in my relay board. I2C SDA was connected to the wrong pin on the Samd11. And I had forgotten to install a zero ohm bridge/jumper resistor.

Finally, I was able to get I2C to work! I tried 10k ohm pull up resistors but they didn’t make any difference. The ESp 32 has internal pull-up resistors on I2C.

Here’s a diagram of the hookup between the ESP board and the samd based relay board.

Diagram of Samd hookup

Here’s picture of the hookup:

Pic of hookup

Here’s a video of the whole thing working. I turn a potentiometer connected to the esp 32 board and it sends the potentiometer wiper voltage to the relay board. The relay board compares the wiper voltage to a set point - if the wiper voltage is higher than the set point the oven is off. Otherwise it is on.

Video of the ESP32 and Relay Board communicating over I2C

The wiper voltage simulates a voltage divider based temperature sensor. If the oven temperature is higher than the maximum temperature for safe operation of the oven, the relay board shuts the oven element (in this case an LED that represents the element) off.

Files:

Software

Arduino Sketch for the I2C master

Arduino Sketch for the I2c Slave

Hardware

Kicad files for relay board

Kicad .pro file

Kicad schematic

Kicad PCB layout

Group Assignment

For the group assignment we connected several of our projects together via different physical links ( wire, IR) and different protocols ( Serial communication, MQTT Broker/Message Bus)

Here is the more ambitious layout that we started with, we ran out of time to implement all of it.

Board with group project connections

Group assignment is here


Last update: November 10, 2022