PiicoDev Buzzer (p18 / WPI4050) works on Raspberry Pi but silent on Arduino Nano (3.3 V I²C)

Hi all
I’m trying to run the PiicoDev Buzzer (p18 / WPI4050) from an Arduino Nano powered at 3.3 V. It appears on I²C at 0x5C and ACKs all writes, but never makes a sound (LED solid). The same buzzer works perfectly on my Raspberry Pi using the Python demo.

I have the Arduino wired with a piicodev breadboard adapter to the buzzer
GND → GND
3V3 → 3.3V
SDA → A4 (analog pin 4 / I²C SDA)
SCL → A5 (analog pin 5 / I²C SCL)

Couldn’t find any libraries for the buzzer.

Here’s the sketch I used:

#include <Wire.h>
#define BUZZER_ADDR 0x5C

void setup() {
  Serial.begin(115200);
  Wire.begin();
  Wire.setClock(100000);
  delay(1000); // let buzzer boot
  Serial.println("PiicoDev Buzzer V2 test");
}

void loop() {
  playTone(1000, 1000);
  delay(2000);
  playTone(2000, 1000);
  delay(4000);
}

void playTone(uint16_t freq, uint16_t dur) {
  Serial.print("Writing frequency "); Serial.println(freq);
  writeReg16(0x00, freq);
  delay(10);
  Serial.print("Writing duration "); Serial.println(dur);
  writeReg16(0x02, dur);
  delay(10);
  Serial.println("Triggering play command");
  writeReg8(0x04, 0x01);
  delay(10);
}

void writeReg16(uint8_t reg, uint16_t val) {
  Wire.beginTransmission(BUZZER_ADDR);
  Wire.write(reg);
  Wire.write(val >> 8);
  Wire.write(val & 0xFF);
  uint8_t err = Wire.endTransmission();
  Serial.print("Write16 reg "); Serial.print(reg, HEX);
  Serial.print(" err="); Serial.println(err);
}

void writeReg8(uint8_t reg, uint8_t val) {
  Wire.beginTransmission(BUZZER_ADDR);
  Wire.write(reg);
  Wire.write(val);
  uint8_t err = Wire.endTransmission();
  Serial.print("Write8 reg "); Serial.print(reg, HEX);
  Serial.print(" err="); Serial.println(err);
}

Serial output (when connected):
Writing frequency 1000
Write16 reg 0 err=0
Writing duration 1000
Write16 reg 2 err=0
Triggering play command
Write8 reg 4 err=0

All writes are ACKed (err=0), yet no sound is produced.

What am I doing wrong?

1 Like

The way I’m reading this the register you need is 0x5.
Then the freq and duration are concat into a single 16bit byte string.
Kinda weird … :man_shrugging:

Is that what you reading too? :slight_smile:

2 Likes

Nice one, you were spot on! Writing to register 0x05 with the concatenated freq + duration bytes did the trick. I just tested it on my Nano and it works perfectly now.

Thanks for pointing me to the MicroPython driver — that cleared it up straight away. Really appreciate the help! :folded_hands:

3 Likes

Happy to help. :slight_smile:
Happy making.

2 Likes