Networking and communications


Assignments:

  • design and build a wired &/or wireless network connecting at least two processors

Plan

For completion of my final project, networking is required. I have to make use of both wired and wireless type of communication. Project details are available in Final Project page. Wired communication is needed for communicating with secondary board where motor controller and LCD display is connected. Both boards should send, receive and acknowldge data frequently. And wireless communication is used for communication between main board and the mobile application. For this, HC05 bluetooth module is used. Celestial coordinate data along with current date and time has to be sent from app to main board via bluetooth.

This week I am going to try both serial communication and wireless communication.

Board design

There are two boards for my project. The main board which contains bluetooth module is designed by me and the other board is designed by my friend Tanvir as this is a group project. Design and development details of my board are below.

  • I used Atmega328 chip for the project. I have left pins for connecting bluetooth, speaker, LED, power switch and pin for serial communication. As I have used hardware level communication port for bluetooth, I used some other pins for wired communication. I have to defineit as communication port in software level. I used kicad for designing. Downloadable files are available at the bottom. Schematic diagram of the project is shown below.

    schematic
  • Final PCB design is here

    PCB design
  • File was then exported to SVG and mill trace & cutout files were generated.

    mill cut
  • Files were fed to modella machine. Screenshots while using modella are below.

    modella mill modella cut
  • Final stuffed board is here

    final board

Programing

The logic I am going to use here is as follows. The board A has bluetooth module and this board is connected to programmer and the board A is also connected to secondary board which has LCD display. Secondary board should wait for input from board A. Then board A sends a '*' symbol to secondary board. When this '*' symbol is received in secondary board, it says so in display. Then it sends a feedback message '#' to board A. Then main board should send a acknowledge symbol and LCD displays 'board acknowledged'.

  • Code for board A. Bluetooth is connected here.

    #include <SoftwareSerial.h>
    SoftwareSerial softserial(3, 4); // RX, TX
    
    void setup() {
    //Initiate Serial communication.
    softserial.begin(9600);
    
    delay(5000);
    softserial.print("*");
    delay(6000);
    }
    
    void loop() {
    char val = softserial.read();
    if (val=='#'){
    delay(3000);
    softserial.print("$");
    softserial.flush();
    }
    }
    
  • Code for secondary board

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(12,13,A2,A3,A4,A5);
    
    void setup() {
    Serial.begin(9600);
    
    while (!Serial.available()) {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("WAITING..."); //waiting for data from Board-A
    }
    }
    
    void loop() {
    char val = Serial.read();
    if (val=='*'){
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("BOARD A SENT *");  //Received data from Board-A
    delay(5000);
    
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("SENDING FEEDBACK"); //Sending feedback to Board-A
    delay(3000);
    Serial.print("#");
    Serial.flush();
    }
    else if (val=='$') {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("BOARD A ACK"); //Board-A acknowledged
    delay(5000);
    }
    }
    

Output

Wireless Communication

For testing wireless communication part using bluetooth, I have to create a mobile app. I did this in Application Programing week. Both bluetooth communication part and app development is explained there.

Downloads

Kicad design files - Download

Codes - Download