Week 18

About Me Assignments Final Project Fab Lab 2017
About Me Assignments Final Project Fab lab 2017
×

NETWORKING AND
COMMUNICATION

Assignments

As a part of my final project, I wanted to work on bluetooth module as I have to incorporate that in final model.

It is a wireless technology standard for exchanging data over short distances usin short wavelength UHF radio waves in the ISM band and ISM band is basically the range of frequencies ranging from 2.4GHz to 2.485GHz. It was first invented by telecom vendor Ericsson in 1994 and was originally conceived as a wireless alternative to RS-232 data cables

I already have an output board which I wanted to communicate with the bluetooth module. So I didn't milled a new board just used the previous ones and I used all my focus to make communication between multiple boards

Initially I started to work on single board bluetooth communcation with the already built-in mobile app.

Previously I had no knowledge about it so I searched on internet and found an interesting tutorial

I downloaded the android Application from here to send and receive bluetooth data.

Here I am using Arduino just to power up my board.

MC Pin Structure

bluetooth module i used

I connected Rx/Tx pins of bluetooth module with Rx/Tx pins of board which were two of pins of FTDI header there and put 9600 baud rate in the program and opened the serial monitor to observe the results using some of the AT commands also. following pictures will demonstart the process step by step

MC Pin Structure

Programming the Module

MC Pin Structure

Checking output on serial monitor

MC Pin Structure

Configuring the AT Commands

MC Pin Structure

Checking the AT Commands Output

Now I just change the configuration of two pins. I connected RX of board to TX of blue tooth module and TX of the board with RX of blue tooth

MC Pin Structure

Checking Results

After this I installed the mobile app to check the bluetooth results

MC Pin Structure

Connecting with bluetooth Module

MC Pin Structure

Sending Data to bluetooth Module

Working of Bluetooth Module



I2C Connection

I2C is a type of protocol in which communication and data is shared between different nodes based on a single data bus which is shared between all the nodes in the network.

MC Pin Structure

i2c netowork

I already had 2 boards during weekly assignments (week6 and week10) and I also designed one more PCB which will become the part of my final project

MC Pin Structure

Week 6 Board

MC Pin Structure

Output Circuit Board

After this, I went and milled my final project board and for the checking of the process of networking I tested the i2c connection on it whether its working or not

MC Pin Structure

Main Board

After milling and soldering process I got this result

MC Pin Structure

Soldered Main Board

Programming

For the part of programming in i2c, it needs two types of codes, one for the Master and one for the slave. Master is the main board which always takes the decision and the slave follows.

Master File Code

#include <Wire.h>

void setup()
{
Wire.begin(); //starting wire
Serial.begin(9600); //started the serial with 9600 baudrate
pinMode(13, OUTPUT);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
}

char data = 0;
void loop()
{
if (Serial.available()){
data=Serial.read();
}
if (data == '8'){
Serial.write(data);
digitalWrite(13, !digitalRead(13));
Wire.beginTransmission(8);
Wire.write(0);
Wire.endTransmission();
delay(200);
}
delay(1000);
if (data == '9')
{
Serial.write(data);
digitalWrite(13, !digitalRead(13));
Wire.beginTransmission(9);
Wire.write(1);
Wire.endTransmission();
delay(200);
}
delay(1000);
delay(100);
}

Slave Code

#include <TinyWireS.h>
#define I2C_SLAVE_ADDR 0x09
#define LED1_PIN 8

void setup()
{
TinyWireS.begin(I2C_SLAVE_ADDR); //initialize I2C lib and setup slave address
pinMode(LED1_PIN, OUTPUT);
digitalWrite(LED1_PIN,HIGH);
delay(2000);
digitalWrite(LED1_PIN,LOW);
}

byte byteRcvd = 0x00;
void loop()
{
byteRcvd = TinyWireS.receive(); //get the byte from master, returns next byte in received buffer
if (byteRcvd == 1){
digitalWrite(LED1_PIN, !digitalRead(LED1_PIN));
delay(2000);

}
}

Final Result of i2c communication

Files available for download

This is all for this week

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.