title: Intel Edison Arduino breakout board: How do I recieve all of the i2c result bytes?(NodeJS)
body: <p>I have an Intel Edison Arduino breakout board, Atlas Scientific EZO PH sensor and an Atlas Scientific Power Isolator.  </p>
  
  <p>I have the power isolator between the Intel Edison Arduino break-out board i2c bus (A4/A5) and the ph sensor.  </p>
  
  <p>The Atlas Scientific data sheets can be found here:<br>
  EZO Ph sensor: <a href="http://www.atlas-scientific.com/_files/_datasheets/_circuit/pH_EZO_datasheet.pdf?" rel="nofollow noreferrer">PH Data-sheet</a><br>
  Power Isolator: <a href="http://www.atlas-scientific.com/_files/_datasheets/_circuit/pwr-iso.pdf?" rel="nofollow noreferrer">Power Isolator Data-sheet</a>    </p>
  
  <p>NodeJS code:  </p>
  
  <pre><code>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( "&gt;&gt; I2C value: " + data);  
  }  
  setTimeout(function (e) { readPH(); }, 1000);
  </code></pre>
  
  <p>I send the command R,56.26 to the ph sensor, wait 1 second and then execute <code>i2c.read();</code>.</p>
  
  <p>I see the lights blink and change color the way they are supposed to when the command is  sent and when the <code>i2c.read()</code> is executed, so I know I am requesting a reading and getting a result.  </p>
  
  <p><strong>The EZO PH sensor data-sheet explains:</strong><br>
  <img src="https://i.stack.imgur.com/9V8b6.png" alt="EZO PH Sensor Result response"><br>
  <img src="https://i.stack.imgur.com/FnHJs.png" alt="enter image description here"></p>
  
  <p>I seem to only be able to store the first bit of my result instead of the full 7 bytes.  I seem to always return a 1.  The 1 that I am receiving corresponds to "Success". To troubleshoot further,  I sent R,34.53 to the ph sensor and then prematurely executed <code>i2c.read();</code> and received 254 which corresponds to "Pending". So, I believe I am receiving the result or a partial result from the EZO PH sensor. </p>
  
  <p>I am at a loss as to how I to store the 7 byte result. I don't know the inner workings of the mraa nodejs library API. So, I am not sure if I should use an object, array, or a variable to store the result, or if I am missing an argument in the <code>i2c.read();</code> </p>
  
  <h2><strong>UPDATE</strong></h2>
  
  <p>I read through the mraa github example section which explains, "There is no explicit nodejs API documentation, see the examples. The API itself is very similar to the python one but with a js syntax." So I wrote a rather simple python script that gets the Ph Sensor value successfully.  </p>
  
  <p>Python code:  </p>
  
  <pre><code>import time
  import mraa
  
  i2c = mraa.I2c(1)
  i2c.address(0x63)
  
  i2c.write("R,23.5")
  
  time.sleep(1.3)
  d = "       "
  i2c.read(d)
  print(d)
  </code></pre>
  
  <p>The python code outputs: 2.974 Getting a result proves my circuit design works and now I need to figure out what the NodeJS API is to get a successful i2c reading. Does anyone know the NodeJS API for getting an i2c reading?  </p>
  
  <p><strong>UPDATE</strong><br>
  Working example code:  </p>
  
  <pre><code>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 d = i2c.read(7);
      console.log("&gt;&gt; " + d);
  }
  setTimeout(function (e) { readPH(); }, 1000);
  </code></pre>