Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////BIBLIOTEKI
- #include <Wire.h>
- #include <SPI.h>
- #include <Adafruit_Sensor.h>
- #include "Adafruit_BME680.h"
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- ////////SENZOR
- #define BME_SCK 13
- #define BME_MISO 12
- #define BME_MOSI 11
- #define BME_CS 10
- #define SEALEVELPRESSURE_HPA (1013.25)
- Adafruit_BME680 bme; // I2C
- //Adafruit_BME680 bme(BME_CS); // hardware SPI
- //Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK);
- ///////EKRAN
- #define BACKLIGHT_PIN 9
- LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address
- const uint8_t charBitmap[][8] = {
- { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
- { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
- { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
- { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
- { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
- { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
- { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
- { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
- };
- ////////MOTOR
- #define MOTOR_PIN 8
- void setup() {
- pinMode(MOTOR_PIN, OUTPUT);
- Serial.begin(9600);
- while (!Serial);
- Serial.println(F("BME680 test"));
- if (!bme.begin()) {
- Serial.println("Could not find a valid BME680 sensor, check wiring!");
- while (1);
- }
- // Set up oversampling and filter initialization
- bme.setTemperatureOversampling(BME680_OS_8X);
- bme.setHumidityOversampling(BME680_OS_2X);
- bme.setPressureOversampling(BME680_OS_4X);
- bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
- bme.setGasHeater(320, 150); // 320*C for 150 ms
- int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
- // Switch on the backlight
- pinMode ( BACKLIGHT_PIN, OUTPUT );
- digitalWrite ( BACKLIGHT_PIN, HIGH );
- lcd.begin(16, 2); // initialize the lcd
- for ( int i = 0; i < charBitmapSize; i++ )
- {
- lcd.createChar ( i, (uint8_t *)charBitmap[i] );
- }
- lcd.home ();
- }
- void loop() {
- if (! bme.performReading()) {
- Serial.println("Failed to perform reading :(");
- return;
- }
- int temp = bme.temperature;
- if(temp > 30){
- digitalWrite(MOTOR_PIN, HIGH);
- }
- delay(2000);
- lcd.setCursor(0,0);
- lcd.print("temp: ");
- lcd.print(temp);
- lcd.setCursor(0,1);
- lcd.print("FAN: ");
- if(digitalRead(MOTOR_PIN) == LOW) lcd.print("ON");
- else lcd.print("OFF");
- }
Advertisement
Add Comment
Please, Sign In to add comment