robert-hh / ads1x15

Micropython driver for ADS1115 and ADS1015
90 stars 25 forks source link

Would it work for 4-20 mA Current Loop Receiver module? #4

Closed johncaipa closed 5 years ago

johncaipa commented 5 years ago

Hi Robert, I'm trying to use this library for the 2-Channel 4-20 mA Current Loop Receiver 16-Bit ADS1115 I2C Mini Module with a Lopy, but I do not know if it's works. can you give some guidance to use it. This is the module: https://store.ncd.io/product/2-channel-4-20-ma-current-loop-receiver-16-bit-ads1115-i2c-mini-module/

robert-hh commented 5 years ago

That should work. The only thing to consider is the pull-up. On the board it is connected to 5V. The LoPy has 3.3V levels. Using the on-board pull-ups should not be a problem, but it seems better to leave the jumpers open and use separate pull-up resistors (~4.7kOhm) connected to 3.3V.

johncaipa commented 5 years ago

Thanks, i am using the Screw Terminal Breakout Board for WiPy2 & LoPy image

with jumpers or without them I can not find the module doing scan from the Lopy. and with your library and example code an error is generated:

>>> Running e:\Pycom\projects\ReadI2C4-20mA\main.py

>>>
>>╝Traceback (most recent call last):
  File "<stdin>", line 13, in <module>
ValueError: invalid argument(s) value
╝>
Pycom MicroPython 1.18.1.r1 [v1.8.6-849-b0520f1] on 2018-08-29; LoPy with ESP32
Type "help()" for more information.
>>>

making a change in line 12 (i2c = I2C(0, I2C.MASTER, baudrate=100000)), this error is solved, but others are generated after:

>>> Running e:\Pycom\projects\ReadI2C4-20mA\main.py

>>>
>>>
╝Traceback (most recent call last):
  File "<stdin>", line 39, in <module>
  File "/flash/lib/ads1x15.py", line 176, in read_rev
  File "/flash/lib/ads1x15.py", line 146, in _read_register
OSError: I2C bus error
╝>
Pycom MicroPython 1.18.1.r1 [v1.8.6-849-b0520f1] on 2018-08-29; LoPy with ESP32
Type "help()" for more information.
>>>

Any suggestions? Thanks in advance

robert-hh commented 5 years ago

Yes, the example code was for ESP8266 and the micropython.org port. Can check,

I'll try here with a LoPy. At least, scan returns 72, which is the I2C address,

robert-hh commented 5 years ago

I had established I2C with

from machine import I2C
from ads1x15 import ADS1115
i2c=I2C()  # default bus at P9 and P10
ads= ADS1115(I2c)
ads.read(0, 0)

The results on channel 0 are fine. It only puzzles me that I cannot get the other channels to work.

johncaipa commented 5 years ago

Apparently the 4 pin I2C port is connected to the default I2C pins of the lopy in the Breakout Board, it must be that my 4-20mA module is defective since the lopy does not find it doing the i2c scan, and it is no longer turning on the power led. :(

robert-hh commented 5 years ago

Does it get power?

robert-hh commented 5 years ago

OK. I tried another ADS1115 from a different supplier, and that one works on all channels. Looks like the first is either defective of a fake one.

johncaipa commented 5 years ago

yeah, the module started to heat up and now it does not turn on the power led for no apparent reason, it must be faulty :( Which option do you recommend to read a 4-20mA current loop sensor from a Lopy, that from ncd did not work for me.

robert-hh commented 5 years ago

What voltage levels resp. to GND does the loop work at, and does it requires isolation?

robert-hh commented 5 years ago

Unless you swap Vcc and GND, it is pretty unlikely to break such a board.

robert-hh commented 5 years ago

I'll close that now. If required, I can reopen it again. The problem with the other channels on one board was my fault: I did not solder all board connector's pin.