<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.netio-products.com/index.php?action=history&amp;feed=atom&amp;title=Function_modbusWriteSingleCoil%28%29</id>
	<title>Function modbusWriteSingleCoil() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.netio-products.com/index.php?action=history&amp;feed=atom&amp;title=Function_modbusWriteSingleCoil%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_modbusWriteSingleCoil()&amp;action=history"/>
	<updated>2026-04-21T16:20:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_modbusWriteSingleCoil()&amp;diff=400&amp;oldid=prev</id>
		<title>Phrych: Created page with &quot;{{DISPLAYTITLE:function modbusWriteSingleCoil()}} Write value to single coil using modbus protocol. The call is asynchronous: the code execution proceeds immediately and when...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_modbusWriteSingleCoil()&amp;diff=400&amp;oldid=prev"/>
		<updated>2019-06-20T13:07:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{DISPLAYTITLE:function modbusWriteSingleCoil()}} Write value to single coil using modbus protocol. The call is asynchronous: the code execution proceeds immediately and when...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:function modbusWriteSingleCoil()}}&lt;br /&gt;
Write value to single coil using modbus protocol. The call is asynchronous: the code execution proceeds immediately and when the response arrives, callback function is called.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;modbusWriteSingleCoil&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; config{&amp;lt;code&amp;gt;deviceAddress&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;port&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;timeout&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;deviceAddress&amp;lt;/code&amp;gt; IP address of device&lt;br /&gt;
* &amp;lt;i&amp;gt;function{response}&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt; this function is called when response arrives&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; number of the coil&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; the value to be written&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;port&amp;lt;/code&amp;gt; numer of port (default 502)&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;timeout&amp;lt;/code&amp;gt; maximum seconds to wait for response (default 30)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Callback Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; response{&amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;errInfo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt; error code of the response (0 is success)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;errInfo&amp;lt;/code&amp;gt; error description (if result&amp;gt;0)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; number of the input register&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- Turn on all outputs on NETIO with IP 10.0.0.105 and port 505&lt;br /&gt;
 local function modbusWriteCallback(data)&lt;br /&gt;
   log(string.format(&amp;quot;addr %d, result %d&amp;quot;, data.address, data.result))&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 for i = 101,104 do&lt;br /&gt;
   modbusWriteSingleCoil{deviceAddress='10.0.0.105', port=505, timeout=6, address=true, value=4, callback=modbusWriteCallback}&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
Netio FirmWare 3.3.0+&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Phrych</name></author>
		
	</entry>
</feed>