Week 13: Networking and Communication

Netwoking and communication plays the crucial role in the electronics world. People communicate between long distance using communication technique of elctronics. This week is about learning how communication is happening between two or more electronics components or devices.

Instruction:
Design, build, and connect wired or wireless node(s) with network or bus addresses
Group Assignment:
Send a message between two projects

    To Do:
  1. Learn about ESP32 board.
  2. Programming of esp32.
  3. How to connect to web from esp board.
  4. Try communicating between esp boards.
  5. Document on what I learn through this week
  6. Group Assignment.

Useful Links:
ESP32 Library for eagle here
ESP32 tutorial resources Here

ESP32:
ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. The ESP32 series employs either a Tensilica Xtensa LX6 microprocessor in both dual-core and single-core variations, Xtensa LX7 dual-core microprocessor or a single-core RISC-V microprocessor and includes built-in antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power-management modules. From Wiki

ESP32 WROOM Specification:

From Datasheet

Controller Fabricating:
I fabricated my esp32 board for my final project and OutPut/Input Devices during week ten of output device week. I also added the documentation here in order for easy reference.

The basic requirement circuit to fabricate ESP32 WROOM as controller is given here. Find under ESP32 heading.

I designed circuit board as per minimum circuit required for esp32 and added some free pinouts so that I can program the pins later.

After the designing and exporting, I tried milling in the cnc milling machine and find out that pins of the esp32 were not printed. Iknew that I overlooked the view given in the mods.

Consultation with instructor found out that I need to change the pad size of the pins of the esp controller in the eagle library.
Doenload esp32 library of eagle from Here.

In order to change the pad size, Right click on the component and select Open Footprint to change it.

On the top, in the comment box, type change smd and enter to get drop down.

From the dropdown, select 66*32 usually it works for esp32 controller. After selecting, we need to select pins one by one to get changed.

After the change, we need to save it as new library file.

Now open the component (ESP32) from new saved library and check if it worked.

Before I use it in my design, I checked it in MIT MODS and looked working.

So, I changed the IC from new library that I have saved. Find my trace file and cut files at the end of the assignment.

After editing, I did milling again and this time it came out well.

I soldered the required components as per my design and my board get ready for programming.

Programming ESP32:
Now it's time to program the controller board. We can use arduino IDE to program esp32, but we need to install the esp library like we did for attiny.

Under Files -> Preferences, we need to paste the https://dl.espressif.com/dl/package_esp32_index.json link as shown in above image. If you have another link already present in the text box, separate it using comma and keeping in new line.

Once added, you can find the library available under Tools -> Board Manager. You can install it.

I used arduino as FTDI to program my ESP board. Unlike ATtiny, ESP32 doesn't require programmer, instead it uses FTDI programmer. So, we need to make arduino as FTDI by either
- Shotting the EN and GND of the arduino,
- Removing the IC of the arduino or
- Loading the blank program to the arduino.

I prefered loading program to the arduino to make it as FTDI.

	void setup(){
	pinMode(0,INPUT);   
	pinMode(1,INPUT); 
	} 
	void loop(){ 
	} 

	

This is simple arduino code that makes RX and TX pin of the arduino as output pin. Load this code to arduino that you are going to use as FTDI.

Now connect ESP board to power supply and connect RX and TX pin of arduino with RXD 0 and TXD 0 pins of ESP32 respectively.

From the Tools -> Boards: -> ESP32 Arduino select ESP32 Dev Module to program our ESP32 WROOM 32 board.

Now keeping the Slide Switch in the programming mode i.e. connected position, to load program. You cannot select the Programmer, now, directly do upload as usual.

Once uploaded, there will not be any print on the Serial Monitor and it took me a whole lot of time tracing the mistake. But later found out that I need to put back Slide Switch to run position and press the Reset Button once.

I was trying the example code of WiFiScan.

Programming for Network:
ESP32 network programming is made much easier with painlessmesh. It let us program to easily communicte between multiple board of esp.

For this we need to first install the library of painlessmesh in the arduino ide.

Painlessmesh comes with the requirement of some other libraries. We can install all together or one by one as required.

Once installed the library, I tried loading the example code in two different esp32 board to check the communication between two boards.

Sender program loading to one board.

Receiver program loading on another board.

Once both the program is loaded, open both the serial monitor from sender port and receiver port and checked the results. In order to open two serial monitor in a pc at once, we need to open ardduino ide separately.

Communication between two esp32 boards of port COM4 and COM6 was successful as shown in the image above.

After the successful communication linking between two esp board, I wanted to communicate with each other using input nad output devices. Going through many tutorial I found the suitable one.

For the two boards to communicate with each other, we need to find out the macAddress for each of them. The boards communicate with each other through the given address.

	#include "WiFi.h"
	void setup() {
	  Serial.begin(115200);
	  WiFi.mode(WIFI_MODE_STA);
	  Serial.println(WiFi.macAddress());
	}
	void loop() {
	}
	

Code to find out the address of from each port.

Finding address of ESP32 on COM port 4

Finding address of ESP32 on COM port 6

Once I got the address, I changed it into required format as shown in above. These address we need to replace in the program as the address of destination.


Issues faced and solution.
This issue is from the input week assignment, as it is revelant as I still used the AsyncTCP library, I added here too for references.

Issue - code debugging:
As the code requires ESPAsyncWebServer.h library for arduino, I loaded the library as usual downloading from the net.

But when I compile, there give the fatal error saying that AsyncTCP.h file is missing. With the help of external expert I found out that I need to add the file externally.

I got the file from Gitlab. I need to download it and add into the library both the .h and .cpp files under ESPAsyncWebServer.h library. After adding the two files, it worked well.




👈 👉