diff --git a/README.md b/README.md index e69de29..4d2ee51 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,33 @@ + +NodeMCU v0.9 + + A0 D0 + RSV (5)D1 - SDS_TX + RSV (4)D2 - SDS_RX + RSV (0)D3 - BMP_SDA + RSV (2)D4 - BMP_SCL + RSV 3V3 - BMP_VCC + RSV GND - BMP_GND + GND D5 + 3V3 D6 + GND D7 - DHT_DATA + 3V3 D8 + EN RX + RST TX + SDS_GND ?- GND GND + SDS_5V ?- 5V 3V3 + +SDS011 + - TXD + - RXD + - GND + - + - 5V + - + - + +DHT22 + VDD -> 3V3 + DATA -> D7 + -> + GND -> GND diff --git a/platformio.ini b/platformio.ini index 5f9e304..5e845e5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,3 +12,7 @@ platform = espressif8266 board = nodemcuv2 framework = arduino + +lib_deps = + Adafruit BMP085 Library + DHT sensor library diff --git a/src/main.cpp b/src/main.cpp index 08df484..e8654c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,16 +1,101 @@ -#include "Arduino.h" +/* + * WetterStation + * Version: 0.0 + * Author: Hendrik Langer + */ + +#include +#include + +#include +#include +#include +#include +#include + +const char* server = "ingress.opensensemap.org"; +const char* ssid = "Freifunk"; +const char* password = ""; + +constexpr unsigned int postingInterval = 60000; //Uploadintervall in Millisekunden + +//senseBox ID +#define SENSEBOX_ID "5a9e9e38f55bff001a494877" + +//Sensor IDs +// Temperature +#define SENSOR1_ID "5a9e9e38f55bff001a49487e" +// Humidity +#define SENSOR2_ID "5a9e9e38f55bff001a49487d" +// Pressure +#define SENSOR3_ID "5a9e9e38f55bff001a49487c" +// PM10 +#define SENSOR4_ID "5a9e9e38f55bff001a49487b" +// PM2.5 +#define SENSOR5_ID "5a9e9e38f55bff001a49487a" +// Radioactivity +#define SENSOR6_ID "5a9e9e38f55bff001a494879" +// Voltage +#define SENSOR7_ID "5a9e9e38f55bff001a494878" + + +static constexpr uint8_t BMP_SCL = D4; +static constexpr uint8_t BMP_SDA = D3; + +static constexpr uint8_t DHT22_PIN = D7; +static constexpr uint8_t DHTTYPE = DHT22; // DHT 22 (AM2302) + +Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); +DHT dht(DHT22_PIN, DHTTYPE); + +void sendValues() { + WiFi.forceSleepWake(); + WiFi.begin(ssid, password); + Serial.print("Connecting to wifi"); + while (WiFi.status() != WL_CONNECTED) { + Serial.print("."); + delay(500); + } + Serial.println(" [CONNECTED]"); + Serial.print("IP address: "); + Serial.println(WiFi.localIP()); + + Wire.begin(BMP_SDA, BMP_SCL); + if (!bmp.begin()) { + Serial.println("No valid BMP085 sensor!"); + } + + dht.begin(); + + float temp = dht.readTemperature(); +// float pressure = bme.readPressure() / 100.0F; + float humidity = dht.readHumidity(); + + Serial.println(temp); + Serial.println(humidity); + + float pressure, temp2; + bmp.getPressure(&pressure); + pressure /= 100; + bmp.getTemperature(&temp2); + Serial.println(temp2); + Serial.println(pressure); + +// float temperature = sensor.readTemperature(); +// postFloatValue(temperature, 1, temperatureSensorID); + + WiFi.mode(WIFI_OFF); + WiFi.forceSleepBegin(); + +} -#ifndef LED_BUILTIN -#define LED_BUILTIN 13 -#endif void setup() { + Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); } void loop() { - digitalWrite(LED_BUILTIN, HIGH); - delay(1000); - digitalWrite(LED_BUILTIN, LOW); - delay(1000); + sendValues(); + delay(postingInterval); }