Skip to content

14. Networking and communications

Assignments for the week

Group assignments

  • Send a message between two projects (assignments made by different students)

Requirements

  • 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 assignments

Communication via bluetooth.

There are no board at Fablab Taipei,
So there are a copy of week 14 board made by Weng.
Both using HC-05 to have bluetooth communication,
one of it as master, the other as slave.

Make the board

See Week 14 of Weng

Set HC-05 as a master

  1. Upload program to arduino.


    /*
    AUTHOR: Hazim Bitar (techbitar)
    DATE: Aug 29, 2013
    LICENSE: Public domain (use at your own risk)
    CONTACT: techbitar at gmail dot com (techbitar.com)
    */
    #include <SoftwareSerial.h>
    SoftwareSerial BTSerial(10, 11); // RX | TX
    void setup()
    {
    Serial.begin(9600);
    Serial.println("Enter AT commands:");
    BTSerial.begin(38400);  // HC-05 default speed in AT command more
    }
    void loop()
    {
    // Keep reading from HC-05 and send to Arduino Serial Monitor
    if (BTSerial.available())
    Serial.write(BTSerial.read());
    // Keep reading from Arduino Serial Monitor and send to HC-05
    if (Serial.available())
    BTSerial.write(Serial.read());
    }
    

  2. Wiring (Remove USB cable first).

    Arduino Nano HC-05
    5V or 3.3 V VCC
    GND GND
    10 TXD
    11 RXD
  3. Press button while links to Arduino.
    Remove HC-05 side of wire,
    links Arduino to conputer.
    Press button on HC-05 while connect HC-05 with Arduino.
    This button allow It into setting mode (AT mode).
    It will blink at ~1 sec. rate if sussesful enter AT mode.

  4. Have the address of the slave module.
    Open Serial port monitor.
    Choose NL&CR mode and 9600 baud.
    Send AT, It will return “OK” if all step works.
    Send AT+ADDR? to have the address of slave module.

  5. Set up master module.
    Choose NL&CR mode and 9600 baud.
    Send AT, It will return “OK” if all step works.
    Send AT+UART=38400,0,0 to setup the baud.
    Send AT+ROLE=1 to setup the HC-05 as a master.
    Send AT+BIND=<address of slave> to set the master link to a slave with specific address.

  6. Upload the code to a board will be the master.

    ---
    #include  <SoftwareSerial.h>        
    SoftwareSerial BTSerial(1, 0); // RX | TX       
    void setup()        
    {       
    BTSerial.begin(38400);  // HC-05 default speed in AT command more       
    }       
    void loop()     
    {       
    BTSerial.write('c');        
    delay(500);     
    BTSerial.write('d');        
    delay(500);     
    BTSerial.write('d');        
    delay(450);     
    BTSerial.write('c');        
    delay(450);     
    BTSerial.write('d');        
    delay(150);     
    BTSerial.write('c');        
    delay(6000);        
    }       
    ---
    
  7. Connect Modules to boards.