Networking and Communications

Hero Shots

Click Here for Our Group Assignment

Networking Satshakit with an Arduino and an ATtiny44




Nano Network




Satshakit Master of Nano Slaves



Initial Reaction

Holy acronym soup! I have no idea what I just watched. I just saw a 75 minute introductory lecture on networking, and I am honestly not sure I can even tell you what the term actually even means. I mean, I have used WiFi and bluetooth on my devices, but I have definitely never created any devices that used them. I think I will try to add a remote control to my final project for this week's assignment, but I'm not even sure what technology those cheapo remotes use. I've got work to do.

After Local Workshop

We did not have a local workshop this week. Now I am legit worried haha. Roland assures me that this topic is not as complicated as it seems and I can do it, so I am headed to the lab now to see what I can learn.

Electronics CAD

Creating a Wired I2C Network

Prep Work

As it turns out, the topic is exactly as complicated as it seems, but Roland did a really great job of explaining the basics to me. We spent a couple hours playing with four Arduino Nano's and a breadboard communicating via an I2C bus. After that, I felt significantly better. I will have no chance to be able to troubleshoot the way that he does, since he knows WAY more about this stuff than I do and has a much larger toolbox so to speak, but I feel like hopefully I should at least be able to recreate what we did using my own board. In the interest of being able to actually complete and submit an assignment for this topic, I decided to focus my efforts exclusively on the I2C serial communication protocol, instead of trying out multiple protocols. I have ordered a remote for my final project, but it's in the mail so for now I will just do some experimenting. I started by connecting four Arduino Nano's together in a bus via their SDA and SCL pins using the I2C serial communication protocol.

The Plan

The idea was to set one up to be the master sending instructions, and the other three to be slaves listening for instructions and then executing them.

Wire.h

Then I installed the Wire library for the Arduino IDE.

Schematic for I2C Networking

Here is the original schematic with four Arduino Nanos. The final circuit is the same, we only replaced two of the Nanos with the Satshakit and with Roland's ATtiny board that was controlling the Hall sensor.

Getting Hooked Up

I used the pinout for the Arduino Nano and hooked everything up starting with the I2C bus.

Altering the Example Code

And then iteratively changed the example codes from the Wire library making sure that they continued to function as intended with each change.

Master Writer Code

The Master Writer example code didn't need much alteration for my purposes. Basically I just needed to repeat the given chunk of code three times since I wanted three slaves on my network.

Upload to Master

And then I uploaded it to the Master Arduino.

Slave Receiver Code

The approach was similar for the Slave Receivers, but it took a little more doing since I wanted to see the LEDs blinking instead of only monitoring on the serial monitor. I used the digitalWrite and Wire.read commands with a while-loop to register when a serial event takes place and to change the state of the built-in LED each time a message is received.

Upload to Slaves

Once I had sufficiently changed the example code to suit my purposes, I uploaded it to the three slave receivers.

Success



In the end, I was able to get all the slaves to blink their LEDs in succession as they received messages from the master.

Using My Own Board

Arduino as ISP

To program my own board, I decided to use a spare Arduino Uno once again. So I started by uploading the Arduino ISP program to the Uno.

Not Uploading

Then I tried uploading the master writer program to the Satshakit, but at first it wouldn't load. I double checked everything using my pinout, but it was all connected properly...

USE_OLD_STYLE_WIRING

...so then I googled it. Turns out, when using the Arduino as ISP to program the ATmega328P, you need to scroll down in the ArduinoISP code and uncomment the line to USE_OLD_STYLE_WIRING.

Still Not Working

I tried uploading the code to my board once again, and once again I was getting errors that prevented the upload.

Old Bootloader

So I googled the problem some more and found that when I USE_OLD_STYLE_WIRING, I also have to tell the IDE what I have done. So in the tools menu, I changed the processor to the old bootloader for the ATmega328P.

Finally!

I tried uploading with the new (old) processor, and it finally worked.

Fun

Although it was challenging to start this subject literally from scratch, the help I got from Roland and the nice people on the internet made it possible. I actually really enjoyed this project. I learned a lot and I got to spend some quality time with my group learning how several different items can be networked during the group project.

Hero Vid



I was really pleased with the result. I was able to accomplish this week's assignment AND I finally had a chance to put my board through some real testing. I am feeling satisfied.