<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ATOM SPK SPEAKER KIT]]></title><description><![CDATA[<p dir="auto">Hello, some example of how to use SPK with the library: <a href="https://github.com/earlephilhower/ESP8266Audio" target="_blank" rel="noopener noreferrer nofollow ugc">github</a></p>
<p dir="auto">How do I configure the output to use the spk chip?<br />
I have modified an example in the ide, but I don't know if it is correct.</p>
<p dir="auto">This example in theory plays an mp3 station</p>
<p dir="auto">Thanks for the help<br />
All the best<br />
Francisco</p>
<p dir="auto">#include &lt;Arduino.h&gt;<br />
#include &lt;M5Atom.h&gt;<br />
#include &lt;WiFi.h&gt;<br />
#include "AudioFileSourceICYStream.h"<br />
#include "AudioFileSourceBuffer.h"<br />
#include "AudioGeneratorMP3.h"<br />
//#include "AudioOutputI2SNoDAC.h"<br />
#include "AudioOutputI2S.h"</p>
<p dir="auto">// Enter your WiFi setup here:<br />
#ifndef STASSID<br />
#define STASSID "TESTWIFI"<br />
#define STAPSK  "TEST"<br />
#endif</p>
<p dir="auto">// Digital I/O used<br />
#define I2S_DOUT      25  // DIN connection<br />
#define I2S_BCLK      22  // Bit clock<br />
#define I2S_LRC       21  // Left Right Clock</p>
<p dir="auto">const char* ssid = STASSID;<br />
const char* password = STAPSK;</p>
<p dir="auto">// Randomly picked URL<br />
const char* URL = "<a href="http://kvbstreams.dyndns.org:8000/wkvi-am" target="_blank" rel="noopener noreferrer nofollow ugc">http://kvbstreams.dyndns.org:8000/wkvi-am</a>";</p>
<p dir="auto">AudioGeneratorMP3* mp3;<br />
AudioFileSourceICYStream* file;<br />
AudioFileSourceBuffer* buff;<br />
//AudioOutputI2SNoDAC* out;<br />
AudioOutputI2S* out = NULL;<br />
//AudioOutputI2S* out</p>
<p dir="auto">void setup()<br />
{<br />
M5.begin();</p>
<pre><code>Serial.begin(9600);
delay(1000);
Serial.println("Connecting to WiFi");

WiFi.disconnect();
WiFi.softAPdisconnect(true);
WiFi.mode(WIFI_STA);

WiFi.begin(ssid, password);

// Try forever
while (WiFi.status() != WL_CONNECTED) {
	Serial.println("...Connecting to WiFi");
	delay(1000);
}
Serial.println("Connected");

audioLogger = &amp;Serial;
file = new AudioFileSourceICYStream(URL);
file-&gt;RegisterMetadataCB(MDCallback, (void*)"ICY");
buff = new AudioFileSourceBuffer(file, 2048);
buff-&gt;RegisterStatusCB(StatusCallback, (void*)"buffer");
//out = new AudioOutputI2SNoDAC();

out = new AudioOutputI2S(0, 1, 32);
out-&gt;begin();



mp3 = new AudioGeneratorMP3();
mp3-&gt;RegisterStatusCB(StatusCallback, (void*)"mp3");
mp3-&gt;begin(buff, out);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void loop()<br />
{<br />
static int lastms = 0;</p>
<pre><code>if (mp3-&gt;isRunning()) {
	if (millis() - lastms &gt; 1000) {
		lastms = millis();
		Serial.printf("Running for %d ms...\n", lastms);
		Serial.flush();
	}
	if (!mp3-&gt;loop()) mp3-&gt;stop();
}
else {
	Serial.printf("MP3 done\n");
	delay(1000);
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">// Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc.<br />
void MDCallback(void* cbData, const char* type, bool isUnicode, const char* string)<br />
{<br />
const char* ptr = reinterpret_cast&lt;const char*&gt;(cbData);<br />
(void)isUnicode; // Punt this ball for now<br />
// Note that the type and string may be in PROGMEM, so copy them to RAM for printf<br />
char s1[32], s2[64];<br />
strncpy_P(s1, type, sizeof(s1));<br />
s1[sizeof(s1) - 1] = 0;<br />
strncpy_P(s2, string, sizeof(s2));<br />
s2[sizeof(s2) - 1] = 0;<br />
Serial.printf("METADATA(%s) '%s' = '%s'\n", ptr, s1, s2);<br />
Serial.flush();<br />
}</p>
<p dir="auto">// Called when there's a warning or error (like a buffer underflow or decode hiccup)<br />
void StatusCallback(void* cbData, int code, const char* string)<br />
{<br />
const char* ptr = reinterpret_cast&lt;const char*&gt;(cbData);<br />
// Note that the string may be in PROGMEM, so copy it to RAM for printf<br />
char s1[64];<br />
strncpy_P(s1, string, sizeof(s1));<br />
s1[sizeof(s1) - 1] = 0;<br />
Serial.printf("STATUS(%s) '%d' = '%s'\n", ptr, code, s1);<br />
Serial.flush();<br />
}</p>
<p dir="auto">Thanks for the help<br />
All the best<br />
Francisco</p>
]]></description><link>https://community.m5stack.com/topic/3925/atom-spk-speaker-kit</link><generator>RSS for Node</generator><lastBuildDate>Mon, 04 May 2026 17:15:29 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/3925.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Jan 2022 08:41:25 GMT</pubDate><ttl>60</ttl></channel></rss>