From 9e538d6fc765ddb51e58b95feb327074f0a1e9e1 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Tue, 11 Apr 2023 09:43:38 +0200 Subject: [PATCH] Initial commit --- README.md | 7 ++++ firmware/.DS_Store | Bin 0 -> 6148 bytes firmware/firmware.ino | 70 +++++++++++++++++++++++++++++++++++++ firmware/sensor_bmp280.ino | 38 ++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 README.md create mode 100644 firmware/.DS_Store create mode 100644 firmware/firmware.ino create mode 100644 firmware/sensor_bmp280.ino diff --git a/README.md b/README.md new file mode 100644 index 0000000..43de912 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +Arduino Nano mit AtMega328p (old bootloader) einstellen in Arduino IDE einstellen. + + +D9 (Pin12) wird mit dem PWM-Eingang der PWM Platine verbunden, +A4 SDA vom BMP280 +D1 SCK vom BMP280 + diff --git a/firmware/.DS_Store b/firmware/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..eff5b43748f3afcb5f3f632c6dd3454e108beaf6 GIT binary patch literal 6148 zcmeHKQA+|r5S~@b6AOGO@NuD6Aw`U&m&5E2bWsl#c9)We*R6PGK8SG7^@sW;{hnra z*GSBl9wKB0X203lnOo+&W9JqCL}%J>08{|LK_$$UaQH!Jopeod)`JL9SlWJY9S&x_%E7scQ$LIc6P*zD2N-g96UKct>!@kmPjs$l7Mzk( z>Q$=qdHb|gla15*q9*6J3L3f< gV=T4eDykOrOEM5$i 0 && bmp280_temp <= FAN_OFF_MAX_TEMP) + { + fan_state = FAN_OFF_STATE; // off + } + + if (bmp280_temp >= FAN_ON_TEMP) + { + fan_state = FAN_ON_STATE; + } + + Serial.println("FAN state: " + String(fan_state)); + + analogWrite(FAN_PIN, fan_state); + + digitalWrite(L_LED_PIN, LOW); + + bmp280_lastcheck_millis = millis(); + } + +} diff --git a/firmware/sensor_bmp280.ino b/firmware/sensor_bmp280.ino new file mode 100644 index 0000000..8af26f8 --- /dev/null +++ b/firmware/sensor_bmp280.ino @@ -0,0 +1,38 @@ + +#include // Install from library manager - sensor board info: https://www.bastelgarage.ch/bmp280-temperatur-luftdruck-sensor + +Adafruit_BMP280 _sensor_bmp280; +Adafruit_Sensor *_sensor_bmp280_temp = _sensor_bmp280.getTemperatureSensor(); +Adafruit_Sensor *_sensor_bmp280_pressure = _sensor_bmp280.getPressureSensor(); + +#define BPM280_TEMP_FACTOR 1.0 + +bool sensor_bmp280_begin(uint8_t addr) { + bool status = _sensor_bmp280.begin(addr); + + if (status) { + Serial.println("BMP280 Connected"); + + _sensor_bmp280.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ + Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ + Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ + Adafruit_BMP280::FILTER_X16, /* Filtering. */ + Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ + + } else { + Serial.println("Could not find a valid BMP280 sensor, check wiring or try a different address!"); + Serial.println("SensorID was: " + String(_sensor_bmp280.sensorID())); + Serial.println(" ID of 0xFF probably means a bad address, a BMP180 or BMP085"); + Serial.println(" ID of 0x56-0x58 represents a BMP280,"); + Serial.println(" ID of 0x60 represents a BME280,"); + Serial.println(" ID of 0x61 represents a BME680."); + } + + return status; +} + +float sensor_bmp280_temperature() { + sensors_event_t temp_event, pressure_event; + _sensor_bmp280_temp->getEvent(&temp_event); + return temp_event.temperature * BPM280_TEMP_FACTOR; +}