Networking and Communications
Send a message between two projects.
connect, build and design wired or wireless node(s) with network.
Establish workflows used in network design.
Implement and understand networking protocols and/or communication protocols
This week task is I to communicate between two microcontrollers using I2C protocol.
The master will relate to a push button.
To light up the LED the signal will be transferred throw the slave Arduino.
One of the important things that I do every week before I start working on documentation, I must make my own research to understand about it.
To know more about electronics, I referred to the Arduino Community.
The following Tutorial was good.
I2C https://i2c.info/ is a serial protocol for two-wire interface to connect low-speed devices like microcontrollers, EEPROMs, A/D and D/A converters, I/O interfaces and other similar peripherals in embedded systems.
I2C uses only two wires: SCL (serial clock) and SDA (serial data).
Both need to be pulled up with a resistor to +Vdd.
There are also I2C level shifters which can be used to connect to two I2C buses with different voltages.
I communicate between two Arduinos using I2C protocol.
The master will be linked with a push button.
The signal will be transferred to the slave Arduino that will light up the LED.
The code as following:
#include : this will call the library so that will allows to communicate with I2C devices.
Wire.begin(); this will launch the Wire library and join the I2C bus as a master or slave. That will normally be contacted only once.
Wire.beginTransmission(); that will begin a transmission to the I2C slave device through the given address.
Wire.write() that will send data from a master to slave device.
Wire.endTransmission(); that will end the transmission to a slave device.
Wire.onReceive(); that will register a function to be called when a slave device receives a transmission from a master.
Wire.read(); that will read data which was transmitted from a master to a slave.