Remarks

Yx5300
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Yx5300

Code Example

public MeadowApp()
{
    Console.WriteLine("Initialize hardware...");

    var mp3Player = new Yx5300(Device, Device.SerialPortNames.Com4);

    //using an async task - this code would likely go in an async method
    Task.Run(async () =>
    {
        mp3Player.SetVolume(15);

        var status = await mp3Player.GetStatus();
        Console.WriteLine($"Status: {status}");

        var count = await mp3Player.GetNumberOfTracksInFolder(0);
        Console.WriteLine($"Number of tracks: {count}");

        mp3Player.Play();

        await Task.Delay(5000); //leave playing for 5 seconds

        mp3Player.Next();

        await Task.Delay(5000); //leave playing for 5 seconds
    });
}

Sample project(s) available on GitHub

Wiring Example

To wire a Yx5300 to your Meadow board, connect the following:

Yx5300 Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00

Characteristic Locus
Inheritance System.Object > Yx5300
Namespace Meadow.Foundation.Audio.Mp3
Assembly Yx5300.dll

Syntax

public class Yx5300 : object

Constructors

Yx5300(IMeadowDevice, SerialPortName)

Create a YX5300 mp3 player object

Declaration
public Yx5300(IMeadowDevice device, SerialPortName serialPortName)

Parameters

Type Name Description
IMeadowDevice device

Meadow device

SerialPortName serialPortName

Name of serial port connected to YX5300

Yx5300(ISerialPort)

Create a YX5300 mp3 player object

Declaration
protected Yx5300(ISerialPort serialPort)

Parameters

Type Name Description
ISerialPort serialPort

Methods

GetIndexOfCurrentFile()

Get index of currently playing file

Declaration
public Task<byte> GetIndexOfCurrentFile()

Returns

Type Description
Task<System.Byte>

GetNumberOfFolders()

Get number of folders

Declaration
public Task<byte> GetNumberOfFolders()

Returns

Type Description
Task<System.Byte>

GetNumberOfTracksInFolder(Byte)

Get count of mp3 files in folder

Declaration
public Task<byte> GetNumberOfTracksInFolder(byte folderIndex)

Parameters

Type Name Description
System.Byte folderIndex

index of folder

Returns

Type Description
Task<System.Byte>

GetStatus()

Get status of YX5300

Declaration
public Task<Yx5300.PlayStatus> GetStatus()

Returns

Type Description
Task<Yx5300.PlayStatus>

PlayStatus enum

GetVolume()

Get audio volume (0-30)

Declaration
public Task<byte> GetVolume()

Returns

Type Description
Task<System.Byte>

Next()

Advance to next track

Declaration
public void Next()

Pause()

Pause current mp3

Declaration
public void Pause()

Play()

Play current file

Declaration
public void Play()

Play(Byte)

Play song at index

Declaration
public void Play(byte songIndex)

Parameters

Type Name Description
System.Byte songIndex

index of mp3 file in folder

Previous()

Move back to previous track

Declaration
public void Previous()

Reset()

Reset the YX5300 hardware

Declaration
public void Reset()

SetVolume(Byte)

Set volume of YX5300

Declaration
public void SetVolume(byte volume)

Parameters

Type Name Description
System.Byte volume

byte value from 0-30

Sleep()

Set the power state to sleep

Declaration
public void Sleep()

Stop()

Stop current mp3

Declaration
public void Stop()

VolumeDown()

Decrease audio volume by 1 (0-30)

Declaration
public void VolumeDown()

VolumeUp()

Increase audio volume by 1 (0-30)

Declaration
public void VolumeUp()

WakeUp()

Set the power state to normal operations

Declaration
public void WakeUp()