D1 Mini & VS1053b

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
SIGTERM
Posts: 4
Joined: Sun Mar 22, 2020 9:23 pm

D1 Mini & VS1053b

Post by SIGTERM » Sun Mar 22, 2020 9:31 pm

Hi folks,

my name is Chris and i try to get some sound out of an esp8266 with vs1053b.
I wired it as i think is correct ......so my code runs, but when i read from SPI, i always get FFFFFFFF. As well as it doesn't play a tone.
I tried to port the vs1053 adafruit circuitpy module (https://github.com/adafruit/Adafruit_Ci ... hon_VS1053).

What am i doing wrong?

init is:
self._xcs = Pin(xcs, Pin.OUT)
self._xdcs = Pin(xdcs, Pin.OUT)
self._dreq = Pin(dreq, Pin.IN)
self._spi = SPI(1, baudrate=_COMMAND_BAUDRATE, polarity=0, phase=0 )

reading :
self._SCI_SPI_BUFFER[0] = _VS1053_SCI_READ
self._SCI_SPI_BUFFER[1] = address & 0xFF
self._spi.init(baudrate=_COMMAND_BAUDRATE)
self._spi.write(self._SCI_SPI_BUFFER)
self._spi.readinto(self._SCI_SPI_BUFFER)

Regards,
Chris

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: D1 Mini & VS1053b

Post by jimmo » Mon Mar 23, 2020 12:30 am

Hi,

I don't see anywhere in your code where you're using the self._xcs pin (which I assume is your chip select). I'd expect to see it being set low before the operation, then high afterwards. (Chip select is generally active low).

(Similarly with _xdcs (not sure what that is? is it a Data/Command pin?)

SIGTERM
Posts: 4
Joined: Sun Mar 22, 2020 9:23 pm

Re: D1 Mini & VS1053b

Post by SIGTERM » Mon Mar 23, 2020 5:08 pm

Ok...you're right....i left out that part:
self._xdcs(0)
self._xcs(0)

i tried that in all variants.......just before and after operations.

oh...according to https://cdn.sparkfun.com/datasheets/Dev ... S1053B.pdf xdcs is "Data chip select / byte sync" .
Or in the SDI description it's "data interface chip select"....

SIGTERM
Posts: 4
Joined: Sun Mar 22, 2020 9:23 pm

Re: D1 Mini & VS1053b

Post by SIGTERM » Mon Apr 20, 2020 7:00 pm

So nobody can help me? Or give me a hint?
Please :-D

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: D1 Mini & VS1053b

Post by jimmo » Tue Apr 21, 2020 2:55 am

SIGTERM wrote:
Mon Apr 20, 2020 7:00 pm
So nobody can help me? Or give me a hint?
Please :-D
Could you post the latest version of your code. I'm not quite sure I followed what you said about setting cs to zero (do you also set it back to 1 again after the operation?).

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: D1 Mini & VS1053b

Post by pythoncoder » Thu Apr 23, 2020 5:49 am

@SIGTERM You might like to read this.

tl;dr According to Adafruit's own code comments their driver doesn't actually work. :o
Peter Hinch
Index to my micropython libraries.

gyroing
Posts: 3
Joined: Thu Apr 23, 2020 5:46 pm

Re: D1 Mini & VS1053b

Post by gyroing » Thu Apr 23, 2020 6:01 pm

this code works on esp32 micropython : https://github.com/urish/vs1053-circuitpython with little modification

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: D1 Mini & VS1053b

Post by pythoncoder » Fri Apr 24, 2020 6:08 am

That is interesting, it looks like he's done a good job of speeding up the response to the DREQ line. I wonder why Adafruit haven't taken this up?

Since DREQ is a physical pin it would seem to offer the possibility of using an IRQ. From a quick look at the datasheet the VS1053b has a 2KiB FIFO buffer. If an MP3 has a bitrate of 128Kbps that's 16KiB/s so the buffer holds 125ms of sound. On the face of it MicroPython on an ESP8266 should be able to keep up with this easily. Am I missing something here? I wonder where the problem is.
Peter Hinch
Index to my micropython libraries.

gyroing
Posts: 3
Joined: Thu Apr 23, 2020 5:46 pm

Re: D1 Mini & VS1053b

Post by gyroing » Fri Apr 24, 2020 10:15 am

i wonder is there any replace function for "spi.try_lock()" and "spi.unlock()" in mocropython, i removed these line form micropython code @ https://github.com/urish/vs1053-circuitpython and change the gpio acording to micropython - i could run internet radio . but wand to find the way to replace spi lock and unlock.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: D1 Mini & VS1053b

Post by pythoncoder » Fri Apr 24, 2020 10:40 am

Yes. I have ported code from Adafruit replacing their bus classes with straight I2C or SPI, for example this RA8875 driver. The object of the bus device code is simplify sharing the bus between multiple devices. They have a different approach to coding, prioritising ease of use by complete beginners over performance. It can make their code quite hard to follow.

The general MicroPython approach is rather the converse, prioritising small code size, performance and readability, potentially at the cost of assuming some degree of experience on the part of users.
Peter Hinch
Index to my micropython libraries.

Post Reply