title: Sending a JSON String via I2C between Arduino and RPi IOT C#
body: <p>I'm trying to send a JSON String via I2C from an Arduino Uno to a RaspPi running Win IOT Core.</p>
  
  <p>The connection works fine, I've registered an event handler on the Arduino side which is called fine when the master (rpi) requests data.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void I2CRequest()
  {
    Serial.println("I2C Request received");
   /*Send data to WinIoT */
  
   int bt = Wire.write(lastJSON.c_str());
   Serial.println(lastJSON);
   Serial.print("Send bytes: ");
   Serial.println(bt);
  }
  </code></pre>
  
  <p>The output on the Serial Monitor looks also fine...</p>
  
  <pre><code>I2C Request received
  {"Sensor":"OneWire","data":["28ffc8675216451",23.9375,"28ff9feb521645e",24.0625]}
  Send bytes: 81
  </code></pre>
  
  <p>The C# method on the RPi looks like this:</p>
  
  <pre class="lang-c# prettyprint-override"><code>public static async Task&lt;byte[]&gt; GetI2CTemperatures()
      {
          var ReceivedData = new byte[1024];
  
          /* Arduino Nano's I2C SLAVE address */
          int SlaveAddress = 64;              // 0x40
  
          try
          {
              // Initialize I2C
              var Settings = new I2cConnectionSettings(SlaveAddress);
              Settings.BusSpeed = I2cBusSpeed.StandardMode;
  
              if (AQS == null || DIS == null)
              {
                  AQS = I2cDevice.GetDeviceSelector("I2C1");
                  DIS = await DeviceInformation.FindAllAsync(AQS);
              }
  
  
              using (I2cDevice Device = await I2cDevice.FromIdAsync(DIS[0].Id, Settings))
              {
                  if (Device==null)
                  {
                      Debug.Write("No access to I2C Device");
                  }
  
  
                  /* Read from Arduino  */
                  Device.Read(ReceivedData);
              }
          }
          catch (Exception ex)
          {
              Debug.WriteLine("Exception occurred on reading I2C",ex);
              // SUPPRESS ANY ERROR
          }
  
          /* Return received data or ZERO on error */
          return ReceivedData;
      }
  }
  </code></pre>
  
  <p>Unfortunately whatever I do, I just get as a result in <code>ReceivedData</code> a <code>00</code> as the first byte followed by <code>FF</code>s.<br>
  I've tried also <code>Device.ReadPartial()</code> instead of <code>Device.Read()</code> with the same result.</p>
  
  <p>Can anybody point me into the right direction what I'm doing wrong?</p>