Light Activated Music Player - Blinka - Circuitpython

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
lyster1
 
Posts: 7
Joined: Mon Mar 25, 2024 1:39 am

Light Activated Music Player - Blinka - Circuitpython

Post by lyster1 »

G'day,
I'm using a raspberry pi zero 2w to make a light activated music player, i.e. when it detects light, it plays a wav file when it detects light.
I've used the standard raspberry pi firmware from the raspberry pi imager and then installed / updated it to inlcude the blinka so that I can use the circuitpython libraries without actually installing circuitpython. I did it using this guide: https://learn.adafruit.com/circuitpytho ... spberry-pi

The resaon I've done this is preserve the functionality of the satdnard pi firmware installation in terms of the FTP / SSH / VNC functionality however I bought the Adafruit I2S 3W Class D Amplifier Breakout - MAX98357A and associated speaker and am intending on using this guidance / code to activate the music player.
https://learn.adafruit.com/mp3-playback ... co-i2s-mp3

I've got the light sensor workign however the code from above (adafruit) throws up an error sayign it doesn't recognise audiocore, I presume it's because I'm not actuall running circuit python.
My impression was (perhaps falsely) that installing blinka woudl automatically include circuitpython functionality and circuitpython functions and code woudl be immediately recognised.

I'd appreciate any feedback on how I might make this work.

Thanks in advance.

User avatar
adafruit_support_mike
 
Posts: 67504
Joined: Thu Feb 11, 2010 2:51 pm

Re: Light Activated Music Player - Blinka - Circuitpython

Post by adafruit_support_mike »

You need to do some additional setup on a RasPi to make I2S work:

https://learn.adafruit.com/adafruit-max ... y-pi-usage

User avatar
lyster1
 
Posts: 7
Joined: Mon Mar 25, 2024 1:39 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by lyster1 »

Thanks for that, I'll incorporate your advice.

Will that take care of the recognition of the audiocore module as well as I got this error when attemting to import the audiocore module --> Import Error: No Module Named audiocore

User avatar
adafruit_support_mike
 
Posts: 67504
Joined: Thu Feb 11, 2010 2:51 pm

Re: Light Activated Music Player - Blinka - Circuitpython

Post by adafruit_support_mike »

Hopefully.

The error probably means the audiocore module isn't there because the RasPi hasn't been set up for I2S yet. It's a dependency thing.

User avatar
lyster1
 
Posts: 7
Joined: Mon Mar 25, 2024 1:39 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by lyster1 »

G'day Mike,
I attempted the I2S setup you suggested and nothing changed. The self testing was all successful however I noted during the audio testing part that nothing came out of the speaker even though the program said it was successful.
In running the program I still also got the audiocore module error (audiocore module --> Import Error: No Module Named audiocore).

User avatar
adafruit_support_mike
 
Posts: 67504
Joined: Thu Feb 11, 2010 2:51 pm

Re: Light Activated Music Player - Blinka - Circuitpython

Post by adafruit_support_mike »

Let me check with some of the other folks who know that part of the system better.

User avatar
lyster1
 
Posts: 7
Joined: Mon Mar 25, 2024 1:39 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by lyster1 »

Thanks Mike,
Further to this and if it helps, I've wired my Pi Zero 2W Board Pins to the MAX98357A as follows:
  • Pin 1 (3V3) to VIN
  • Pin 6 (GND) to GND
  • Pin 27 (GPIO 0) to BCLK
  • Pin 28 (GPIO 1) to LRC
  • Pin 3 (GPIO 2) to DIN
This is how I interpretted the guidance for the pico onto my zero 2w from here:
https://learn.adafruit.com/mp3-playback ... co-i2s-mp3

I presume the link you sent me then sets those pins up for I2S audio.

Thanks again for your assistance.

User avatar
MakerMelissa
 
Posts: 379
Joined: Wed Jun 05, 2013 2:10 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by MakerMelissa »

Hi, for the Raspberry Pi, it has dedicated I2S pins. Here's how it should be wired according to a project (https://learn.adafruit.com/robotic-ai-b ... it-diagram) that I did last year using the MAX98357 on the Pi:

Pin 1 (3V3) to VIN
Pin 6 (GND) to GND
Pin 12 (GPIO 18) to BCLK
Pin 35 (GPIO 19) to LRC
Pin 40 (GPIO 21) to DIN

Here's a nice diagram of the pins on the Pi: https://pinout.xyz/

User avatar
lyster1
 
Posts: 7
Joined: Mon Mar 25, 2024 1:39 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by lyster1 »

G'day MakerMelissa,
Thanks for your reply. I've been attempting to follow this guidance:
https://learn.adafruit.com/mp3-playback ... co-i2s-mp3
Which suggests:
Pico 3V3 to breakout VIN
Pico GND to breakout GND
Pico GP0 (I2C0 SDA) to breakout BCLK
Pico GP1 (I2C0 SDC) to breakout LRC
Pico GP2 (I2C1 SDA) to breakout DIN

Which, I've reinterpretted for the Pi Zero 2w as:
Zero 3V3 to breakout VIN
Zero GND to breakout GND
Zero GPIO0 (I2C SDA0, Pin 27) to breakout BCLK
Zero GPIO1 (I2C SDC0, Pin 28) to breakout LRC
Zero GPIO2 (I2C SDA1, Pin 3) to breakout DIN

I'm slightly confused because the pins you've specified don't seem to correspond to the I2S on the PI (unless I'm missing something which is quite possible as I'm relatively new to this):

Pin 12 (GPIO 18) --> PCM CLK
Pin 35 (GPIO 19) --> PCM FS
Pin 40 (GPIO 21) --> PCM DOUT

Also Pin 12 on the Pi Zero is the same as the Pi but I didn't find any equivalents on my Zero for PCM FS or PCM DOUT?

Thansk again for your input.

User avatar
MakerMelissa
 
Posts: 379
Joined: Wed Jun 05, 2013 2:10 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by MakerMelissa »

It sounds like there is some confusion because "Raspberry Pi" is both the name of the company and a line of products that company produces called Single Board Computers. The Pi Zero 2w is one of the Single Board Computers. They started getting into microcontrollers a few years back and designed the RP2040 processor and Raspberry Pi pico microcontroller board, which runs that processor.

So, you are using a guide for the microcontroller, but attempting to wire up a single board computer. A much better guide to follow (at least for wiring) is: https://learn.adafruit.com/adafruit-max ... -pi-wiring, which tells you exactly what you need. :)

Melissa

User avatar
lyster1
 
Posts: 7
Joined: Mon Mar 25, 2024 1:39 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by lyster1 »

G'day Melissa,
Thanks for the clarification and that was exactly it. I did a totally fresh install of the OS, Blinka and followed the guidance you recommended and I finally got the music player part of it working, at least runnign it from the command line. The next bit is to code it into python.

Thanks again for your assistance and expertise.

Regards,

Wade

User avatar
MakerMelissa
 
Posts: 379
Joined: Wed Jun 05, 2013 2:10 am

Re: Light Activated Music Player - Blinka - Circuitpython

Post by MakerMelissa »

You're welcome. Glad to be of help.

Melissa

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”