Question about I2C data bits (ascii more than 127)

Why need a scope :wink:

// Forum: https://forum.arduino.cc/t/question-about-i2c-data-bits-ascii-more-than-127/1113744/
//
// Use byte array, or else the Serial.print() sees a negative number

byte test[] = "€";

void setup() 
{
  Serial.begin(115200);

  Serial.println("Print text as hex");

  Serial.print( (char *)test);
  Serial.print( " = ");
  for( int i=0; i<strlen(test); i++)
  {
    Serial.print( "0x");
    if( test[i] < 0x10)
      Serial.print( "0");
    Serial.print( test[i], HEX);
    Serial.print( ",");
  }
  Serial.println();
}

void loop() {}

Try it in Wokwi:

1 Like