You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learn/05.communication/01.wire/wire.md
+86-3Lines changed: 86 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,6 +198,8 @@ void requestEvent() {
198
198
199
199
### Controller Writer
200
200
201
+

202
+
201
203
In some situations, it can be helpful to set up two (or more!) Arduino boards to share information with each other. In this example, two boards are programmed to communicate with one another in a Controller Writer/Peripheral Receiver configuration via the [I2C synchronous serial protocol](http://en.wikipedia.org/wiki/I2C). Several functions of Arduino's [Wire Library](https://www.arduino.cc/en/Reference/Wire) are used to accomplish this. Arduino 1, the Controller, is programmed to send 6 bytes of data every half second to a uniquely addressed Peripheral. Once that message is received, it can then be viewed in the Peripheral board's serial monitor window opened on the USB connected computer running the Arduino Software (IDE).
This code lets you read accelerometer data from a [Grove 6-Axis Accelerometer module](https://store.arduino.cc/collections/sensors/products/grove-6-axis-accelerometer-gyroscope) using the [seeed arduino LSM6DS3 library](https://www.arduino.cc/reference/en/libraries/seeed-arduino-lsm6ds3/).
285
288
@@ -325,10 +328,90 @@ void loop() {
325
328
}
326
329
```
327
330
331
+
### I2C BMP280
332
+
333
+

334
+
335
+
This code example lets you read the temperature over I2C from a BMP280 breakout module from Adafruit:
336
+
```arduino
337
+
#include <Wire.h>
338
+
#include <Adafruit_BMP280.h>
339
+
340
+
//Create an instance of the BMP280 sensor
341
+
Adafruit_BMP280 bmp;
342
+
343
+
void setup() {
344
+
Serial.begin(9600);
345
+
346
+
// Start the sensor, and verify that it was found
347
+
if (!bmp.begin()) {
348
+
Serial.println("Sensor not found");
349
+
while (1){}
350
+
}
351
+
352
+
}
353
+
354
+
void loop() {
355
+
// Read the values
356
+
float temperature = bmp.readTemperature();
357
+
358
+
// Print to the Serial Monitor
359
+
Serial.print("Temperature: ");
360
+
Serial.print(temperature);
361
+
Serial.println(" C");
362
+
363
+
Serial.println();
364
+
delay(2000);
365
+
}
366
+
367
+
```
368
+
369
+
328
370
### I2C OLED
371
+

372
+
This code example draws a (very crude) version of the Arduino logo on a 128x64 I2C Grove OLED:
329
373
330
-
[This code example](https://github.com/adafruit/Adafruit_SSD1306/blob/master/examples/ssd1306_128x32_i2c/ssd1306_128x32_i2c.ino) lets you write on an [Adafruit Monochrome I2C OLED display](https://www.adafruit.com/product/4440) using the popular ssd1306 driver
374
+
```arduino
375
+
#include <Wire.h>
376
+
#include <Adafruit_GFX.h>
377
+
#include <Adafruit_SSD1306.h>
378
+
379
+
Adafruit_SSD1306 display(128, 64, &Wire, -1);
380
+
381
+
void setup() {
382
+
Serial.begin(9600);
383
+
384
+
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
385
+
Serial.println(F("SSD1306 not found"));
386
+
while(1){}
387
+
}
388
+
389
+
display.display();
390
+
delay(2000);
391
+
display.clearDisplay();
392
+
393
+
drawArduino();
394
+
}
395
+
396
+
void loop() {
397
+
}
398
+
399
+
void drawArduino(){
400
+
display.clearDisplay();
331
401
332
-
### I2C BME280
333
-
[This code example](https://github.com/sparkfun/SparkFun_BME280_Arduino_Library/) lets you read temperature, humidity, pressure and altitude from [Sparkfuns BME280 breakout module](https://www.sparkfun.com/products/13676)
0 commit comments