<?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[Micropython SPI]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I've got a M5basic module with fw version 1.4.5.1 and not to mention SPI sensor.<br />
Code in Visual studio code. When importing SPI I'm getting the error: 'cannot import SPI'</p>
<p dir="auto">I'm following the documentation: <a href="https://github.com/m5stack/M5Stack_MicroPython" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Stack_MicroPython</a></p>
<p dir="auto">I investigated and it appears the 'machine' module does not have SPI.<br />
So my question: How do I make SPI work on M5stack with micropython 1.4.5?<br />
Secondary question: All documentation seems old or in complete. Where can I find the newest/most complete information?</p>
<p dir="auto">---- Code from documentation</p>
<p dir="auto">from machine import SPI, Pin</p>
<p dir="auto">spi = SPI(<br />
spihost=SPI.HSPI,<br />
baudrate=2600000<br />
sck=Pin(18),<br />
mosi=Pin(23),<br />
miso=Pin(19),<br />
cs=Pin(4)<br />
)</p>
<p dir="auto">spi.write(buf) #NOHEAP<br />
spi.read(nbytes, *, write=0x00) #write is the byte to ?output on MOSI for each byte read in<br />
spi.readinto(buf, *, write=0x00) #NOHEAP<br />
spi.write_readinto(write_buf, read_buf) #NOHEAP; write_buf and read_buf can be the same</p>
<p dir="auto">------Machine module, python terminal: help("machine")</p>
<p dir="auto">object &lt;module 'umachine'&gt; is of type module<br />
<strong>name</strong> -- umachine<br />
mem8 -- &lt;8-bit memory&gt;<br />
mem16 -- &lt;16-bit memory&gt;<br />
mem32 -- &lt;32-bit memory&gt;<br />
freq -- &lt;function&gt;<br />
reset -- &lt;function&gt;<br />
unique_id -- &lt;function&gt;<br />
sleep -- &lt;function&gt;<br />
lightsleep -- &lt;function&gt;<br />
deepsleep -- &lt;function&gt;<br />
idle -- &lt;function&gt;<br />
disable_irq -- &lt;function&gt;<br />
enable_irq -- &lt;function&gt;<br />
heap_info -- &lt;function&gt;<br />
time_pulse_us -- &lt;function&gt;<br />
nvs_setint -- &lt;function&gt;<br />
nvs_getint -- &lt;function&gt;<br />
nvs_setstr -- &lt;function&gt;<br />
nvs_getstr -- &lt;function&gt;<br />
nvs_erase -- &lt;function&gt;<br />
nvs_erase_all -- &lt;function&gt;<br />
random -- &lt;function&gt;<br />
Timer -- &lt;class 'Timer'&gt;<br />
WDT -- &lt;class 'WDT'&gt;<br />
SLEEP -- 2<br />
DEEPSLEEP -- 4<br />
Pin -- &lt;class 'Pin'&gt;<br />
Signal -- &lt;class 'Signal'&gt;<br />
TouchPad -- &lt;class 'TouchPad'&gt;<br />
ADC -- &lt;class 'ADC'&gt;<br />
DAC -- &lt;class 'DAC'&gt;<br />
I2C -- &lt;class 'I2C'&gt;<br />
I2S -- &lt;class 'I2S'&gt;<br />
PWM -- &lt;class 'PWM'&gt;<br />
RTC -- &lt;class 'RTC'&gt;<br />
UART -- &lt;class 'UART'&gt;<br />
Neopixel -- &lt;class 'Neopixel'&gt;<br />
reset_cause -- &lt;function&gt;<br />
HARD_RESET -- 2<br />
PWRON_RESET -- 1<br />
WDT_RESET -- 3<br />
DEEPSLEEP_RESET -- 4<br />
SOFT_RESET -- 5<br />
wake_reason -- &lt;function&gt;<br />
PIN_WAKE -- 2<br />
EXT0_WAKE -- 2<br />
EXT1_WAKE -- 3<br />
TIMER_WAKE -- 4<br />
TOUCHPAD_WAKE -- 5<br />
ULP_WAKE -- 6</p>
]]></description><link>https://community.m5stack.com/topic/1845/micropython-spi</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 23:05:22 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/1845.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Apr 2020 17:03:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Micropython SPI on Thu, 16 Apr 2020 17:47:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tialm" aria-label="Profile: tialm">@<bdi>tialm</bdi></a> The problem is that the firmware is constantly changing as they work to ix bugs in the firmware. They are working to get it up to the same level as mainstream Micropython but its slow going.<br />
I'm currently digging through demo and examples (that I'm creating) to find the API's but its slow going due to the rapidly changing firmware.</p>
]]></description><link>https://community.m5stack.com/post/8173</link><guid isPermaLink="true">https://community.m5stack.com/post/8173</guid><dc:creator><![CDATA[ajb2k3]]></dc:creator><pubDate>Thu, 16 Apr 2020 17:47:50 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Thu, 16 Apr 2020 03:17:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jwrm22" aria-label="Profile: jwrm22">@<bdi>jwrm22</bdi></a> SPI can be found in machine module</p>
<pre><code>from machine import SPI

