Start Bootstrap

Networking and communications

Week 15

wire communication between 2 Attiny44

The goal of this week is to build a wire or wireless communication between at least two processors.


In week 6 of the electronics design I unveiled two microcontrollers that use the Attiny 44.So I decided to use these two microcontrollers and make the communication from one to the other.



The following diagram shows the two microcontrollers that I have.

i2C Comunication



The communication between the 2 Attiny 44 was made through the i2c protocol.

You can find more information about this protocol here:

  • i2c communication



  • With Attiny 44 it is possible to make the i2c communication using the SDA and SCL pins. The matching pins on attiny44 are:

  • Pin PA6 (A6) = SDA + MOSI
  • Pin PA4 (A4) = SCL + SCK



  • The boards must be programmed individually and then connected to each other to verify that one of the boards is receiving and the other to be sent.



    The wiring connection between the boards require a 10K resistor between the SDA and the SCL, and must be connected as shown in the diagram below:



    PROGRAMMING





    To start programming my board I started by investigating on the internet projects that use i2c communication between two attiny boards.

    I found some projects but none of the projects uses an attiny 44, which is very annoying.



    I've seen a very good example that explains the communication between atias 85, see here:

  • I2C (master and slave) on the ATtiny85



  • The code had only been tested for ATtiny85 and might work with other attinys, so I relied on this code to try to reproduce for my attiny44.



    First you need to install and include TinyWire libraries.

    In my searches I found a TinyWireS that works with attiny 44. Download here:

  • TinyWireS library


  • The previous library only works for Slave and I could not find any library for the Master.

    So I used the USI i2C library, which uses "#include USIWire.h" and the commands are identical to the common Wire library for arduino.

    You can download this library here:

  • USIWire.rar _library






  • I wrote the very simple program to see if the boards were communicating between them.


    Attention, in the code it is necessary to set the same I2c adress for the two boards: Master and Slave (you can choose any adress, it does not matter)



    See the code here:

  • tiny44_i2c_Master
  • tiny44_i2c_Slave



  • Since attiny44 does not support the serial monitor, I could not figure out if the communication was being made, so I used leds for that purpose.



    The Master card flashes a yellow LED connected to pin 7 to show that it is alive and sending data.


    In turn, the Slave or Reciever card flashes a yellow LED connected to pin 7 to show that it is alive. E lights a blue LED connected to pin 8 stating that it receives data from the Master card.







    The following video shows the boards making the communication.



    This is a simple example using LEDs, which shows that communication is being done between the boards. :)

    VIDEO


    Find the files used and download here:


  • tiny_i2c.rar _Arduino Files with librarys