OK.
Let's start with some background information.
What model of Beaglebone?
What version of OS, kernel?
Which version of Python? 
How is the pH sensor hooked to the Beaglebone?
What Voltage are you using to power the pH sensor?

Now some basics to see if the I2C bus is running

sudo apt-get install i2c-tools

now run
i2cdetect -y -r 1
what do you get?

now run
i2cdetect -y -r 2
what do you get?

When you say that you get "garbage" what do you mean?
What do you actually get? errors? tracebacks? obviously wrong data, but no 
reported errors?

--- Graham

==

On Thursday, June 15, 2017 at 5:38:58 PM UTC-5, Sebastián Sáez wrote:
>
>
> Hi,
>
> I'm writing a python script to communicate via i2c with the ph oem sensor 
> from Atlas Scientific.
>
> https://www.atlas-scientific.com/product_pages/oem/oem_ph.html
>
> https://www.atlas-scientific.com/_files/_datasheets/_oem/pH_oem_datasheet.pdf
>
> I already tried with the i2c module of mraa and smbus without luck. 
> Now I am trying to translate this arduino example from Atlas to python but 
> I read garbage
>
>
> Any suggestions?, attached the full example arduino code
>
>
> *Atlas arduino code*
> byte i2c_device_address=0x65;
> byte starting_register=0x00
> byte device_type;
> byte version_number;
> Wire.beginTransmission(i2c_device_address);
> Wire.write(staring_register);
> Wire.endTransmission();
> Wire.requestFrom(i2c_device_address,(byte)2);
> device_type = Wire.read();
> version_number = Wire.read();
> Wire.endTransmission(); 
>
>
> *My python script*
> import smbus
>
> # General i2c device class so that other devices can be added easily
> class i2c_device:
>  def __init__(self, addr, port):
>  self.addr = addr
>  self.bus = smbus.SMBus(port)
>
>  def write(self, byte):
>  self.bus.write_byte(self.addr, byte)
>
>  def read(self):
>  return self.bus.read_byte(self.addr)
>
>  def read_nbytes_data(self, data, n): # For sequential reads > 1 byte
>  return self.bus.read_i2c_block_data(self.addr, data, n)
>
> ph = i2c_device(0x65, 2)
> ph.write(0x00)
> device_type = ph.read()
> version_number = ph.read()
> print(device_type)
> print(version_number)
>
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/4e302bea-d05f-4cb9-bc4f-55de94d496be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to