Program hangs reading analog input from water level sensor

I have a 4 channel 4-20mA receiver (PR33-15) with I2C interface to Arduino Uno.
The inputs to the receiver are several water level sensors from MoreSunsDIY (Biosensor P22-10MI), all the same sensors

.

The wiring of the sensors with the receiver is corresponding the wiring diagram of 4-Channel I2C 4-20mA Current Receiver with I2C Interface:

I have downloaded the Arduino code from the ADS1115 Arduino lib at: https://github.com/ControlEverythingCommunity/CE_ARDUINO_LIB/tree/master/ADS1115

The Arduino code is normally executed until Wire.beginTransmission(address) and hangs at Wire.endTransmission()

This happens with every sensor, so I assume something in my code is the cause. The sensors are new, several tests with different water depths cause the same hanger.

Thank you in advance for your help or suggestions, what might cause the code to hang.
Any idea to read the analog value of the sensors differently ?

Best regards,
Wilfried

Hi Will,
This board has a MCP3428 and you are using ADS1115 code.
You will need to use this code

Thanks

Hi Bhaskar,
Thank you for your comment.
Is there any demo code for the MCP3428?
I’m getting locked in additional errors when replacing the library. Seem to be the parameters of the MCP3428 class.
Wilfried

the above lib is for mcp3428.
download the entire folder and copy/paste the .cpp and .h file in your arduino lib folder.
In the folder you will find a .ino file, open this file and upload it in the arduino.
On the serial monioter you should be able to see the 4-20mA values.

Thanks

Hi Bhaskar,

the mcp3428 lib folder contains 2 .ino-files: the …OneShot_Conversion.ino and the …MultiChannel.ino. I tried both and was in both cases blocked just as before at the same point: the code is executed until Wire.endTransmission().

This is the code for OneShot_Conversion, no error messages, MCP.devAddr = 104:

#include <MCP3428.h>
#include <Wire.h>

MCP3428 MCP(0); // Declaration of MCP3428: A2, A1, A0 bits (000, 0x68)

void setup()
{   Serial.begin(9600);
    delay(500);  }

void loop()
{   byte error;
    int8_t address;

    address = MCP.devAddr;
    Wire.beginTransmission(address);

    Serial.print("Wire.beginTransmission(address) executed, address: ");
    Serial.println(address);
    
    error = Wire.endTransmission();

    Serial.println("Wire.endTransmission(address) executed");
    
    if (error == 0)
    {
        long Raw_ADC;
        MCP.SetConfiguration(1,14,0,1);

        Raw_ADC = MCP.readADC();
        Serial.print("Digital value of Analog Input at Channel 1: ");
        Serial.println(Raw_ADC);
        Serial.println(" ");
        Serial.println("        ***************************        ");
        Serial.println(" ");
    }
    else
    {
        Serial.println("MCP3428 Disconnected!");
        Serial.println(" ");
        Serial.println("        ************        ");
        Serial.println(" ");
    }

    delay(1000);
}

Any idea to have a response from the PR33-15 and to read the ADC ?
Thank you very much.
Wilfried

Hi Bashkar,
I’m a bit confused if the jumpers on the board are set correctly for this device address.

Any changes needed ?
Thank you

Wilfried

You will need to remove both Address jumpers and retry the code.

Thanks

Hi Baskar,

As you proposed, I installed the mcp3428 folder in the arduino lib folder and uploaded the .ino file in the arduino. I tried all possible jumper positions, corresponding the wiring diagram of the PR33-15. There was always the same result, the execution of the code hangs always at : Wire.endTransmission()

One time I could observe, that at one jumper position 2 or 3 times the execution continued and Wire.endTransmission() delivered the code: 2, so I could read this error code. But this never recurred in the same jumper position.

That makes me believe, that there is possibly a hardware flaw at the PR33-15 board ( the board is a new one ).

If this is not a hardware flaw, do you see other possibilities, maybe to access the board with instructions of another lib than wire ? My familiarity with arduino software is very limited.

Thank you.
Wilfried

run this code as it is. this will scan the i2c port and will show the connected device i2c address


let me know what it comes up with.

Thanks

Hi Bhaskar,
execution of the I2C-scan hangs with the wire.endTransmission (i).
I have added 2 program lines to print each for-loop after each Wire.beginTransmission (i) , see hardcopy. Execution hangs after Wire.beginTransmission (1).

Thank you.
Wilfried

can you post a picture of your setup?
Thanks

Hi Baskhar,
this is setup with water level sensor outside water tank.

Wilfried

i2c cable is connected in the wrong port. it should connect to the i2c input port.

Thanks

Hi Baskhar,

I have been thinking lots of times, which port should be the right one to connect to the USB-shield and I was absolutely sure, that this has to be the out-port. As a misunderstanding this is now the best solution.

Thank you very much for the prompt assistance.

Wilfried