Wire Library not working with AtMega328pb-au.

Thread Starter

DaveInNevada

Joined Apr 15, 2021
12
I am using AtMega328PB-AU as Slave and an Arduino Nano as Master. Address of 0.
The AtMega328PB-AU uses the same Pins for SDA(A4/D18) and SCL(A5/D19) as the nano, uno, etc.
Using Arduino IDE, I had to install another Library to upload sketches and burn the bootloader. From the Board Manager, I used Atmel/Microchip ATmega328PB support for Arduino IDE by Watterott. This allowed me to easily burn the Bootloader and Upload Sketches. The test sketch performs perfectly; allows button press to blink LEDs, etc. However, the Wire Library doesn't work for some reason. When I try a simple sketch to communicate using SDA/SCL, it doesn't work. I have installed the 2 pull-up resistors, 10k, to VCC(5v).

I used the IDE example as a test.
Slave:

Code:
#include <Wire.h>
void setup() {
 Wire.begin(0);
 Wire.onReceive(receiveEvent);
Serial.begin(9600);
}

void loop() {
  delay(100);
}

void receiveEvent() {
  while(Wire.available()){
    char c=Wire.read();
    theString+=c;
  }
  Serial.print(c);
}
}
Master:
Code:
#include <Wire.h>

void setup() {
  Wire.begin();
}

void loop() {
  Wire.beginTransmission(0);
  Wire.write("Hello");
  Wire.endTransmission();
Does anyone know that by using a different board manager, as I described above, affects the Wire Librarys functionality?
 
Last edited:

Thread Starter

DaveInNevada

Joined Apr 15, 2021
12
I am using AtMega328PB-AU as Slave and an Arduino Nano as Master. Address of 0.
The AtMega328PB-AU uses the same Pins for SDA(A4/D18) and SCL(A5/D19) as the nano, uno, etc.
Using Arduino IDE, I had to install another Library to upload sketches and burn the bootloader. From the Board Manager, I used Atmel/Microchip ATmega328PB support for Arduino IDE by Watterott. This allowed me to easily burn the Bootloader and Upload Sketches. The test sketch performs perfectly; allows button press to blink LEDs, etc. However, the Wire Library doesn't work for some reason. When I try a simple sketch to communicate using SDA/SCL, it doesn't work. I have installed the 2 pull-up resistors, 10k, to VCC(5v).

I used the IDE example as a test.
Slave:

Code:
#include <Wire.h>
void setup() {
Wire.begin(0);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
}

void loop() {
  delay(100);
}

void receiveEvent() {
  while(Wire.available()){
    char c=Wire.read();
    theString+=c;
  }
  Serial.print(c);
}
}
Master:
Code:
#include <Wire.h>

void setup() {
  Wire.begin();
}

void loop() {
  Wire.beginTransmission(0);
  Wire.write("Hello");
  Wire.endTransmission();
Does anyone know that by using a different board manager, as I described above, affects the Wire Librarys functionality?
I figured it out. I had two 10k pull-up resistors on SCL/SDA. One of them was actually a bad resistor. Unbelievable. What are the odds?
 
Top