14. Networking and communications (CLS Students)¶
Group 1: Nick, Alaric, Jada, Jack¶
For this assignment, the four rigged multiple arudinos together and got them to communicate via serial to eachother which could be read to the Serial monitor.
They began with just 2 arudinos. Nick and Jack wrote the code and Nick and Jada did the wiring. We got this to work:
From here, Alaric added compatibility for a third arduino through the code and Nick wired it. Jack took photos and videos and Jada grabbed more components and wires.
The third chained arudino worked:
Nick wrote the above documentation whilst the images and videos were uploaded by the people who took them.
Group 2: Pari, Andrew, Aarush¶
This week Pari, Andrew, and Aarush worked together to network Arduino boards together using the I2C protocol. Prior to the networking they received a short lecture on I2C from a lab guru Dr. Harris.
Next they started with networking two arduinos, where they got some inspiration from this helpful arduino tutorial.
First they uploaded this peripheral sender code to their peripheral arduino.
// Wire Master Writer
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
void loop()
{
Wire.beginTransmission(8); // transmit to device #4
Wire.write("hello");
Wire.endTransmission(); // stop transmitting
delay(500);
}
Then they uploaded this controller reader code to the master arduino.
// Wire Controller Reader
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}
void loop() {
Wire.requestFrom(8, 6); // request 6 bytes from peripheral device #8
while (Wire.available()) { // peripheral may send less than requested
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
delay(500);
}
After connecting the peripheral sender arduino to a 9V power supply, they found success. As you can see the message is sent from one arduino to the other using I2C.
Next they moved on to the next hurdle, which was getting 3 arduinos networked with 1 master and 2 peripherals. Just like they had done with two arduinos, they connected another Arduino’s SDA and SCL pins with the rest of them, and also configured a common ground between the three. Here’s a photo of the wiring.
Using the same method as before but simply adding another peripheral sender, they found success with 3 arduinos. They had to keep in mind to use a different address for the third arduino so both I2C input data could be read at the same time