<?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[M5Unit C6L Lora initialisation error]]></title><description><![CDATA[<p dir="auto">Hi, I am using the following program to test Lora on this model. However, i receive this error: [SX1262] Initializing... Failed, code: -2. I assume that i am using the correct ports as given in rthe documentation. Any suggestions ? Thanks ```<br />
#include &lt;RadioLib.h&gt;<br />
//#include &lt;arduino.h&gt;<br />
#include &lt;M5Unified.h&gt;<br />
#include &lt;SPI.h&gt;</p>
<p dir="auto">// SX1262: CS, IRQ, NRST, BUSY<br />
SX1262 radio = new Module(23, 7, RADIOLIB_NC, 19);</p>
<p dir="auto">bool receiveFlag = false;  // flag to indicate that a packet was received</p>
<p dir="auto">// function to be called when a complete packet is received<br />
void setFlag(void) {<br />
receiveFlag = true;<br />
}</p>
<p dir="auto">#define LORA_MISO 22 //38 //19<br />
#define LORA_MOSI 21 //23<br />
#define LORA_SCLK 20 //18</p>
<p dir="auto">void setup() {</p>
<p dir="auto">// auto cfg = M5.config();<br />
// M5.begin(cfg);</p>
<p dir="auto">Serial.begin(115200);<br />
M5.begin();<br />
delay(1000);</p>
<p dir="auto">Serial.println("And we have started");</p>
<pre><code>if (SPI.begin(LORA_SCLK, LORA_MISO, LORA_MOSI,-1))  // SCK, MISO, MOSI, SS
  {
    Serial.println("Fine");
    M5.Display.print("SPI is fine");
  }
else 
  {
     Serial.println("Not fine");
     M5.Display.print("SPI ERROR");
   }
</code></pre>
<p dir="auto">auto&amp; ioe = M5.getIOExpander(0);<br />
ioe.digitalWrite(7, false);<br />
delay(100);<br />
ioe.digitalWrite(7, true);  // re-enable SX_NRST<br />
ioe.digitalWrite(6, true);  // enable SX_ANT_SW<br />
ioe.digitalWrite(5, true);  // enable SX_LNA_EN</p>
<p dir="auto">// initialize SX1262<br />
Serial.print("\n[SX1262] Initializing... ");<br />
// frequency MHz, bandwidth kHz, spreading factor, coding rate denominator, sync word,<br />
// output power dBm, preamble length, TCXO reference voltage, useRegulatorLDO<br />
int beginState = radio.begin(868.0, 125.0, 12, 5, 0x34, 22, 20, 3.0, true);<br />
if (beginState == RADIOLIB_ERR_NONE) {<br />
Serial.println("Succeeded!");<br />
} else {<br />
Serial.print("Failed, code: ");<br />
Serial.println(beginState);<br />
while (true) { delay(100); }<br />
}</p>
<p dir="auto">// set the function to be called when a new packet is received<br />
radio.setPacketReceivedAction(setFlag);</p>
<p dir="auto">// start listening for LoRa packets<br />
Serial.print("[SX1262] Starting to listen... ");<br />
int receiveState = radio.startReceive();<br />
if (receiveState == RADIOLIB_ERR_NONE) {<br />
Serial.println("Succeeded!");<br />
} else {<br />
Serial.print("Failed, code: ");<br />
Serial.println(receiveState);<br />
while (true) { delay(100); }<br />
}<br />
}</p>
<p dir="auto">void loop() {<br />
if (receiveFlag) {      // check if a new packet is received<br />
receiveFlag = false;  // reset the flag</p>
<pre><code>String str;  // read the received data as an Arduino String
int readState = radio.readData(str);

if (readState == RADIOLIB_ERR_NONE) {  // packet was received successfully
  Serial.println("\n[SX1262] Received packet!");
  Serial.print("[SX1262] Data: ");
  Serial.println(str);

  Serial.print("[SX1262] RSSI: ");
  Serial.print(radio.getRSSI());  // Received Signal Strength Indicator
  Serial.println(" dBm");

  Serial.print("[SX1262]  SNR: ");
  Serial.print(radio.getSNR());  // Signal-to-Noise Ratio
  Serial.println(" dB");

  Serial.print("[SX1262] Frequency error: ");
  Serial.print(radio.getFrequencyError());
  Serial.println(" Hz");

} else if (readState == RADIOLIB_ERR_CRC_MISMATCH) {  // packet was received but malformed
  Serial.println("CRC error!");

} else {  // some other error occurred
  Serial.print("Failed, code: ");
  Serial.println(readState);
}
</code></pre>
<p dir="auto">}<br />
}</p>
<pre><code></code></pre>
]]></description><link>https://community.m5stack.com/topic/8098/m5unit-c6l-lora-initialisation-error</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 23:05:23 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/8098.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 23 Feb 2026 20:53:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to M5Unit C6L Lora initialisation error on Wed, 25 Feb 2026 10:09:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a> said in <a href="/post/30688">M5Unit C6L Lora initialisation error</a>:</p>
<blockquote>
<p dir="auto">here</p>
</blockquote>
<p dir="auto">thank you for figuring that out. Honestly, i would have expected that that would be dealt with in M5Unified. Anyway, module works great. Cam right on time on the market because we really need to upgrade our iot devices in the field.</p>
]]></description><link>https://community.m5stack.com/post/30689</link><guid isPermaLink="true">https://community.m5stack.com/post/30689</guid><dc:creator><![CDATA[HappyUser]]></dc:creator><pubDate>Wed, 25 Feb 2026 10:09:53 GMT</pubDate></item><item><title><![CDATA[Reply to M5Unit C6L Lora initialisation error on Wed, 25 Feb 2026 07:48:56 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/happyuser" aria-label="Profile: HappyUser">@<bdi>HappyUser</bdi></a></p>
<p dir="auto">glad to hear you figured it out.</p>
<p dir="auto">Well, part of M5GFX is used to try to figure out which board is in use. See code starting from <a href="https://github.com/m5stack/M5GFX/blob/0.2.15/src/M5GFX.cpp#L2052" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>. Maybe this detection went wrong somehow?</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/30688</link><guid isPermaLink="true">https://community.m5stack.com/post/30688</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 25 Feb 2026 07:48:56 GMT</pubDate></item><item><title><![CDATA[Reply to M5Unit C6L Lora initialisation error on Wed, 25 Feb 2026 07:38:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/happyuser" aria-label="Profile: HappyUser">@<bdi>HappyUser</bdi></a> Well, solved it. Updated M5GFX to 0.2.19 did the trick. What makes me wonder is how tis update is related to  a communication issue with the LoRa chap.</p>
]]></description><link>https://community.m5stack.com/post/30687</link><guid isPermaLink="true">https://community.m5stack.com/post/30687</guid><dc:creator><![CDATA[HappyUser]]></dc:creator><pubDate>Wed, 25 Feb 2026 07:38:54 GMT</pubDate></item><item><title><![CDATA[Reply to M5Unit C6L Lora initialisation error on Tue, 24 Feb 2026 20:14:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/happyuser" aria-label="Profile: HappyUser">@<bdi>HappyUser</bdi></a><br />
These are the libs that I am using. Could it be that somehow there is a difference with your config?<br />
Multiple libraries were found for "SPI.h"<br />
Used: /Users/..../Library/Arduino15/packages/m5stack/hardware/esp32/3.2.5/libraries/SPI<br />
Not used: /Users/....../Library/Arduino15/packages/m5stack/hardware/esp32/3.2.5/libraries/_DontUse_SPI<br />
Using library RadioLib at version 7.3.0 in folder: /Users/....../Documents/Arduino/libraries/RadioLib<br />
Using library SPI at version 3.2.1 in folder: /Users....../Library/Arduino15/packages/m5stack/hardware/esp32/3.2.5/libraries/SPI<br />
Using library M5Unified at version 0.2.13 in folder: /Users/....../Documents/Arduino/libraries/M5Unified<br />
Using library M5GFX at version 0.2.15 in folder: /Users.../Documents/Arduino/libraries/M5GFX<br />
/Users/....../Library/Arduino15/packages/m5stack/tools/esp-rv32/2411/bin/riscv32-esp-elf-size -A /Users/..../Library/Caches/arduino/sketches/E220783385D73AB555D51793968410FB/LoRa_Test.ino.elf<br />
Sketch uses 434305 bytes (33%) of program storage space. Maximum is 1310720 bytes.<br />
Global variables use 17508 bytes (5%) of dynamic memory, leaving 310172 bytes for local variables. Maximum is 327680 bytes.<br />
<a href="http://esptool.py" target="_blank" rel="noopener noreferrer nofollow ugc">esptool.py</a> v4.8.1<br />
Serial port /dev/cu.usbmodem1101:<br />
Connecting...<br />
Connected to ESP32-C6 on /dev/cu.usbmodem1101:<br />
Chip type:          ESP32-C6 (QFN40) (revision v0.2)<br />
Features:           Wi-Fi 6, BT 5 (LE), IEEE802.15.4, Single Core + LP Core, 160MHz<br />
Crystal frequency:  40MHz<br />
USB mode:           USB-Serial/JTAG<br />
MAC:                58:8c:81:ff:fe:50:00:08<br />
BASE MAC:           58:8c:81:50:00:08<br />
MAC_EXT:            ff:fe</p>
]]></description><link>https://community.m5stack.com/post/30683</link><guid isPermaLink="true">https://community.m5stack.com/post/30683</guid><dc:creator><![CDATA[HappyUser]]></dc:creator><pubDate>Tue, 24 Feb 2026 20:14:22 GMT</pubDate></item><item><title><![CDATA[Reply to M5Unit C6L Lora initialisation error on Tue, 24 Feb 2026 15:14:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a> Thank you. I tried this extra spi call because I assumed that something is wrong with SPI. Leaving out this call does not solve the problem either. Bot M5Unified and and radiolib are updated. M5Stack board manager is also updated. This is very weird. Not sure how to process further.</p>
]]></description><link>https://community.m5stack.com/post/30682</link><guid isPermaLink="true">https://community.m5stack.com/post/30682</guid><dc:creator><![CDATA[HappyUser]]></dc:creator><pubDate>Tue, 24 Feb 2026 15:14:49 GMT</pubDate></item><item><title><![CDATA[Reply to M5Unit C6L Lora initialisation error on Tue, 24 Feb 2026 14:39:09 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/happyuser" aria-label="Profile: HappyUser">@<bdi>HappyUser</bdi></a></p>
<p dir="auto">hmm, both examples (w/o any modifications) work for me ok - no error.</p>
<p dir="auto">Question: why are you using <code>SPI.begin()</code> in your code? I don't see that in the linked example.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/30681</link><guid isPermaLink="true">https://community.m5stack.com/post/30681</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Tue, 24 Feb 2026 14:39:09 GMT</pubDate></item><item><title><![CDATA[Reply to M5Unit C6L Lora initialisation error on Tue, 24 Feb 2026 11:45:30 GMT]]></title><description><![CDATA[<p dir="auto">I receive this debug error message : GPIO pre-transfer timeout, is it connected? which is located in in the function<br />
int16_t Module::SPItransferStream(const uint8_t* cmd, uint8_t cmdLen, bool write, const uint8_t* dataOut, uint8_t* dataIn, size_t numBytes, bool waitForGpio)<br />
in the file Module.cpp</p>
<p dir="auto">I am using the example in this M5Stack link : <a href="https://docs.m5stack.com/en/arduino/unit_c6l/lora" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.m5stack.com/en/arduino/unit_c6l/lora</a></p>
<p dir="auto">Help is appreciated.<br />
Regards</p>
]]></description><link>https://community.m5stack.com/post/30680</link><guid isPermaLink="true">https://community.m5stack.com/post/30680</guid><dc:creator><![CDATA[HappyUser]]></dc:creator><pubDate>Tue, 24 Feb 2026 11:45:30 GMT</pubDate></item></channel></rss>