,

Networking and Communications

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

 

  

Networking communiation two  boards through I2C

The Inter-integrated Circuit (I2C) Protocol is a protocol intended to allow multiple “slave” digital integrated circuits (“chips”) to communicate with one or more “master” chips. Like the Serial Peripheral Interface (SPI), it is only intended for short distance communications within a single device. Like Asynchronous Serial Interfaces (such as RS-232 or UARTs), it only requires two signal wires to exchange information. reference Spark fun

 

Thumbnail Image 1

Assignment

In this time I want to use the module ESP8266 Wifi for simulating the functions and also underestanding the concection via Internet, https://nurdspace.nl/ESP8266 (datasheet) for more information.

The ESP8266 is a complete and self-contained Wi-Fi network solutions that can carry software applications

This module comunicates over serial, that means that this modul can send comands and

You can conect this module trough software serial as I do it, or hardware serial having  more capacity of sending data and receiving data from internet.

for this assigment I used the Gyro SK this is the board that I modified using the orifinals Satscha Kit for my Input device assignment.

Thumbnail Image 1
Voltage Regulators

For connecting this module you need a voltage regulator , in my case I used two. One for converting the voltage of 9 volts of the battery to 5V for the (Gyro) SatshaKit and from the output of 5 V (Gyro) SatshaKit to 3 volt to WiFi module.

Thumbnail Image 1
Measuring the output voltage

The most important part for considering, is to test te output of the voltage , for the both components. In this form you can avoid some damage in boards.

Thumbnail Image 1
Connection with the Gyro SatshaKit

The Satshakit stay with the FTDI Cable to communicate the Computer and upload the Arduino sketch.

 

 

Thumbnail Image 1
Thumbnail Image 1

Serial Communication between 2 satshakits

 

In the previous assignment we are connecting our board basically with hardware serial interface, using the TX and RX in the communication with the computer. This example is the same to established from the communication with our Fab ISP. Serial Peripheral Interface (SPI), it is only intended for short distance communications within a single device. In this time I will send and receive data between two Satshakits, using the “software Serial” (I²C) library from arduino IDE.

 

About I2C:

About I2C: The Inter-integrated Circuit (I2C) Protocol is a protocol intended to allow multiple “slave” digital integrated circuits (“chips”) to communicate with one or more “master” chips. Like the Serial Peripheral Interface (SPI), it is only intended for short distance communications within a single device. Like Asynchronous Serial Interfaces (such as RS-232 or UARTs), it only requires two signal wires to exchange information. https://learn.sparkfun.com/tutorials/i2c

I²C (Inter-Integrated Circuit), pronounced I-squared-C, is a multi-master, multi-slave, single-ended, serial computer bus invented by Philips Semiconductor (now NXP Semiconductors). It is typically used for attaching lower-speed peripheral ICs to processors and microcontrollers in short-distance, intra-board communication. Alternatively I²C is spelled I2C (pronounced I-two-C) or IIC (pronounced I-I-C).

I found this program that explain a little bit the big thematic arround serial Communication. Arduino Tutorial #10: Arduino to Arduino I2C 

What I did 

1. I connect directly the satshakits trying to upload the code, i have some problems to uploading the code I has some Ardunio error note

Troubleshooting : I connect directly the satshakits trying to upload the code, i have some problems to uploading the code I has some Arduino error note the code in the slave has a some wrong word , In fact I have some type error. 3, the connection with the SDA and SCL was in the wrong direction. Be Careful !!!! the TX is always connected with RX of the satcha and the RX is connected with TX! Well this problem takes me the whole day to discover, why I can not upload my program if the jumper ar well-connected !!!

After correcting he hold problems I could communicate my Gyro SK with the AC2016 (final Project Board. As you can see in the video I can communicate both boards pressing the Letter H for high and the letter L. low.

 

 

Thumbnail Image 1

.

.

Thumbnail Image 1

.

.

.

.

.

.

Code

ESP8266 Wirless Comunication code.

// Basic serial communication with ESP8266
// Uses serial monitor for communication with ESP8266
//
//  Pins
//  Arduino pin 2 (RX) to ESP8266 TX
//  Arduino pin 3 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduino to GND on the ESP8266
//  Pull ESP8266 CH_PD HIGH
//
// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the ESP8266
//
 
#include 
SoftwareSerial ESPserial(2,3); // RX | TX

String get="GET / HTTP/1.1\r\nHost:192.168.1.113:8080\r\n\r\n";
String cipSend ="AT+CIPSEND=";

void setup() 
{
  
    cipSend+=get.length();
    cipSend+="\r\n";
    Serial.begin(19200);     // communication with the host computer
    //while (!Serial)   { ; }
 
    // Start the software serial for communication with the ESP8266
    ESPserial.begin(9600);  
    ESPserial.print(("AT+CWJAP=\"(please put the name of your network)\",\"(please put your password of your network)\"\r\n");
  
    delay(8000);

   while ( ESPserial.available() ) {  
    Serial.write( ESPserial.read() ); 
   } 

}
 
void loop() 
{
    


  
  ESPserial.print("AT+CIPSTART=\"TCP\",\"192.168.1.113\",8080\r\n");
  
  delay(5000);

  while ( ESPserial.available() ) {  
    Serial.write( ESPserial.read() ); 
  }

  ESPserial.print(cipSend);
  
  delay(5000);

  while ( ESPserial.available() ) {  
    Serial.write( ESPserial.read() ); 
  }

ESPserial.print(get);
  
  delay(1);

  while ( ESPserial.available() ) {  
    Serial.write( ESPserial.read() );
  delay(2);  
  }

  
delay(10000); 

}	

I2C Master Gyro SK

// I2C Master Gyro SK 
// remember that we have to send whit I2C one message for one time therfore we have to programe the master and the slave.

#include 

void setup() {

  Serial.begin(9600);
  Wire.begin();

 
}


 
 
void loop() {

  {
      while (Serial.available() > 0)
      {
   
          char c = Serial.read (); // character c
 Serial.println(c);
                if (c == 'H' )
                {
                  Serial.println("H");
                   Wire.beginTransmission (5);
                   Wire.write ("H");
                   Wire.endTransmission();




                   
               
                }
            
                else if (c =='L' )

                {
                  Serial.println("L");
                   Wire.beginTransmission (5);
                   Wire.write ("L");
                   Wire.endTransmission();
                   
                 }
 
         }
  } 


}


	

I2C Slave AC 2016

// Slave AC 2016 
/*4.7 KOhm ressistors
apull up at 5 V therfor we as 
 
concect  the SDA = arduino A5 data line
             SCK = arduino pin A4 cklock line
 */            
//remember that we have for this kind of programing some kind of interrups that mame events. this Event will be another function after the void loop

#include 


void setup()             
{
  // put your setup code here, to run once:

Wire.begin (5);
Wire.onReceive (receiveEvent);

 pinMode (13,OUTPUT);
 digitalWrite (13, LOW);
 
 
}

void loop() 

{
  // put your main code here, to run repeatedly:

}

void receiveEvent (int howMany)

{

while (Wire.available ())
        {

          char c = Wire.read (); // character c
          //char d = Serial.read (); // character d

                if (c== 'H')
                {
                   digitalWrite (13,HIGH);
               
                }
            
                else if (c == 'L') 
                {
                  digitalWrite(13,LOW);
              
                }

         }

}