14. Networking and communications¶
Assignment¶
individual assignment: design, build, and connect wired or wireless node(s) with network or bus addresses group assignment: send a message between two projects
Learning outcomes¶
Demonstrate workflows used in network design Implement and interpret networking protocols
nueval-Check List¶
Described your project using words/images/diagrams/schematic screenshots. Explained the programming process/es you used. Outlined problems and how you fixed them Included design files (or linked to where they are located) and original code
Group work¶
FabAcademy2019-FabLab Kannai lab site
My work¶
This week, I made 3 boards and tried to communicate among these boards. Based on hello.I2C.45.bridge for the master, and hello.I2C.45.node for slave.
Here’s parts list

Using fabmodules for creating a data for mill

Milled by MDX-15

I milled master and slave boards at once

I coded the following for master and for slave. Master sends signal and when slaves get signal, their LED blink.
When I tried to write through FabISP, it didn’t go well. When I supplied electricity through USB tiny and write throuh FabISP, I successfully wrote it.
#include <Wire.h>
#include <SoftwareSerial.h>
#define SLAVE_1 1
#define SLAVE_2 5
SoftwareSerial mySerial(3, 4); // RX, TX
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
mySerial.begin(9600);
mySerial.println("start");
}
byte x = 0;
void loop() {
Wire.beginTransmission(SLAVE_1); // transmit to address
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
delay(1000);
Wire.beginTransmission(SLAVE_2); // transmit to address
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
delay(1000);
x = (x == 0) ? 1 : 0;
}
#include <Wire.h>
#define SLAVE_ADDR 5 // i2c slave address (1)
#define LED_PIN 4
void setup() {
// put your setup code here, to run once:
pinMode(LED_PIN,OUTPUT);
Wire.begin(SLAVE_ADDR); // init I2C Slave mode
Wire.onReceive(receiveEvent); // register event
}
void loop() {
delay(100);
}
volatile byte msg = 0;
void receiveEvent(int howMany){
while (0 < Wire.available()) {
msg = Wire.read();
if (msg == 0){
digitalWrite(LED_PIN, HIGH);
}else if (msg == 1){
digitalWrite(LED_PIN, LOW);
}else{
msg = 0;
}
}
}
#include <Wire.h>
#define SLAVE_ADDR 1 // i2c slave address (1)
#define LED_PIN 4
void setup() {
// put your setup code here, to run once:
pinMode(LED_PIN,OUTPUT);
Wire.begin(SLAVE_ADDR); // init I2C Slave mode
Wire.onReceive(receiveEvent); // register event
}
void loop() {
delay(100);
}
volatile byte msg = 0;
void receiveEvent(int howMany){
while (0 < Wire.available()) {
msg = Wire.read();
if (msg == 1){
digitalWrite(LED_PIN, HIGH);
}else if (msg == 0){
digitalWrite(LED_PIN, LOW);
}else{
msg = 0;
}
}
}
Video¶
Here’s the video the boards communicating.