Networking and Communications¶
This week there are two types of assignments, one group and one individual. In my case I’m alone in ESNE’s Fab Lab so I am doing both.
Assignment¶
Group assignment:
- Send a message between two projects
Individual assignment:
- Design, build, and connect wired or wireless node with network or bus addresses
Group assignment¶
Group assignment page¶
In the following link you can access the Leon Fab Lab page that contains all the group assignments: Fab Lab Leon group assignment page
Send a message between two projects¶
For this assignment I have chosen two micro:bit boards, the micro:bit boards can communicate by radio. Wireless communication is broadcast, or diffusion, in the sense that the signals sent. And this is the type of communication that we are going to practice with today, so that the messages that are sent from a micro:bit board reach all the boards that are within the distance range.
For this I followed the following tutorial, it seemed very simple and easy to follow, here is the program that I loaded in each of the micro:bit.
After I simulated it in the micro:bit page, the program causes that when pressing the left key of the micro:bit the rest of the micro:bit show the number 3. Everything seemed correct
Then load the program on the boards and try it
Individual assignment¶
Design, build, and connect wired or wireless node with network or bus addresses¶
Bridge & node Attiny 412 Tx & Rx¶
What is Tx and Rx?¶
The asynchronous serial protocol is a common communication protocol in the world of embedded electronics. It is used by controllers and devices to communicate information. The protocol is implemented in universal asynchronous receiver/transmitters (UARTs). When a device communicates using the serial protocol, its UART transmits on the “TX” line and receives data on the “RX” line.
When two devices are connected in this way, one device sends a character using its TX line and the other receives it on its RX line and vice versa. The connection of three devices like the ones I am going to use is in the following image
Board design¶
This week for my individual assignment I am going to create 3 boards with the AtTiny412 microcontroller, one of them will be the bridge and the other two the nodes. For all this process I had the documentation of Adrian Torres and the help of my colleague Luis Diaz without whom this would not be possible.
I started by creating the bridge in the KiCAD schematic
Then I made the design of the board with all its components
With the bridge finished I started with the design of the two nodes with the Attiny 412, these nodes are almost the same as the bridge but without the 6-pin male connector. I started by creating the node in the KiCAD schematic.
IMPORTANT: INVERT Tx & Rx IN THE NODES
Then I made the design of the board with all its components
Board milling¶
With the KiCAD design save the svg to put them in mods. From mods I got the gcode for my Roland modela MDX 40.
Using the gcodes, drill the board with the 0.4mm and 0.8mm mills.
Solder components¶
With the milled boards I welded all the components to each of the boards
Program¶
Bridge¶
With the boards finished I started programming the bridge and then the two nodes, this is the code I used for the bridge. The code generates a random number in the bridge from 1 to 5 every 2 seconds, if the number is the same as the node, the node blinks with the bridge otherwise it does not.
//Fab Academy 2022
//Initial code of Adrián Torres modified with the help of Luis Diaz
//ATtiny412 bridge
int valor =0;
int i =0;
void setup() {
Serial.begin(115200); //initialize serial communications
pinMode(4, OUTPUT); // led
}
void loop() {
valor = random(1,5); {
Serial.println(valor); // print value to Serial
}
for (i=0;i<valor;i++){
digitalWrite(4,HIGH);
delay(200);
digitalWrite(4,LOW);
delay(200);
}
delay(2000);
}
Node 1¶
//Fab Academy 2022
//Initial code of Adrián Torres modified with the help of Luis Diaz
//ATtiny412 Nodo 1
int valor=0;
int nodeid=2;//Node Identification
int i =0;
void setup() {
Serial.begin(115200);
pinMode(4, OUTPUT); // led
}
void loop() {
while (Serial.available () == 0 ) {} //while serial is 0
valor = Serial.parseInt();
if(valor == nodeid) //If the value of "valor" equals the identification of the node
{
for (i=0;i<valor;i++){
digitalWrite(4,HIGH);
delay(200);
digitalWrite(4,LOW);
delay(200);
}
}
else
{
digitalWrite(4,LOW);
}
}
Node 2¶
//Fab Academy 2022
//Initial code of Adrián Torres modified with the help of Luis Diaz
//ATtiny412 Nodo 2
int valor=0;
int nodeid=4;//Node Identification
int i =0;
void setup() {
Serial.begin(115200);
pinMode(4, OUTPUT); // led
}
void loop() {
while (Serial.available () == 0 ) {} //while serial is 0
valor = Serial.parseInt();
if(valor == nodeid) //If the value of "valor" equals the identification of the node
{
for (i=0;i<valor;i++){
digitalWrite(4,HIGH);
delay(200);
digitalWrite(4,LOW);
delay(200);
}
}
else
{
digitalWrite(4,LOW);
}
}
The code worked correctly and the nodes correctly repeated the information issued by the bridge
Download files¶
.svg¶
Bridge Edge Cuts .svg
Bridge Path Cuts .svg
Node Edge Cuts .svg
Bridge Path Cuts .svg
.jpg¶
Bridge Edge Cuts .jpg
Bridge Path Cuts .jpg
Node Edge Cuts .jpg
Node Path Cuts .jpg
See you next week!