├── .gitattributes ├── .gitignore └── I2C_1-Video.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /I2C_1-Video.ino: -------------------------------------------------------------------------------- 1 | /* Showcase of how to connect several I2C devices to one bus 2 | 3 | - Pressure Sensor 4 | - OLED display 5 | - Capacitive Sensor 6 | 7 | */ 8 | 9 | // Your sketch must #include this library, and the Wire library. 10 | // (Wire is a standard library included with Arduino.): 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "Adafruit_MPR121.h" 18 | 19 | // You will need to create an SFE_BMP180 object, here called "pressure": 20 | 21 | #define OLED_RESET 4 22 | Adafruit_SSD1306 display1(OLED_RESET); 23 | SFE_BMP180 pressure; 24 | Adafruit_MPR121 cap = Adafruit_MPR121(); 25 | 26 | double T, P; 27 | bool page = false; 28 | 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | Serial.println("REBOOT"); 34 | display1.begin(SSD1306_SWITCHCAPVCC, 0x3C); 35 | 36 | // Initialize the sensor (it is important to get calibration values stored on the device). 37 | 38 | if (pressure.begin()) 39 | Serial.println("BMP180 init success"); 40 | else 41 | { 42 | // Oops, something went wrong, this is usually a connection problem, 43 | // see the comments at the top of this sketch for the proper connections. 44 | 45 | Serial.println("BMP180 init fail (disconnected?)\n\n"); 46 | while (1); // Pause forever. 47 | } 48 | 49 | Serial.println("Adafruit MPR121 Capacitive Touch sensor test"); 50 | 51 | // Default address is 0x5A, if tied to 3.3V its 0x5B 52 | // If tied to SDA its 0x5C and if SCL then 0x5D 53 | if (!cap.begin(0x5A)) { 54 | Serial.println("MPR121 not found, check wiring?"); 55 | while (1); 56 | } 57 | Serial.println("MPR121 found!"); 58 | 59 | } 60 | 61 | void loop() 62 | { 63 | // Get a new pressure reading: 64 | getPressure(); 65 | 66 | if ( cap.touched() == 1 ) page = !page; 67 | 68 | if (page) { 69 | 70 | display1.setTextSize(2); 71 | display1.setTextColor(WHITE); 72 | display1.clearDisplay(); 73 | display1.setCursor(10, 0); 74 | display1.println("Pressure"); 75 | display1.setCursor(10, 30); 76 | display1.println(P); 77 | display1.display(); 78 | 79 | } 80 | else { 81 | 82 | display1.setTextSize(2); 83 | display1.setTextColor(WHITE); 84 | display1.clearDisplay(); 85 | display1.setCursor(10, 0); 86 | display1.println("Temp"); 87 | display1.setCursor(10, 30); 88 | display1.println(T); 89 | display1.display(); 90 | } 91 | 92 | delay(500); 93 | } 94 | 95 | 96 | void getPressure() 97 | { 98 | char status; 99 | double p0, a; 100 | 101 | // You must first get a temperature measurement to perform a pressure reading. 102 | 103 | // Start a temperature measurement: 104 | // If request is successful, the number of ms to wait is returned. 105 | // If request is unsuccessful, 0 is returned. 106 | 107 | status = pressure.startTemperature(); 108 | if (status != 0) 109 | { 110 | // Wait for the measurement to complete: 111 | 112 | delay(status); 113 | 114 | // Retrieve the completed temperature measurement: 115 | // Note that the measurement is stored in the variable T. 116 | // Use '&T' to provide the address of T to the function. 117 | // Function returns 1 if successful, 0 if failure. 118 | 119 | status = pressure.getTemperature(T); 120 | if (status != 0) 121 | { 122 | // Start a pressure measurement: 123 | // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait). 124 | // If request is successful, the number of ms to wait is returned. 125 | // If request is unsuccessful, 0 is returned. 126 | 127 | status = pressure.startPressure(3); 128 | if (status != 0) 129 | { 130 | // Wait for the measurement to complete: 131 | delay(status); 132 | 133 | // Retrieve the completed pressure measurement: 134 | // Note that the measurement is stored in the variable P. 135 | // Use '&P' to provide the address of P. 136 | // Note also that the function requires the previous temperature measurement (T). 137 | // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.) 138 | // Function returns 1 if successful, 0 if failure. 139 | 140 | status = pressure.getPressure(P, T); 141 | if (status != 0) 142 | { 143 | 144 | } 145 | else Serial.println("error retrieving pressure measurement\n"); 146 | } 147 | else Serial.println("error starting pressure measurement\n"); 148 | } 149 | else Serial.println("error retrieving temperature measurement\n"); 150 | } 151 | else Serial.println("error starting temperature measurement\n"); 152 | } 153 | --------------------------------------------------------------------------------