Boron not talking to Atlas Scientific pH sensor

Hello,

I’m using a Boron to connect to an Atlas Scientific pH sensor using the Tentacle 3 HAT board. All the connections are as per the specifications I found online but the Boron is unable to listen to the sensor. This is the code I’m running and I keep getting a -1 value for Wire.read(). Please help!

String WebHookName = "SetWebhookParameter";
#define address 99
double ph = 0;

void setup() {
    Wire.setSpeed(20000);
    if (!Wire.isEnabled())
    Wire.begin();
    Particle.variable("pH", ph);
}

void loop() {
     char data[20];
  int i=0;
  String cmd = "R";
    Wire.beginTransmission(address);
  Wire.write(cmd);
  Wire.endTransmission();
  Wire.requestFrom(address, 20);
  int val=Wire.read();
  switch (val) {
    case 1:
    Particle.publish("Read", "Success");
      break;
    case 2:
      Particle.publish("Read", "Failed");
      break;
    case 254:
      Particle.publish("Read", "Pending");
      break;
    case 255:
      Particle.publish("Read", "No Data");
      break;
    default:
      String Publish = String::format("Invalid response:%d", val);
      Particle.publish("Read", Publish);
      }

  while(Wire.available()) {
    data[i]= Wire.read();
    i+=1;
  }
  Wire.endTransmission();
  String pH_data = data;
  
  if (isdigit(pH_data.charAt(0))) {
    float current = String(pH_data).toFloat();
    if((ph == 0))
      ph = current;
    else
      ph = (ph + current) / 2;
  }
    String DataPublish = String::format("{\"ph\":%f}",ph);
    Particle.publish("Data", DataPublish);
    delay(2000);
}

Whenever experiencing difficulties communicating with an I2C device it’s advisable to check the most basic communication with an I2C scanner application.

If this doesn’t find the device chances are that your are missing the pull-up resistors on the communication lines.

To exactly understand your HW setup it’s also,good practice to provide a schematic or at least a pin connection table and the exact types of the sensor and connection board (preferable with link).

1 Like