Fall 2016 Solar Panels: I2C Communication Experiment

By Jose Rodriguez (Electronics & Control)

Approved By Inna Echual (Project Manager)

Objective: Currently, we will be using our own Arduino Leonardo while the Thursday Pathfinder group (referred to as the chassis group) will also have their own Arduino Leonardo. The solar panels Arduino and chassis Arduino will communicate using I2C interface on Arduino. In order to ensure the concept is understood completely, the following experiment was done with an Arduino Mega and Arduino Uno, where the Mega was used as the Master and the Uno as the slave.

The following were the components used for the experiment:

  • Arduino Uno
  • Arduino Mega
  • LED
  • Resistor
  • Breadboard

untitled1

Figure 1: Code to set up Mega as master

The code in Figure 1 was used to set up the Arduino Mega as the master. The serial monitor was used to debug the system; however it can be removed without affecting the code. Wire.Begin starts the communication using the I2C and address must be inputted. Wire, write is then used to send data to the Arduino. To end the communication using the I2C, Wire.endtransmission needs to be used.

 untitled3

Figure 2: Code to set up Uno as slave

 

The code in Figure 2  was used to set the Arduino Uno as the slave. The key difference is that the Arduino is given an address by writing wire.begin followed with address. The address given to the Arduino is 400 because of the class but any number could have been used. In addition, a subroutine has to be made so that when data is sent, the Arduino goes to the function and does something with the data received. Note that the function called cocoon was created but any other function can be used.

Figure 3 shows the Fritzing Diagram showing how the circuit is configured.

untitled4

Figure 3: Fritzing Diagram

untitled5

Figure 4: Visual Results of Experiment

Figure 4 shows the results of our experiment, i.e. our code working: every time the button is pressed, the Arduino Mega reads the value and sends the value to the Arduino Uno. As a result, pin 13 is set to high whenever the value received is one. Since we do not have both projects done yet, I am using the button as the Arxterra signal that will tell Arduino mega to cocoon. A LED on means subroutine cocoon is active in the Arduino Uno and inactive if the LED is off.

This experiment verifies that communication between two Arduinos is possible.