Recent

Author Topic: connect 1 rasbperry to 2 atmega328P  (Read 1165 times)

pascalbythree

  • Sr. Member
  • ****
  • Posts: 266
connect 1 rasbperry to 2 atmega328P
« on: February 09, 2024, 04:19:21 pm »
Still working on my system, does anybody know if it is possible to connect 1 rasbperry to 2 atmega328P mcu's ? at all ?

I2C RPI as master, I2C AVR as slave.

Is this possible with this class framework?

https://github.com/ccrause/fpc-avr

i2cslavedemo.pp

https://github.com/ccrause/rpiplc_pas
« Last Edit: February 09, 2024, 04:31:56 pm by pascalbythree »

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 573
Re: connect 1 rasbperry to 2 atmega328P
« Reply #1 on: February 09, 2024, 04:42:10 pm »
I don't know, but it's more fun to bit bang it anyway :)

ccrause

  • Hero Member
  • *****
  • Posts: 984
Re: connect 1 rasbperry to 2 atmega328P
« Reply #2 on: February 09, 2024, 05:03:27 pm »
Yes.  I2C is a bus protocol which allows several devices to intercommunicate.  It would be best if both the RPi and 328's operate at the same voltage (3.3V), however this is not necessary.  Connect the pullups to the RPi 3.3V. Picking the correct pullup resistors is somewhat important, typically 2 - 4.7 kOhm should work.

You can get more details on I2C in the I2C specification and user manual.

PS: Remember to use different slave addresses for the 328s
« Last Edit: February 09, 2024, 05:13:28 pm by ccrause »

VisualLab

  • Hero Member
  • *****
  • Posts: 614
Re: connect 1 rasbperry to 2 atmega328P
« Reply #3 on: February 10, 2024, 12:50:12 am »
Yes.  I2C is a bus protocol which allows several devices to intercommunicate.  It would be best if both the RPi and 328's operate at the same voltage (3.3V), however this is not necessary.  Connect the pullups to the RPi 3.3V. Picking the correct pullup resistors is somewhat important, typically 2 - 4.7 kOhm should work.

You can get more details on I2C in the I2C specification and user manual.

PS: Remember to use different slave addresses for the 328s

You could use some small logic level translator module.

ccrause

  • Hero Member
  • *****
  • Posts: 984
Re: connect 1 rasbperry to 2 atmega328P
« Reply #4 on: February 10, 2024, 04:31:31 pm »
Yes.  I2C is a bus protocol which allows several devices to intercommunicate.  It would be best if both the RPi and 328's operate at the same voltage (3.3V), however this is not necessary.  Connect the pullups to the RPi 3.3V. Picking the correct pullup resistors is somewhat important, typically 2 - 4.7 kOhm should work.

You can get more details on I2C in the I2C specification and user manual.

PS: Remember to use different slave addresses for the 328s

You could use some small logic level translator module.
The input voltage high threshold for digital I/O pins on the m328p running at 5V is ~ 2.6 V. Thus running the I2C bus at 3.3V is within specification even if the m328p itself is running at 5V.  So a level shifter is not strictly required.  Having said that, if the m328p I2C pins are accidentally switched high while connected to a 3.3V RPi it may overload the input pins of the RPi. As a safety precaution either include series resistors on the I2C lines (as suggested in the I2C manual), or use a voltage level shifter as suggested by VisualLab.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 809
    • Blog personal
Re: connect 1 rasbperry to 2 atmega328P
« Reply #5 on: February 10, 2024, 05:18:24 pm »

 

TinyPortal © 2005-2018