Argument of type Void is incompatible


I am trying to write a simple i2c reader and when i come to compile the code i get an error " argument of type “void()()" is incompatible with parameter of type "void()(int)”

code is below, the error relates to line Wire.onReceive(read_data);

any help would be greatly appreciated.

#include <Wire.h>
// Define Slave I2C Address
#define SLAVE_ADDR 9
// Variable for received data
int rd;
// Variable for blink rate
int br;

void setup() {
  // Initialize I2C communications as Slave

  // Function to run when data received from master
  // Setup Serial Monitor 
  Serial.println("I2C Slave Demonstration");
void loop() {
  rd =;
  // Calculate blink value
  br = map(rd, 1, 255, 10, 100); 

void read_data() {
  // read one character from the I2C
  rd =;
  // Print value of incoming data

Your read_data function requires an int parameter for how many bytes to receive:

void read_data(int howMany)

This is necessary even if you don’t need the howMany parameter.

Thanks @rickkas7 i come from the Arduino world where you seem to get away with things like this!