Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Blog post describing the use case for this script is here :
#include <Wire.h>
int buff[1024];
int buff_pointer = 0;
void setup()
Serial.begin(115200); // start serial for output
Wire.begin(0x3c); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
void loop()
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
int j = 0;
while (j < howMany) // loop through all but the last
int c =; // receive byte as a character
Serial.print("0x"); // print the character in Hex
Serial.print(" ");
Serial.print(c); // print the character as ascii
Serial.print(" ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.