You can also make one Arduino act as a slave. This is useful for multi-processor projects. Master Code (Sends a command): #include <Wire.h> void setup() Wire.begin(); Serial.begin(9600);
void loop() // Tell sensor to start measurement Wire.beginTransmission(SENSOR_ADDR); Wire.write(0x12); // Pressure data register (MSB) Wire.endTransmission(false); // Repeated start arduino wire.h library
if(Wire.available() >= 5) unsigned long pressure_raw = ((long)Wire.read() << 16) delay(1000); You can also make one Arduino act as a slave
// Request 5 bytes (3 pressure, 2 temp) Wire.requestFrom(SENSOR_ADDR, 5); void setup() Wire.begin()
Happy making!
#include <Wire.h> void receiveEvent(int bytes) while(Wire.available()) char c = Wire.read(); Serial.print(c);
Serial.println();