</code></pre>
]]></description><link>https://community.m5stack.com/post/8171</link><guid isPermaLink="true">https://community.m5stack.com/post/8171</guid><dc:creator><![CDATA[lukasmaximus]]></dc:creator><pubDate>Thu, 16 Apr 2020 03:17:03 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Wed, 15 Apr 2020 23:17:32 GMT]]></title><description><![CDATA[<p dir="auto">As well as any decent documentation. Its a known problem</p>
]]></description><link>https://community.m5stack.com/post/8170</link><guid isPermaLink="true">https://community.m5stack.com/post/8170</guid><dc:creator><![CDATA[Thrasher]]></dc:creator><pubDate>Wed, 15 Apr 2020 23:17:32 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Wed, 15 Apr 2020 17:08:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thrasher" aria-label="Profile: thrasher">@<bdi>thrasher</bdi></a> I did it and it works fine. The only downside is that M5Stack doens't give you their micropython libraries to work with...  They claim they are open source ( and that was why I got into it) but then they don't share the sources that we need to make the best of the hardware.. I have asked for some in other posts and got no reply</p>
]]></description><link>https://community.m5stack.com/post/8165</link><guid isPermaLink="true">https://community.m5stack.com/post/8165</guid><dc:creator><![CDATA[tialm]]></dc:creator><pubDate>Wed, 15 Apr 2020 17:08:59 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Mon, 13 Apr 2020 09:59:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/crami25" aria-label="Profile: crami25">@<bdi>crami25</bdi></a> Ok. SPI is used both for the SD card and TFT.<br />
The link to the micropython docs is not the same as any of the m5stsck firmware.<br />
The SPI in the machine module does not exist.</p>
<p dir="auto">Can you tell me how I install or add SPI to a micropython build?</p>
]]></description><link>https://community.m5stack.com/post/8139</link><guid isPermaLink="true">https://community.m5stack.com/post/8139</guid><dc:creator><![CDATA[jwrm22]]></dc:creator><pubDate>Mon, 13 Apr 2020 09:59:20 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Sun, 12 Apr 2020 22:16:27 GMT]]></title><description><![CDATA[<p dir="auto">@ you can find the micropython SPI API in the microphyton reference:<br />
<a href="https://docs.micropython.org/en/latest/esp32/quickref.html#software-spi-bus" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.micropython.org/en/latest/esp32/quickref.html#software-spi-bus</a><br />
M5Stack has a repository hooking up a SPI TFT display to the M5Stack on github:<br />
<a href="https://github.com/m5stack/M5Stack_TFT_ILI9341" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5Stack_TFT_ILI9341</a></p>
<p dir="auto">They are using following Pins for the Hardware SPI bus (vspi, ID channel 2) in order not to have any conflicts with the built in components:<br />
MOSI: 23<br />
MISO: 19<br />
SCK : 18<br />
CS: 5 (Display CS)<br />
DC: 26 (display DC)<br />
TCS: 25 (touch screen CS)</p>
]]></description><link>https://community.m5stack.com/post/8137</link><guid isPermaLink="true">https://community.m5stack.com/post/8137</guid><dc:creator><![CDATA[crami25]]></dc:creator><pubDate>Sun, 12 Apr 2020 22:16:27 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Sun, 12 Apr 2020 22:01:29 GMT]]></title><description><![CDATA[<p dir="auto">Anyone tried flashing m5 stack basic device with raw micropython? Will it brick the device? I doubt that. Raw micropython works just fine with atom and reflashes to uiflow just okay.</p>
]]></description><link>https://community.m5stack.com/post/8136</link><guid isPermaLink="true">https://community.m5stack.com/post/8136</guid><dc:creator><![CDATA[Thrasher]]></dc:creator><pubDate>Sun, 12 Apr 2020 22:01:29 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Sun, 12 Apr 2020 21:51:06 GMT]]></title><description><![CDATA[<p dir="auto">I do not have enough knowledge of python or git to find the files that write SPI.<br />
I've found some .c files but don't know what to do with them.</p>
]]></description><link>https://community.m5stack.com/post/8135</link><guid isPermaLink="true">https://community.m5stack.com/post/8135</guid><dc:creator><![CDATA[jwrm22]]></dc:creator><pubDate>Sun, 12 Apr 2020 21:51:06 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Sun, 12 Apr 2020 20:22:52 GMT]]></title><description><![CDATA[<p dir="auto">While I understand that the SPI is used for the SD card.<br />
On the back of the  m5stack SPI is clearly broken out. No hand soldering required.<br />
I do not need CS it's just what's used as example.</p>
<p dir="auto">There is an implementation in the sited m5stack git source on software SPI on different pins.<br />
I'm just annoyed the software and documentation are not in sync.<br />
Do you know where I can find the source used to build 1.4.5.1 for instance?</p>
<p dir="auto">I'll see if I can find the code to read/write to the SD card.</p>
]]></description><link>https://community.m5stack.com/post/8134</link><guid isPermaLink="true">https://community.m5stack.com/post/8134</guid><dc:creator><![CDATA[jwrm22]]></dc:creator><pubDate>Sun, 12 Apr 2020 20:22:52 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Sun, 12 Apr 2020 19:18:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jwrm22" aria-label="Profile: jwrm22">@<bdi>jwrm22</bdi></a>  Want to brick your ESP32 with SPI programming ?</p>
<p dir="auto">see <a href="http://community.m5stack.com/topic/1840/issues-interfacing-mfrc522-rfid-with-m5stack" target="_blank" rel="noopener noreferrer nofollow ugc">http://community.m5stack.com/topic/1840/issues-interfacing-mfrc522-rfid-with-m5stack</a></p>
<p dir="auto">Using GPIO4 CS ?  It is used as CS on the micro SD card reader of the M5Stack: You either have to solder a wire to your ESP32:</p>
<p dir="auto"><img src="/assets/uploads/files/1586717164809-9ef98010-a52f-4a4e-9e6a-79b669499a82-image.png" alt="0_1586717155260_9ef98010-a52f-4a4e-9e6a-79b669499a82-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">or make a micro sd card adapter connecting wires to micro sd card:<img src="/assets/uploads/files/1586716835293-75d899e5-34fd-4672-9285-01744d8e4c14-image.png" alt="0_1586716832850_75d899e5-34fd-4672-9285-01744d8e4c14-image.png" class=" img-fluid img-markdown" /><br />
GPIO4 is on your microSD Pin 2 !<br />
You can get all the SPI signals you wanted in the sd Micro card adapter ! <a href="https://github.com/m5stack/M5-Schematic/blob/master/Core/Basic/M5-Core-Schematic(20171206).pdf" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/m5stack/M5-Schematic/blob/master/Core/Basic/M5-Core-Schematic(20171206).pdf</a><br />
<img src="/assets/uploads/files/1586717906304-fba69185-f178-408f-918d-707836984713-image.png" alt="0_1586717905380_fba69185-f178-408f-918d-707836984713-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Your copy and paste Micropython code from the M5Stack reference is the basic API reading/writing to the SD (SPI) micro card !</p>
<p dir="auto"><img src="/assets/uploads/files/1586719044833-2c44b6a7-a9ee-453a-839f-f0eff2d2973e-image.png" alt="0_1586719044843_2c44b6a7-a9ee-453a-839f-f0eff2d2973e-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/8133</link><guid isPermaLink="true">https://community.m5stack.com/post/8133</guid><dc:creator><![CDATA[crami25]]></dc:creator><pubDate>Sun, 12 Apr 2020 19:18:16 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython SPI on Sun, 12 Apr 2020 17:48:43 GMT]]></title><description><![CDATA[<p dir="auto">1.3.2 does not contain the I2C/SPI etc. in the machine module.</p>
<p dir="auto">1.2.3 does include SPI but none of the other code works as uiflow module does not exist.</p>
]]></description><link>https://community.m5stack.com/post/8132</link><guid isPermaLink="true">https://community.m5stack.com/post/8132</guid><dc:creator><![CDATA[jwrm22]]></dc:creator><pubDate>Sun, 12 Apr 2020 17:48:43 GMT</pubDate></item></channel></rss>