I am using an Atlas Scientific I2C sensor and trying to connect it to the Pi. http://www.atlas-scientific.com/_files/_datasheets/_circuit/EC_EZO_Datasheet.pdf

Here's the code that I'm running:

import smbus
import time

bus = smbus.SMBus(1)

def read_sensor(addr):
    time.sleep(1)                # This is required by the sensor
    for i in range (0,32):
        print bus.read_byte(addr)

I also try:

result = bus.read_i2c_block_data(addr,0x52)
print result # returns 1, then 255's

When I write 0x52, the light changes as it should, then when I read a byte, the first byte is 1, meaning that it is successful, but the rest of the bytes are 255.

How can I trigger the read by sending 0x52, then wait a second while the sensor takes its readings, the read the 32 bytes available WITHOUT sending any additional commands.

I looked into pyA13 library, but this apparently doesn't run on Pi.

Can Python do this?

  • Isn't your Python script already doing the 1 second pause? Did you calibrate the sensor first? Did you try using the sensor in different environments?
    – tlhIngan
    Jun 17, 2016 at 19:47
  • @tlhIngan It is pausing, but I think the problem is that when I call the read, it is sending a new request to the sensor causing the sensor to think it is a new request
    – pekasus
    Jun 17, 2016 at 20:36
  • You aren't talking to the device. write_byte(0x09, 0x52) is sending byte 0x52 to (the non-existent) device at address 0x09.
    – joan
    Jun 17, 2016 at 20:51
  • @joan 0x09 is the actual address of the sensor. I forgot to replace it with 'addr' when I pasted the code. I corrected it.
    – pekasus
    Jun 17, 2016 at 21:00

1 Answer 1


I think you may be running up against an inherent problem with SMBus commands, they are not great at talking to I2C devices.

I suggest you try reading the device with my pigpio library.

If you have a recent Raspbian this may be preinstalled or available from the repositories.

To check try

sudo pigpiod

If that doesn't work do

sudo apt-get update
sudo apt-get install pigpio python-pigpio python3-pigpio

and then do sudo pigpiod

If that doesn't work see http://abyz.me.uk/rpi/pigpio/download.html

Then enter the following commands

pigs i2co 1 0x09 0
pigs i2cwd 0 0x52
sleep 1
pigs -x i2crd 0 20

If that gives a result you can do the same with the pigpio Python module.

  • This looks promising. I tried it on Ubuntu Mate, and it can't find the packages in apt-get. I'll try it on my Raspian later.
    – pekasus
    Jun 17, 2016 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.