I2C module communication over I2C Hub?

Expansion modules and attachments
Post Reply
murjan
Posts: 4
Joined: Thu Feb 11, 2016 4:50 pm

I2C module communication over I2C Hub?

Post by murjan »

Hi,

First post here.
I have been playing with DO probe from Atlas Scientific and RA. It was not hard to get it to read when connecting it directly to the relay box, however I am almost out of ideas on how to get it working when connected to the hub, and what would possibly you have to change in the code or circuits to get it working behind the hub?

I created the required libraries similar to the implementation of ORP, Ph and using Wire.beginTransmission(DOI2C) where DOI2C is 97 (the DO circuit default address is 0x61 but it never worked when using hex address, any idea for this also?)

My understanding is that the I2C Hub is basically invisible and the implementation should not require any changes to work on a hub or directly on the main bus. Is my understanding right?

The DO circuit by Atlas has 2 modes of operation, UART and I2C, where you have to prompt it with a command and wait for the response and read it

Appreciate any help
Mur
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: I2C module communication over I2C Hub?

Post by jsclownfish »

Hello Mur,

I have this same unit on my RA. I had to do a number of things to make it work for me. First, like you've done I had to modify a library (phExp in my case) to report the ORP result. Second, I set it up on the I2C to send a request for a DO reading followed a few seconds later by a read request from the same unit. Lastly, the DO probe interferes with my PH probe and I had to make a module to isolate the signal using a ADUM1250 chip.

Mine works pretty well now, but it is more noisy than I would have expected. I also have a problem with it getting out of sync with the call/response cycle but I think this is part of a bigger issue I have with noise on my I2C lines. It may work better as a serial connection as it could be put in continuous read mode and you wouldn't need the call out to read a signal. I haven't had a chance to try that one.

Good luck and let me know how it goes!

Jon
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: I2C module communication over I2C Hub?

Post by jsclownfish »

I forgot to mention that the interference and I2C issues only happen with the hub for me. Like you've experienced it works more robustly connected to the relay directly.

-Jon
murjan
Posts: 4
Joined: Thu Feb 11, 2016 4:50 pm

Re: I2C module communication over I2C Hub?

Post by murjan »

Thanks Jon for your reply.

I have purchased the power isolator circuit from Atlas Scientific also and using it, I hope this will eliminate the interference.

How are you supplying power to the DO circuit? Can you post your code for the DO libraries you created so I can compare with mine? maybe we can collaborate to make a good library for other people to use.

Mur
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: I2C module communication over I2C Hub?

Post by jsclownfish »

I'll post the code soon (I'm not at my PC) but let me know how the power iso works. It worked fine for me when connected to the outlet box directly, but not with the hub. I tried 3 power isolator so and only the adum1250 chip has worked with the expansion hub.

Jon
murjan
Posts: 4
Joined: Thu Feb 11, 2016 4:50 pm

Re: I2C module communication over I2C Hub?

Post by murjan »

Power iso seems to work well, but I ended up putting an Arduino uno in between so I don't have to deal with call/response out of sync as it has affected many things in the program and I did not have the patience to fine tune it. so I am reading values in continuous UART mode to an Arduino and calling the Arduino from RA for the last recorded value!

this way most of the implementation would be almost a copy of how ph is being retrieved.
-Murjan
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: I2C module communication over I2C Hub?

Post by jsclownfish »

That's the direction I'm thinking as well. Unfortunately I don't think you can put the Atlas DO in continuous read when in the I2C format. I'd imagine it might stabilize the signal as well in continuous mode than to keep reinitializing a read every few seconds. Here is my altered PH extension file that reads the DO instead of the PH extension. It took some time to get the format correct to read on the portal and web chart correctly.

Code: Select all

/*
 * Copyright 2010 Reef Angel / Roberto Imai
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

 /*
  * Updated by:  Curt Binder
  * Updates Released under Apache License, Version 2.0
  */

#include "PH.h"
#include <Globals.h>
#include <Wire.h>


PHClass::PHClass()
{
}


int PHClass::Read()
{
      int iPH;
	static boolean DOevent=false;
	char DO_data[4];                //we make a 20 byte character array 
	byte DOcode=0;

	
if (DOevent==false && second()%5==0) 
  {
    DOevent=true;
    Wire.beginTransmission(97); //call the circuit by its ID number.  
    Wire.write("r");             //transmit the command 
    Wire.endTransmission();      //end the I2C data transmission.
}
 
else if (DOevent==true && (second()%5-2)==0)
  {
    DOevent=false;                        //reset the serial event flag.
    Wire.requestFrom(97,5,1); //call the circuit and request 20 bytes 
    
    DOcode=Wire.read();               //the first byte is the response code

      while(Wire.available())
      { 
          for (int a=0;a<4;a++)
      DO_data[a]=Wire.read();
      }
      DO_data[4]= '\0';
      
char StrDO[5] = {DO_data[0],DO_data[2],DO_data[3],DO_data[4]};
iPH =atoi(StrDO);
}


return iPH;
}
Do you have the pwr-iso connected to the expansion hub? When I tried that it stopped the interference with the pH read, but I couldn't communicate through I2C. Maybe the serial read into the uno solves this problem as well?
murjan
Posts: 4
Joined: Thu Feb 11, 2016 4:50 pm

Re: I2C module communication over I2C Hub?

Post by murjan »

I was able to use the power iso in i2c directly connected to the relay box and also using the hub. only issue was call/response out of sync.

the difference between running with or without a hub is the matter of supplying the DO circuit power from an external source vs taking the power from RA. Behind the hub I had to give it power from an external power source and it worked fine, also with the power iso, it doesn't make any difference to your implementation.

On Arduino I made it read from the DO circuit using UART continuous mode, so Arduino is always reading and storing the reading in a variable, which then is being accessed via i2c from RA (connected the Arduino to the RA Hub).

Thanks for the code. this is pretty similar to what I did initially then I started putting flags to force it to skip the process if the last call was not yet satisfied. but got pretty messed up. I think someone else than me would have done it though.
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: I2C module communication over I2C Hub?

Post by jsclownfish »

:) Yeah, I learned everything about Arduino from the folks here. Especially Roberto who has been a great help for these little projects. Sounds like we had similar issues with communication over I2C and the hub. The ADUM1250 chip separates the I2C from the DO powered with a secondary 5V source. I actually made a little intermediate module that isolates anything you plug into it. As you said the isolation works to solve the pH interference, but the pwr-iso didn't work with the expansion hub. I have a couple extra arduino boards around, I'll try the serial idea as well. Thanks!
-Jon
Post Reply