So far I believe I have my ph sensor hooked up properly to i2c pins A4 and A5. My code is as follows:
var m = require('mraa'); var i2c = new m.I2c(1); i2c.address(0x63); i2c.write("R,56.26"); console.log("Reading I2C.."); function readPH() { var data = i2c.read(); console.log( ">> I2C value: " + data); } setTimeout(function (e) { readPH(); }, 1000);
The code is pretty much straight forward. I send the command R,56.26 to the ph sensor, wait 1 second and then execute i2c.read().
The datasheet of the ph sensor explains:
I used a setTimeout at 1sec to allow enough time for the ph sensor to calculate the value. After 1second is up readPH() function executes. i2c.read() does read data; however, when I output the data value I only receive a 1 as the output. How do I read the complete 7 byte string?