Hi Bhaskar,
I Just received my order of 3 x 12 port 4-20mA Boards (PR33-28) with Onion Omega 2+ and I2C + Ethernet board for onion omega. Looking for examples I only found the python script.
Being more of an infrastructure kind of guy I was hoping to use i2cget and i2cset in a bash script to do the work for me. Have you managed to get that working reliably?
Anyway in the interest of science i decided to give the python script a go.
I have set the jumper addresses on the board to 0x6A, 0x6B and 0x6C respectively.
I have taken your python code example from github changed the address and extended the sleep time as I read somewhere that can have an impact on reliable readings.
I’m just testing with one port (as I only 1 4-20 signal generator) Here’s the Code:
# Distributed with a free-will license.
# Use it any way you want, profit or free, provided it fits in the licenses of its associated works
# MCP3428
# This code is designed to work with the MCP3428 4-20mA current receiver board available from Contr
# https://shop.controleverything.com/collections/4-20-ma-current-loop-input/products/4-20ma-current
# https://shop.controleverything.com/collections/4-20-ma-current-loop-input/products/4-channel-4-20
from OmegaExpansion import onionI2C
import time
DL = 0.01
DL1 = 1.01
# Get I2C bus
i2c = onionI2C.OnionI2C()
# MCP3428 address, 0x6A(104)
# Send configuration command
while True:
#0x10(16)Continuous conversion mode, Channel-1, 12-bit Resolution
data = [0x11]
i2c.write(0x6A, data)
time.sleep(DL1)
# MCP3428 address, 0x68(104)
# Read data back from 0x00(0), 2 bytes
# raw_adc MSB, raw_adc LSB
data = i2c.readBytes(0x6A, 0x00, 2)
# Convert the data to 12-bits
raw_adc = (data[0] & 0x0F) * 256 + data[1]
if raw_adc > 2047 :
raw_adc -= 4095
current = (raw_adc * 0.01109)
# Output data to screen
print "Current Input at Channel One is : %.3f" %current
time.sleep(DL)
I notice that the readings from the board are all over the place.
Here’s the Output:
root@Omega-E70F:~/Onion-Omega-2-4-20mA-Current-Receiver# python sams_4-20mA_G2.py
Current Input at Channel One is : 3.815
Current Input at Channel One is : 2.983
Current Input at Channel One is : 3.039
Current Input at Channel One is : 3.105
Current Input at Channel One is : 3.815
Current Input at Channel One is : 3.638
Current Input at Channel One is : 3.704
Current Input at Channel One is : 2.861
Current Input at Channel One is : 3.094
Current Input at Channel One is : 3.815
Current Input at Channel One is : 3.693
Current Input at Channel One is : 3.571
Current Input at Channel One is : 2.883
Current Input at Channel One is : 3.094
Current Input at Channel One is : 3.116
Current Input at Channel One is : 3.815
Current Input at Channel One is : 3.671
Current Input at Channel One is : 3.748
Current Input at Channel One is : 2.861
Current Input at Channel One is : 3.094
Current Input at Channel One is : 3.316
Current Input at Channel One is : 3.815
Current Input at Channel One is : 2.906
Current Input at Channel One is : 3.016
Current Input at Channel One is : 3.771
Current Input at Channel One is : 3.649
Current Input at Channel One is : 3.449
Current Input at Channel One is : 2.894
Current Input at Channel One is : 3.016
Current Input at Channel One is : 3.771
Current Input at Channel One is : 3.649
Current Input at Channel One is : 3.405
Current Input at Channel One is : 3.760
Current Input at Channel One is : 3.682
Current Input at Channel One is : 3.726
Current Input at Channel One is : 2.906
Current Input at Channel One is : 3.094
Current Input at Channel One is : 3.161
Current Input at Channel One is : 3.793
The current generator is sending a 4.00mA signal
Any Ideas as to why it might be so wonky ? I was reading a thread on the onion omega forum about the omega2+ having issues with I2C implementation http://community.onion.io/topic/2312/i2c-detect-slave-method not sure if this has anything to do with it.