I am unable to read from it by using brzo library. My understanding of hardware and firmware is not very strong and I have been trying to figure it out for sometime but not able to wrap my head around it. Will be really helpful if someone can point me to right direction.
#include <brzo_i2c.h>
uint8_t SDA_PIN = 4;
uint8_t SCL_PIN = 5;
uint8_t MAX11615_ADR = 0x33;
uint8_t buffer[4];
uint8_t error = 0;
float pH = 0.0;
float EC = 0.0;
uint8_t ICACHE_RAM_ATTR get_pH_EC(float *p, float *e) {
uint32_t ph_code = 0;
uint32_t ec_code = 0;
uint8_t bcode = 0;
brzo_i2c_start_transaction(MAX11615_ADR, 400);
buffer[0] = 0xD2;
buffer[1] = 0x09;
brzo_i2c_write(buffer, 2, true);
buffer[0] = 0x00;
brzo_i2c_write(buffer, 1, true);
brzo_i2c_read(buffer, 4, false);
bcode = brzo_i2c_end_transaction();
// ec_code_e = buffer[9];
ph_code = ((buffer[0] << 4) | buffer[1]);
ec_code = ((buffer[2] << 4) | buffer[3]);
*p = ph_code;
*e = ec_code;
Serial.print(bcode);
Serial.print("ph code = ");
Serial.println(ph_code);
Serial.print("EC Code = ");
Serial.println(ec_code);
return bcode;
}
void setup() {
delay(1000);
Serial.begin(115200);
brzo_i2c_setup(SDA_PIN, SCL_PIN, 2000);
}
void loop() {
Serial.println("Waiting 5 seconds...");
delay(5000);
error = get_pH_EC(&pH, &EC);
if (error == 0) {
//Print ph and ec
}
else {
Serial.print("Brzo error : ");
Serial.println(error);
}
}