14. Networking and communications¶
Checklist¶
- Linked to group assignment page
- Documented my project.
- Documented what I have learned.
- Explained programming processes.
- Outlined problems and how I have fixed them.
- Included all original files.
Networking week was super difficult, but I managed to pull through! I had to make a lot of boards this week, but I’ll sum it up like this:
Board Production¶
Board production was pretty difficult. I had to make a bunch of different boards since my traces would either break or not cut through. It was pretty difficult, but I ended up getting through it. For the process of making a board, check out my week 5, week 7, week 9, or week 11!
Networking Schematic Networking Board
Programming in Arduino¶
Programming my boards was a whole other story. I found out in the arduino code that I had to change the number from ‘0’ to ‘1’ after I programmed my bridge board. 1 would be my node. That solved a lot of problems with the Arduino programming. Other than that, I didn’t have much issue with Arduino.
Programming in Python¶
Whether it be step response or charlie plexing, Python is always finicky with indentation, with libraries, with pip, with almost anything! Its no wonder why Python has decided to scrap 2.7 and switch to 3.1, but it makes it super hard to convert all the old work done on 2 to 3. After I programmed both boards with the FTDI header, I tested to see if they worked. They didn’t at first, but when plugged in, I did see the node program work! They were lit up and whenever I touched the RX pin, the lights would flash. Now, after I flipped my FTDI cable, I was successfuly able to program them!
LCD Networking¶
This is where I go over networking with two LCD boards. I tested out my Networking with this first because it is easier to see clear results and can serve as a better example for when I will go back to do this again.
Materials and Pins¶
All you need are :
Breadboards
ESPWRoom32S
Jumper wires (male to female preferable, but a male to male connected to a female to female does the same thing). I used 12 male to male and 8 female to female, but you can always use 4 male to male and 8 male to female jumper wires.
Two QAPASS LCD Displays
The pins on the Huzzah that we will use are:
SCL - P22
SDA - P21
VCC - 3V3
GND - GND
Here is the pinout of a ESPWroom32S board.
Set Up¶
Getting your library: There is an LCD Screen library that you need to download in order to actually use my code. Here is the link to the where I downloaded my library.
This video helps with the set-up. The LCD Displays I bought already had the processor soldered on, but it is pretty easy to solder it all together. What is the most important thing to solder are the three spaces labeled A0, A1, and A2. Depending on what pins you decide to jump together, the binary address will change. This is to change the binary component and ground the different open circuits. Here is an example from the youtube video above.
What I did was jump the A2 pin. You can make many different addresses like this, but it can be hard to actually solder the bit. I went in very carefully and blobbed two pieces of solder on each pad before I took a long strip of solder wire and laid it on top. I melted it in after and had my jumper. I did not use a jumper resistor because the ones I had at home would not fit the pads I had tightly enough. You can leave all the pins blank if you would like, but you can only have one board like this. Each of your boards will need a different address or else you might have an issue like I did below.
You will need to also need to connect a jumper between the two pins LED and POWER. This is what will light up your LCD Screen from a dark to light blue. There is also a light blue potentionmeter on the back that will allow you to control the intesity of the light of the LCD.
Issues and How I Fixed Them¶
I had an issue with my two LCD boards at first because they were both trying to receive and project the same message, but because of my soldering I had to recode my program and set up an lcd2 (which had the same pins and such, just a different name and address). Here is the video I have of the original problem.
In the programming experience, I had some trouble with understanding void loops() again. What I didn’t realize was that there could only be one void loop per program. I fixed it by encorporating the code from my second loop into the first one. Really nothing change, I just had to set up everything all together without sectioning it off in different loops (though comments are advised for sections and marking what is happening in the program.)
Overall, my program works for anyone who wants to make one board connect to two LCD Displays at the same time, but with different messages displayed at different times.
Final Result!¶
My Code¶
You don’t have to use the first code if you know what the address of both your boards will be. I used it before because I didn’t know how the different bits originally affected the address.
//esp32-i2c-scan
/*********
Rui Santos
Complete project details at https://randomnerdtutorials.com
*********/
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(115200);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ ) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address<16) {
Serial.print("0");
}
Serial.println(address,HEX);
nDevices++;
}
else if (error==4) {
Serial.print("Unknow error at address 0x");
if (address<16) {
Serial.print("0");
}
Serial.println(address,HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
}
else {
Serial.println("done\n");
}
delay(5000);
}
Here is the code that actually got the boards to light up.
/*********
Rui Santos, editted and remodeled by Brigette O'Neill
Complete project details at https://randomnerdtutorials.com
*********/
#include <LiquidCrystal_I2C.h>
// set the LCD number of columns and rows
int lcdColumns = 16;
int lcdRows = 2;
int lcdColumns2 = 16;
int lcdRows2 = 2;
// set LCD address, number of columns and rows
// if you don't know your display address, run an I2C scanner sketch
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
LiquidCrystal_I2C lcd2(0x23, lcdColumns2, lcdRows2);
void setup(){
// initialize LCD
lcd.init();
// turn on LCD backlight
lcd.backlight();
// initialize LCD
lcd2.init();
// turn on LCD backlight
lcd2.backlight();
}
void loop(){
// set cursor to first column, first row
lcd.setCursor(0, 0);
// print message
lcd.print("Brigette O'Neill");
delay(1000);
// clears the display to print new message
lcd.clear();
// set cursor to first column, second row
lcd.setCursor(0,1);
lcd.print("Hello, World!");
delay(1000);
lcd.clear();
// set cursor to first column, first row
lcd2.setCursor(0, 0);
// print message
lcd2.print("FabAcademy");
delay(1000);
// clears the display to print new message
lcd2.clear();
// set cursor to first column, second row
lcd2.setCursor(0,1);
lcd2.print("2020");
delay(1000);
lcd2.clear();
}
Group Assignment¶
For the group assignment, I will network between my original networking board and my dad’s networking project from 2018. I will do this using mods between the two to communicate. Though I’m not sure how to get the two boards to communicate, I am guessing that they will be similar in finding the IP addresses used between them. The addresses will be important to linking them just like they were for the I2C and the LCD screens. Since the communication protocol is also different, I will have to learn mods and how to run it on multiple machines at once.
Links¶
The best video to explain LED QAPASS Boards
This youtube video is one of the greatest things that I’ve ever found! This goes through the entire process of connecting a LCD Display to different devices. It doesn’t give an exact tutorial for an exact device, so that made it a lot easier to fully understand!