<?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[Need help communicating with a &quot;primitive&quot; I2C device]]></title><description><![CDATA[<p dir="auto">I have a Onion Omega2+ plugged into a CE PR32-3 (adapter), thence into a MCP23008 / PEIO4R4G5LE (4-relay "shield" with I2C interface).</p>
<p dir="auto">Using a simple Python script, I was controlling the relays quickly.  So far, so good.</p>
<p dir="auto">I plugged a SI7020-A20 (temperature / humidity sensor) into the I2C bus.  The LED lights up.</p>
<p dir="auto">This device has no addressable registers, so has a different programming interface than what the onionI2C Python library provides.  There is i2c.readBytes(), but no i2c.read().  I suspect this is the root of my problem, but I tried this Python script:</p>
<p dir="auto">#!/usr/bin/env python<br />
from OmegaExpansion import onionI2C<br />
import time</p>
<p dir="auto">i2c = onionI2C.OnionI2C()</p>
<p dir="auto">i2c.write(0x40, [0xF5])   # 0x40 is the I2C address, 0xF5 is the command to start a conversion<br />
time.sleep(0.5)</p>
<p dir="auto">data = i2c .readBytes(0x40, 0x00, 2) # This device has no addressable registers, so this readBytes() call is suspect, but there is no i2c .read()</p>
<p dir="auto">print "%x" %data[0]<br />
print "%x" %data[1]</p>
<hr />
<p dir="auto">I get:</p>
<p dir="auto">0</p>
<p dir="auto">3f</p>
<p dir="auto">Specced conversion gives RH of -5.88%.  I've never heard of negative humidity!</p>
<p dir="auto">I'm sure it's something really silly, but I have fiddled around a lot with the write(), writeBytes(), and readBytes() calls and not gotten anywhere.</p>
<p dir="auto">It could be that I need to abandon Python and try to use more primitive functions that might be available in the C libraries, but I was sorta trying to avoid that.  I haven't gotten anywhere with the cloud C compiler at all!  All I get is an inert Web page that doesn't do anything.</p>
]]></description><link>http://community.onion.io/topic/1614/need-help-communicating-with-a-primitive-i2c-device</link><generator>RSS for Node</generator><lastBuildDate>Thu, 21 May 2026 02:15:35 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/1614.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Feb 2017 06:30:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Tue, 07 Feb 2017 06:30:34 GMT]]></title><description><![CDATA[<p dir="auto">I have a Onion Omega2+ plugged into a CE PR32-3 (adapter), thence into a MCP23008 / PEIO4R4G5LE (4-relay "shield" with I2C interface).</p>
<p dir="auto">Using a simple Python script, I was controlling the relays quickly.  So far, so good.</p>
<p dir="auto">I plugged a SI7020-A20 (temperature / humidity sensor) into the I2C bus.  The LED lights up.</p>
<p dir="auto">This device has no addressable registers, so has a different programming interface than what the onionI2C Python library provides.  There is i2c.readBytes(), but no i2c.read().  I suspect this is the root of my problem, but I tried this Python script:</p>
<p dir="auto">#!/usr/bin/env python<br />
from OmegaExpansion import onionI2C<br />
import time</p>
<p dir="auto">i2c = onionI2C.OnionI2C()</p>
<p dir="auto">i2c.write(0x40, [0xF5])   # 0x40 is the I2C address, 0xF5 is the command to start a conversion<br />
time.sleep(0.5)</p>
<p dir="auto">data = i2c .readBytes(0x40, 0x00, 2) # This device has no addressable registers, so this readBytes() call is suspect, but there is no i2c .read()</p>
<p dir="auto">print "%x" %data[0]<br />
print "%x" %data[1]</p>
<hr />
<p dir="auto">I get:</p>
<p dir="auto">0</p>
<p dir="auto">3f</p>
<p dir="auto">Specced conversion gives RH of -5.88%.  I've never heard of negative humidity!</p>
<p dir="auto">I'm sure it's something really silly, but I have fiddled around a lot with the write(), writeBytes(), and readBytes() calls and not gotten anywhere.</p>
<p dir="auto">It could be that I need to abandon Python and try to use more primitive functions that might be available in the C libraries, but I was sorta trying to avoid that.  I haven't gotten anywhere with the cloud C compiler at all!  All I get is an inert Web page that doesn't do anything.</p>
]]></description><link>http://community.onion.io/post/10612</link><guid isPermaLink="true">http://community.onion.io/post/10612</guid><dc:creator><![CDATA[Art Milburn]]></dc:creator><pubDate>Tue, 07 Feb 2017 06:30:34 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Tue, 07 Feb 2017 15:58:45 GMT]]></title><description><![CDATA[<p dir="auto">Indeed, I2C devices that do not have internal registers do break a number of I2C wrapper APIs.</p>
<p dir="auto">It looks like the Linux i2c-dev interface should itself be able to do the kinds of raw byte access you want</p>
<p dir="auto"><a href="https://www.kernel.org/doc/Documentation/i2c/dev-interface" rel="nofollow">https://www.kernel.org/doc/Documentation/i2c/dev-interface</a></p>
<p dir="auto">That is mostly simple file operations, but you will need to use an ioctl() call to set the target chip's address.</p>
<ul>
<li>
<p dir="auto">You get a working cross compiler as a result of a build of the system from source</p>
</li>
<li>
<p dir="auto">There appear to be ways to perform an ioctl() from python, for example there's an "fcntl" module that has this capability, you could see if that or something similar is available.</p>
</li>
</ul>
<p dir="auto"><strong>Update:</strong> looks like all the pieces you need are available <s>in python</s> <strong>C</strong> code in the onion i2c library, you just need to refactor them somewhat.</p>
<p dir="auto"><a href="https://github.com/OnionIoT/i2c-exp-driver/blob/master/src/lib/onion-i2c.c#L84" rel="nofollow">_i2c_writeBuffer</a> appears to  operate without the assumption that the first byte sent is an internal register address, it is then used by higher level functions that do enforce that assumption that is problematic for your case.</p>
<p dir="auto">I'm not immediately seeing a corresponding raw buffer read, but you should be able to make one from the piece there, perhaps just by making a copy that doesn't do a write to send a register address, but instead goes right to the read.</p>
<p dir="auto">Needless to say i2c debugging is a lot easier with the aid of a storage scope or a simple USB-based logic analyzer - you can figure it all out from what <em>should</em> be happening but it goes a lot faster when you can see what <em>is</em> happening.</p>
<p dir="auto"><strong>2nd Update:</strong> realizing the above is C code, not python that you could use without the cross compiler.  But that C code includes the ability to do the necessary ioctl() call, so perhaps you can use the built library to open the i2c device "file", perform the ioctl() call to set the peripheral address, but then do the actual byte writing/reading using file operations on that file descriptor directly from python.</p>
]]></description><link>http://community.onion.io/post/10651</link><guid isPermaLink="true">http://community.onion.io/post/10651</guid><dc:creator><![CDATA[Chris Stratton]]></dc:creator><pubDate>Tue, 07 Feb 2017 15:58:45 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Wed, 08 Feb 2017 05:52:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/2602">@Chris-Stratton</a> I previously wrote a suite of libraries and programs for the Omega1 (see <a href="https://github.com/KitBishop/Omega-GPIO-I2C-Arduino" rel="nofollow">https://github.com/KitBishop/Omega-GPIO-I2C-Arduino</a>) and amongst this is some code for I2C that includes <em><code>raw</code></em> access (i.e. without specifying a register) because I had some devices that required this.</p>
<p dir="auto">Unfortunately, my code is currently only for the Omega1, it will not work as is for the Omega2.  I need to make some changes for the Omega2 - I intend to do this but can't at the moment say when I will have time to do so (paid work getting in the way <img src="http://community.onion.io/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=ic093v0mjao" class="not-responsive emoji emoji-android emoji--disappointed" title=":-(" alt="😞" /> )</p>
]]></description><link>http://community.onion.io/post/10719</link><guid isPermaLink="true">http://community.onion.io/post/10719</guid><dc:creator><![CDATA[Kit Bishop]]></dc:creator><pubDate>Wed, 08 Feb 2017 05:52:42 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Wed, 08 Feb 2017 06:08:39 GMT]]></title><description><![CDATA[<p dir="auto">I have compiled libsoc and its python2- and python3-bindings ( <a href="https://github.com/jackmitch/libsoc" rel="nofollow">https://github.com/jackmitch/libsoc</a> ) for the Omega2. libsoc allows you to read or write without specifying the register, so go nuts with it, if you please. A python-example is available at <a href="https://github.com/jackmitch/libsoc/blob/master/test/i2c_test.py" rel="nofollow">https://github.com/jackmitch/libsoc/blob/master/test/i2c_test.py</a></p>
<p dir="auto">libsoc itself: <a href="https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/libsoc_0.8.2-230117-1_mipsel_24kc.ipk" rel="nofollow">https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/libsoc_0.8.2-230117-1_mipsel_24kc.ipk</a><br />
python2-bindings: <a href="https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/python-libsoc_0.8.2-230117-1_mipsel_24kc.ipk" rel="nofollow">https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/python-libsoc_0.8.2-230117-1_mipsel_24kc.ipk</a><br />
python3-bindings: <a href="https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/python3-libsoc_0.8.2-230117-1_mipsel_24kc.ipk" rel="nofollow">https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/python3-libsoc_0.8.2-230117-1_mipsel_24kc.ipk</a></p>
<p dir="auto">EDIT: Thought to add the LEDE-package Makefile for libsoc that I made: <a href="https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/lede-libsoc-Makefile" rel="nofollow">https://dl.dropboxusercontent.com/u/11811685/omega2-stuff/lede-libsoc-Makefile</a> -- this is only useful for those who wish to build their own LEDE-packages, so everyone else can just ignore this.</p>
]]></description><link>http://community.onion.io/post/10722</link><guid isPermaLink="true">http://community.onion.io/post/10722</guid><dc:creator><![CDATA[WereCatf]]></dc:creator><pubDate>Wed, 08 Feb 2017 06:08:39 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Tue, 21 Feb 2017 00:20:34 GMT]]></title><description><![CDATA[<p dir="auto">Finally getting a chance to look at this again.</p>
<p dir="auto">I want to thank everyone for their thoughtful responses.</p>
<p dir="auto">I'm afraid I have a IoT noob question.  How do I go about installing an .ipk file?  I'd like to have a go with WereCatf's libsoc.  Seems like the path of least resistance.</p>
<p dir="auto">Thanks!</p>
<p dir="auto">Art</p>
]]></description><link>http://community.onion.io/post/11298</link><guid isPermaLink="true">http://community.onion.io/post/11298</guid><dc:creator><![CDATA[Art Milburn]]></dc:creator><pubDate>Tue, 21 Feb 2017 00:20:34 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Tue, 21 Feb 2017 00:50:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/2148">@Art-Milburn</a> said in <a href="/topic/1614/need-help-communicating-with-a-primitive-i2c-device/5">Need help communicating with a "primitive" I2C device</a>:</p>
<blockquote>
<p dir="auto">How do I go about installing an .ipk file?</p>
</blockquote>
<p dir="auto">Download the file, then <code>opkg install package.ipk</code></p>
<p dir="auto">Do note that I haven't tested these on the official firmware, so I don't 100% guarantee they work. But they <em>should</em> work just fine.</p>
]]></description><link>http://community.onion.io/post/11300</link><guid isPermaLink="true">http://community.onion.io/post/11300</guid><dc:creator><![CDATA[WereCatf]]></dc:creator><pubDate>Tue, 21 Feb 2017 00:50:52 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Tue, 21 Feb 2017 06:20:13 GMT]]></title><description><![CDATA[<p dir="auto">Wow, I must be a total doof.  I tried to use opkg to attempt to install python-libsoc_xxxxxxxxxx and I just got an error:</p>
<p dir="auto">Installing python-libsoc (0.8.2-230117-1) to root...<br />
Collected errors:</p>
<ul>
<li>satisfy_dependencies_for: Cannot satisfy the following dependencies for python-libsoc:</li>
<li>
<pre><code> pkg-config *    libsoc *
</code></pre>
</li>
<li>opkg_install_cmd: Cannot install package python-libsoc.</li>
</ul>
<p dir="auto">Ouch....</p>
]]></description><link>http://community.onion.io/post/11309</link><guid isPermaLink="true">http://community.onion.io/post/11309</guid><dc:creator><![CDATA[Art Milburn]]></dc:creator><pubDate>Tue, 21 Feb 2017 06:20:13 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Tue, 21 Feb 2017 07:55:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/2148">@Art-Milburn</a> Did you download and install libsoc? Also, install pkg-config from repos.</p>
]]></description><link>http://community.onion.io/post/11310</link><guid isPermaLink="true">http://community.onion.io/post/11310</guid><dc:creator><![CDATA[WereCatf]]></dc:creator><pubDate>Tue, 21 Feb 2017 07:55:57 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Sat, 25 Feb 2017 04:59:28 GMT]]></title><description><![CDATA[<p dir="auto">I can't figure out where to get pkg-config</p>
]]></description><link>http://community.onion.io/post/11500</link><guid isPermaLink="true">http://community.onion.io/post/11500</guid><dc:creator><![CDATA[Carl Allen]]></dc:creator><pubDate>Sat, 25 Feb 2017 04:59:28 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Sat, 25 Feb 2017 05:33:14 GMT]]></title><description><![CDATA[<p dir="auto">oh found it:<br />
<a href="http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/packages/pkg-config_0.29.1-1_mipsel_24kc.ipk" rel="nofollow">http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/packages/pkg-config_0.29.1-1_mipsel_24kc.ipk</a></p>
]]></description><link>http://community.onion.io/post/11501</link><guid isPermaLink="true">http://community.onion.io/post/11501</guid><dc:creator><![CDATA[Carl Allen]]></dc:creator><pubDate>Sat, 25 Feb 2017 05:33:14 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Sat, 25 Feb 2017 05:48:40 GMT]]></title><description><![CDATA[<p dir="auto">I got it all installed but I get a segmentation fault when I try to import I2C</p>
]]></description><link>http://community.onion.io/post/11502</link><guid isPermaLink="true">http://community.onion.io/post/11502</guid><dc:creator><![CDATA[Carl Allen]]></dc:creator><pubDate>Sat, 25 Feb 2017 05:48:40 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Mon, 06 Mar 2017 21:46:49 GMT]]></title><description><![CDATA[<p dir="auto">Ugh I was just trying to get this to work myself. What is annoying is there IS a write function that allows a no address write, but no corresponding read! Not sure why this was part of the kickstarter if its not easy to control, at least via python.</p>
]]></description><link>http://community.onion.io/post/11843</link><guid isPermaLink="true">http://community.onion.io/post/11843</guid><dc:creator><![CDATA[Matthew Butch]]></dc:creator><pubDate>Mon, 06 Mar 2017 21:46:49 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Sun, 12 Mar 2017 09:37:43 GMT]]></title><description><![CDATA[<p dir="auto">Has anyone found any reasonably straightforward solution here?  I appreciate all the suggestions from folks, but am very surprised by the lack of corresponding function to the arduino Wire library for OMega2 + Python for I2C.  I'm trying to get a board running that is working on Arduino utilizing the Wire API to get data from the device using Wire.requestFrom(), Wire.available(), and Wire.read().  Is the most straightforward solution to add parameter compatible calls to OmegaExpansion.onionI2c?  I might be able to assist in any efforts if this seems like a path Onion would like to take that would be useful to others.  Btw, I do love my Omega2.  I think it just needs a little more library love!</p>
<p dir="auto">Thanks.<br />
-Casten</p>
<p dir="auto">Original Arduino Source:  <a href="https://github.com/SparkysWidgets/MinipHBFW/blob/master/MinipH.ino" rel="nofollow">https://github.com/SparkysWidgets/MinipHBFW/blob/master/MinipH.ino</a><br />
Python Version:  <a href="https://github.com/SparkysWidgets/MinipHBFW/blob/master/RaspberryPi%20-%20Python3/pHReader.py" rel="nofollow">https://github.com/SparkysWidgets/MinipHBFW/blob/master/RaspberryPi - Python3/pHReader.py</a></p>
]]></description><link>http://community.onion.io/post/12019</link><guid isPermaLink="true">http://community.onion.io/post/12019</guid><dc:creator><![CDATA[Casten Riepling]]></dc:creator><pubDate>Sun, 12 Mar 2017 09:37:43 GMT</pubDate></item><item><title><![CDATA[Reply to Need help communicating with a &quot;primitive&quot; I2C device on Tue, 04 Jul 2017 10:04:04 GMT]]></title><description><![CDATA[<p dir="auto">Maybe posting here will make them merge the PR: <a href="https://github.com/OnionIoT/i2c-exp-driver/pull/15" rel="nofollow">https://github.com/OnionIoT/i2c-exp-driver/pull/15</a></p>
<p dir="auto">Compiled packages are available on <a href="https://www.dropbox.com/sh/p7mki5nbgyu1tcv/AABPC1HzA848MbEA9RpNiNNva?dl=0" rel="nofollow">https://www.dropbox.com/sh/p7mki5nbgyu1tcv/AABPC1HzA848MbEA9RpNiNNva?dl=0</a></p>
<p dir="auto">One can install them with opkg install libonioni2c_0.4-2_mipsel_24kc.ipk pyOnionI2C_0.4-2_mipsel_24kc.ipk pyOmegaExpansion_0.4-2_mipsel_24kc.ipk liboniondebug_0.4-2_mipsel_24kc.ipk</p>
<p dir="auto">Example using modified python library: <a href="https://gist.github.com/foxel/a163231293d7cf6f24831b363a91dfe5" rel="nofollow">https://gist.github.com/foxel/a163231293d7cf6f24831b363a91dfe5</a></p>
]]></description><link>http://community.onion.io/post/13649</link><guid isPermaLink="true">http://community.onion.io/post/13649</guid><dc:creator><![CDATA[Andrei Kupreichik]]></dc:creator><pubDate>Tue, 04 Jul 2017 10:04:04 GMT</pubDate></item></channel></rss>