6 #include <Adafruit_BMP280.h>
8 U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
10 // U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display
13 #define DHTPIN 3 // what pin we're connected to
14 #define DHTTYPE DHT11 // DHT 11
16 DHT dht(DHTPIN, DHTTYPE);
19 Adafruit_BMP280 bmp; // I2C
24 LIS3DHTR<TwoWire> LIS; //IIC
34 //u8x8.setBusClock(100000); // If you breakout other modules, please enable this line
44 Serial.println(F("Could not find a valid BMP280 sensor!"));
47 /* Default settings from datasheet. */
48 bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
49 Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
50 Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
51 Adafruit_BMP280::FILTER_X16, /* Filtering. */
52 Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
54 pinMode(BUTTON_PIN, OUTPUT);
55 pinMode(SOUND_PIN, INPUT);
56 pinMode(LIGHT_PIN, INPUT);
59 LIS.begin(WIRE, 0x19);
62 LIS.setFullScaleRange(LIS3DHTR_RANGE_2G);
63 LIS.setOutputDataRate(LIS3DHTR_DATARATE_5KHZ);
64 LIS.setHighSolution(true); //High solution enable
74 int oled_active = ! digitalRead(BUTTON_PIN);
75 u8x8.setPowerSave( oled_active );
78 temp = dht.readTemperature();
79 humi = dht.readHumidity();
81 u8x8.setFont(u8x8_font_chroma48medium8_r);
83 //u8x8.print("Temp:");
86 Serial.print("dht_temp=");
89 temp = bmp.readTemperature();
91 Serial.print(",bmp_temp=");
96 u8x8.setCursor(0,1 * 9);
97 u8x8.print("Humidity:");
100 Serial.print(",dht_humidity=");
104 pressure = bmp.readPressure();
106 u8x8.setCursor(0,2 * 9);
107 u8x8.print( pressure );
108 Serial.print(",bmp_pressure=");
109 Serial.print(pressure);
111 unsigned long sumSquare;
112 for(int i=0; i++; i<1000) {
113 int sound = analogRead(SOUND_PIN);
114 sumSquare += sound * sound;
116 int rms_sound = sqrt(sumSquare / 1000);
117 Serial.print(",rms_sound=");
118 Serial.print(rms_sound);
120 int sound = analogRead(SOUND_PIN);
121 u8x8.setCursor(0,3 * 9);
123 Serial.print(",sound=");
126 int light = analogRead(LIGHT_PIN);
127 u8x8.setCursor(0,3 * 9);
129 Serial.print(",light=");
132 u8x8.refreshDisplay();
134 float x = 0, y = 0, z = 0;
135 for(int i=0; i<=300; i++) {
136 x += LIS.getAccelerationX();
137 y += LIS.getAccelerationY();
138 z += LIS.getAccelerationZ();
141 Serial.print(",x="); Serial.print(x);
142 Serial.print(",y="); Serial.print(y);
143 Serial.print(",z="); Serial.print(z);
147 t = t + 1000 - millis();