Hendrik Langer
7 years ago
3 changed files with 130 additions and 8 deletions
@ -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 |
@ -1,16 +1,101 @@ |
|||||
#include "Arduino.h" |
/*
|
||||
|
* WetterStation |
||||
|
* Version: 0.0 |
||||
|
* Author: Hendrik Langer <hendrik+dev@xd0.de> |
||||
|
*/ |
||||
|
|
||||
|
#include <Arduino.h> |
||||
|
#include <ESP8266WiFi.h> |
||||
|
|
||||
|
#include <Wire.h> |
||||
|
#include <SPI.h> |
||||
|
#include <Adafruit_Sensor.h> |
||||
|
#include <Adafruit_BMP085_U.h> |
||||
|
#include <DHT.h> |
||||
|
|
||||
|
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() { |
void setup() { |
||||
|
Serial.begin(115200); |
||||
pinMode(LED_BUILTIN, OUTPUT); |
pinMode(LED_BUILTIN, OUTPUT); |
||||
} |
} |
||||
|
|
||||
void loop() { |
void loop() { |
||||
digitalWrite(LED_BUILTIN, HIGH); |
sendValues(); |
||||
delay(1000); |
delay(postingInterval); |
||||
digitalWrite(LED_BUILTIN, LOW); |
|
||||
delay(1000); |
|
||||
} |
} |
||||
|
Loading…
Reference in new issue