Specifications / instructions for writing my own i2c interface to a pHAT BEAT?

Hi everyone,

I’m working on a home hub (wake-up alarms, controlling smart home devices, etc) and for various reasons I’m using a non-standard OS on a Raspberry Pi Zero W. This is a big learning exercise for me, so I’m not necessarily interested in just using more popular tools. I’m trying to learn embedded programming, circuit design and all the related skills I’ll need. Warning: I’m brand new to a lot of this (though with plenty of programming knowledge and some basic electronics) so I apologise if I’m using incorrect phrasing or getting mixed up. If you think my approach is wrong I would gladly appreciate pointers.

I’m using https://nerves-project.org/ — the Elixir programming language running on a cut-down embedded linux + VM (built with https://buildroot.org/). That’s one of the only fixed parts of the system, I want more experience with this tech so I don’t want to switch to another OS and use Python.

I also have a pHAT BEAT from the excellent hosts of this forum, and I would love to get that hooked up. My problem is this: my current linux installation isn’t setup to route audio over the GPIO pins and the Pimoroni setup script doesn’t support my OS. I’ve been trying to understand the setup script a bit more, but I suspect I need to mess around at a slightly lower level first.
I could theoretically switch to a Pi 3 and use the audio-jack, but then I would have to use something other than the pHAT BEAT which would be a shame.

So: what’s the best way for me to get started with manually interfacing with the DAC from my system? I haven’t been able to find any documentation beyond the pinout diagram. I’m probably not looking in the right places or for the right terms? I can see that communication is done with I2C but not much beyond that.

Thank you for any help, specific or general.

Its i2"s" actually for the sound part. For that pHat / DAC anyway. The other GPIO are the buttons being pressed signals. The DAC is an MAX98357A (from the product page) if that helps. Looking at the pinout it doesn’t use i2c at all. I “think” its all done in ALSA? I’m far from being any kind of expert on this stuff though. The VU meter plugin is for ALSA.

Forgot to mention, I have a pHat Beat hooked up to a Pi Zero W running Pirate Radio (Internet Radio). Pretty well a stock install on Raspbian. Full Raspbian set to boot to command line. I just find doing the setup easier with a GUI instead of from the command line. Its running headless but I could hook a monitor up to check any files etc you might want the contents of.

Thanks for the links, I’m digging into i2(s!) :)

To be honest, you could send me all the files in the world and I wouldn’t know what to do with them yet. This is my first journey into Pis and the infrastructure around them. But thank you for the offer!

My Linux skills are pretty basic. I hadn’t touched Linux until I bought my first Raspberry Pi. I can do the basic stuff. Same deal with Python. I’m about average or maybe a little better skill wise there I think. I just keep plugging away at it. Sometimes its one step forward two steps back, but I usually get there eventually.

I usually just run the one line installer for the Pimoroni Hats and pHats. They also have the manual steps, which I believe gets you more messages / info when you run them. If your watching intently, that is.

Phil @gadgetoid is I believe the Pimoroni software guru. He may be able to point you in the right direction. Links to info etc. I only have a very basic understanding of it all. Just enough to be dangerous lol.

You might find some useful info if you poke around here a bit.
It might require some patience to sift through what’s useful and what’s not though. ;)