<?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[Core2 with W5500 and RS485 (ModbusMaster) with more then 2 slaves]]></title><description><![CDATA[<p dir="auto">Hello, everyone</p>
<p dir="auto">I am trying to read data from 4 slaves with M5Core via Modbus RTU. Unfortunately, only communication with 2 slaves works. As soon as a third slave comes along, the connection breaks down with errorcode "E2" (Timeout).</p>
<p dir="auto">Here the code:</p>
<p dir="auto">#include &lt;M5Stack.h&gt;<br />
#include &lt;ModbusMaster.h&gt;</p>
<p dir="auto">ModbusMaster node1,node2,node3,node4;</p>
<p dir="auto">uint8_t result1,result2,result3,result4;<br />
TFT_eSprite img = TFT_eSprite(&amp;M5.Lcd);<br />
int i;</p>
<p dir="auto">void setup() {</p>
<p dir="auto">M5.begin(true, false, true, false);  // Init M5Core.<br />
M5.Power.begin();  // Init Power module.<br />
img.setColorDepth(8); // Set color depth.<br />
img.setTextSize(2);<br />
img.createSprite(320, 240);  //Create a 320x240 canvas.</p>
<p dir="auto">Serial.begin(115200);<br />
Serial1.begin(9600,SERIAL_8N1,16,17);</p>
<p dir="auto">node1.begin(1, Serial1);<br />
node2.begin(2 , Serial1);<br />
node3.begin(3, Serial1);<br />
node4.begin(4, Serial1);</p>
<p dir="auto">}</p>
<p dir="auto">void loop() {</p>
<p dir="auto">Check1();<br />
delay(1000);<br />
Check2();<br />
delay(1000);<br />
Check3();<br />
delay(1000);<br />
Check4();<br />
delay(1000);<br />
}</p>
<p dir="auto">void Check1(){<br />
i=1;<br />
// Read 21 register starting at 0<br />
while ((i&gt;0)&amp;(i&lt;5))  {<br />
result1 = node1.readInputRegisters(0,21);<br />
Serial.println(result1, HEX);</p>
<p dir="auto">if (result1 == node1.ku8MBSuccess) {<br />
Serial.print("Id1 ");<br />
Serial.print(node1.getResponseBuffer(0)/100);<br />
Serial.print(node1.getResponseBuffer(1)/100);<br />
Serial.println(node1.getResponseBuffer(2)/100);<br />
i=0;<br />
}<br />
else {<br />
Serial.print("Error ID1\n");<br />
delay(250);<br />
i++;<br />
}<br />
}<br />
}<br />
void Check2(){<br />
i=1;<br />
// Read 21 register starting at 0<br />
while ((i&gt;0)&amp;(i&lt;5))  {<br />
result2 = node2.readInputRegisters(0,21);<br />
Serial.println(result2, HEX);</p>
<p dir="auto">if (result2 == node2.ku8MBSuccess) {<br />
Serial.print("Id2 ");<br />
Serial.print(node2.getResponseBuffer(0)/100);<br />
Serial.print(node2.getResponseBuffer(1)/100);<br />
Serial.println(node2.getResponseBuffer(2)/100);<br />
i=0;<br />
}<br />
else {<br />
Serial.print("Error ID2\n");<br />
delay(250);<br />
i++;<br />
}<br />
}<br />
}</p>
<p dir="auto">void Check3(){<br />
// Read 21 register starting at 0<br />
result3 = node3.readInputRegisters(0,21);</p>
<p dir="auto">Serial.println(result3, HEX);</p>
<p dir="auto">if (result3 == node3.ku8MBSuccess) {<br />
Serial.print("Id3 ");<br />
Serial.print(node3.getResponseBuffer(0)/100);<br />
Serial.print(node3.getResponseBuffer(1)/100);<br />
Serial.println(node3.getResponseBuffer(2)/100);<br />
}<br />
else {<br />
Serial.print("Error ID3\n");<br />
}<br />
}</p>
<p dir="auto">void Check4(){<br />
// Read 21 register starting at 0<br />
result4 = node4.readInputRegisters(0,21);</p>
<p dir="auto">Serial.println(result4, HEX);</p>
<p dir="auto">if (result4 == node4.ku8MBSuccess) {<br />
Serial.print("Id4 ");<br />
Serial.print(node4.getResponseBuffer(0)/100);<br />
Serial.print(node4.getResponseBuffer(1)/100);<br />
Serial.println(node4.getResponseBuffer(2)/100);<br />
}<br />
else {<br />
Serial.print("Error ID4\n");<br />
}<br />
}</p>
]]></description><link>https://community.m5stack.com/topic/4555/core2-with-w5500-and-rs485-modbusmaster-with-more-then-2-slaves</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 14:47:32 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/4555.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Aug 2022 10:19:28 GMT</pubDate><ttl>60</ttl></channel></rss>