<?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[Topics tagged with software i2c]]></title><description><![CDATA[A list of topics that have been tagged with software i2c]]></description><link>http://community.onion.io/tags/software i2c</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 19:59:49 GMT</lastBuildDate><atom:link href="http://community.onion.io/tags/software i2c.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Nov 2020 17:53:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[FAQ: How can I make a software-based (bit-bang) I2C bus&#x2F;Can I use any 2 GPIOs as an I2C bus?]]></title><description><![CDATA[<h2>Software-based (bit-bang) I2C bus on the GPIOs is doable!</h2>
<p dir="auto">Check out the OpenWRT documentation on this topic: <a href="https://openwrt.org/docs/techref/hardware/port.i2c#i2c_over_gpio" rel="nofollow">https://openwrt.org/docs/techref/hardware/port.i2c#i2c_over_gpio</a></p>
<h4>Setting up a Software I2C Bus</h4>
<p dir="auto">Install the required kernel modules</p>
<pre><code>opkg update
opkg install kmod-i2c-gpio-custom
</code></pre>
<p dir="auto">Setup a bus:</p>
<pre><code>insmod i2c-gpio-custom bus&lt;BUS NUMBER&gt;=&lt;BUS NUMBER&gt;,&lt;SDA GPIO&gt;,&lt;SCL GPIO&gt;
</code></pre>
<h4>Example</h4>
<p dir="auto">For example, to setup a SW I2C bus with SDA on GPIO18 and SCL on GPIO19:</p>
<pre><code>insmod i2c-gpio-custom bus1=1,18,19
</code></pre>
<p dir="auto">If all goes well, there will be a message in the kernel log:</p>
<pre><code>[  308.931002] Custom GPIO-based I2C driver version 0.1.1
[  308.936785] i2c-gpio i2c-gpio.1: using pins 18 (SDA) and 19 (SCL)
</code></pre>
<p dir="auto">And there will be a new I2C bus 1 device available:</p>
<pre><code>root@Omega-F195:/# ls /dev/i2c-*
/dev/i2c-0  /dev/i2c-1
</code></pre>
<h4>Notes:</h4>
<ul>
<li>Check out the <a href="https://docs.onion.io/omega2-docs/using-gpios.html" rel="nofollow">Omega2 pinout and GPIOs article in the documentation</a> to select your GPIOs</li>
<li>The Omega's hardware I2C bus is occupying the <code>bus0</code> label, so your new sw i2c bus will need to be <code>bus1</code></li>
<li>Keep in mind this is bit banging so the timing is not exact. However since I2C is synchronous it should not be a problem.</li>
<li>If you're using Onion's Omega2 firmware, you'll need to be on the <code>latest</code> available firmware to install the required kernel modules. See <a href="http://docs.onion.io/omega2-docs/using-opkg.html#onion-package-repo" rel="nofollow">our documentation</a> for more details.</li>
</ul>
<h2>Changing the SW I2C Bus Speed</h2>
<p dir="auto">If you are using SW I2C over GPIO, then when you insert the kernel module you can specify a delay value</p>
<p dir="auto">For example:</p>
<pre><code>insmod i2c-gpio-custom bus1=1,5,4,udelay
</code></pre>
<p dir="auto">where I2C speed (kHz) = 500 / udelay<br />
udelay can only be an <strong>integer</strong></p>
<p dir="auto">Keep in mind this is bit banging so the timing is not exact however since I2C is synchronous it should not be a problem.</p>
]]></description><link>http://community.onion.io/topic/4333/faq-how-can-i-make-a-software-based-bit-bang-i2c-bus-can-i-use-any-2-gpios-as-an-i2c-bus</link><guid isPermaLink="true">http://community.onion.io/topic/4333/faq-how-can-i-make-a-software-based-bit-bang-i2c-bus-can-i-use-any-2-gpios-as-an-i2c-bus</guid><dc:creator><![CDATA[Lazar Demin]]></dc:creator><pubDate>Wed, 18 Nov 2020 17:53:39 GMT</pubDate></item></channel></rss>