Simple Weather Station with Amazing Web Monitoring

Hallo liebe Forum Gemeinde ich hab ein kleines Problem mit diesem Code hier ich hoffe ihr könnt mir helfen

/***************************************************************************
This is a library for the BME280 humidity, temperature & pressure sensor

Designed specifically to work with the Adafruit BME280 Breakout
----> LED Magician [v2.0] : ID 2650 : $39.95 : Adafruit Industries, Unique & fun DIY electronics and kits

These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface. The device's I2C address is either 0x76 or 0x77.

Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!

Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/

/*

  • Sensor connection:
  • BME280 GND --> NodeMCU GND
  • BME280 3.3V --> NodeMCU 3V3
  • BME280 SDA --> NodeMCU D2
  • BME280 SCL --> NodeMCU D1
    */

#include <Wire.h>

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// Wi-Fi settings
const char* ssid = "YOUR-SSID";
const char* password = "YOUR-PASSWORD";

// Sensor settings
const uint8_t sensor_address = 0x76;

// Corlysis Setting - click to the database to get those info
const char* db_name = "YOUR-DB_NAME";
const char* db_password = "YOUR-DB-PASSWORD";
const unsigned long delayTimeMs = 10000;

Adafruit_BME280 bme;
HTTPClient http;

void setup() {
Serial.begin(9600);
Serial.println("NodeMCU + BME280 + Corlysis");

bool status;

// you can also pass in a Wire library object like &Wire2
status = bme.begin(sensorAddress); hier
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}

delay(100); // let sensor boot up

//Wi-Fi connection
Serial.print("Connecting to the: ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}

Serial.println();
Serial.println("WiFi connected.");
Serial.print("My IP address: ");
Serial.println(WiFi.localIP());

}

void loop() {
// read data from sensor
float temperature = bme.readTemperature();
//temperature = 9.0/5.0 * temperature + 32.0;
float pressure = bme.readPressure();
float humidity = bme.readHumidity();

sendDataToCorlysis(temperature, pressure, humidity);

delay(delayTimeMs);
}

void sendDataToCorlysis(float temperature, float pressure, float humidity) {
static long counter = 0;

char payloadStr[150];
sprintf(payloadStr, "bme280_data temperature=%d.%02d,pressure=%d.%02d,humidity=%d.%02d", (int)temperature, (int)abs(temperature100)%100,
(int)pressure, (int)abs(pressure
100)%100, (int)humidity, (int)abs(humidity*100)%100);
Serial.println(payloadStr);

char corlysisUrl[200];
sprintf(corlysisUrl, "http://corlysis.com:8087/write?db=%s&u=token&p=%s", dbName, dbPassword); hier
http.begin(corlysisUrl);
//HTTPS variant - check ssh public key fingerprint
//sprintf(corlysisUrl, "https://corlysis.com:8086/write?db=%s&u=token&p=%s", dbName, dbPassword);
//http.begin(corlysisUrl, "FF:2D:E9:25:75:39:D1:A0:5C:99:02:34:EF:81:73:0F:3F:3E:2D:0D");

http.addHeader("Content-Type", "application/x-www-form-urlencoded");
int httpCode = http.POST(payloadStr);
Serial.print("http result:");
Serial.println(httpCode);
http.writeToStream(&Serial);
http.end();

if(httpCode == 204) {
counter = 0;
Serial.println("Data successfully sent.");
}else{
if(counter > 10 && httpCode == -1) {
Serial.println("WiFi: still not connected -> reboot.");
WiFi.forceSleepBegin(); wdt_reset(); ESP.restart(); while(1)wdt_reset();
}
counter++;
Serial.println("Data were not sent. Check network connection.");
}
Serial.println("");
}

Ich hoffe ihr könnt mir da helfen hier ist der Link (Simple Weather Station with Amazing Web Monitoring - Hackster.io )von der Seite wo ich den her hab ich wollte das kleine Projekt gerne fertig bekommen der Fehler lautet error: 'dbName' was Not declared in this Scope und das selbe mit der sensoradress
Dort wo hier steht sind die Fehler enstanden
Bitte hilft mir :confused:

sensor_address ist was anderes als sensorAddress

Code bitte als Code, Links als Links (nicht einfach den url-Text) posten.

So gerade mal getestet das mit dem sensor_adress kommt auch der selbe Fehler

tommy89:
So gerade mal getestet das mit dem sensor_adress kommt auch der selbe Fehler

Zusätzlich zum Test hättest Du auch den Code im OP in Code-Tags fassen und URLs in klickbare Links ändern können.

Vergessen? Das wäre eine freundliche Geste.

Gruß

Gregor

Hi

Würde ich zumindest So versuchen.

Die Variablen müssen schon genau so heißen, wie Du Diese erstellt hast.
a ist was Anderes als _a - wäre auch blöd, wenn nicht!

MfG

PS:
klappt nicht
und
kommt der selbe Fehler
sind nicht wirklich hilfreich - WAS für ein Fehler kommt WO?
Hättest Du den Sketch in Code-Tags, die Libraries verlinkt oder zumindest bei geschrieben, welche Version Du benutzt, könnte man Das ja Mal antesten.
So ist Es nur Stochern im Nebel.

Wie bekomme ich d3n Code als Code hier gepostet wäre nett wenn du mir da grade helfen kannst ich schreibe hier von einem Tablet Danke im voraus

Ich benutze die IDE 1.8.12

tommy89:
Wie bekomme ich d3n Code als Code hier gepostet wäre nett wenn du mir da grade helfen kannst ich schreibe hier von einem Tablet Danke im voraus

Die Quote-Tags erzeugst Du im Editor durch einen Klick auf das Symbol

Einen klickbaren Link erzeugst Du so: URL markieren und in die Zwischenablage kopieren (Strg-C). Dann das Link-Symbol klicken, Strg-V drücken und zweimal auf OK klicken.

Das Link-Symbol sieht so aus:

Gruß

Gregor

Ok danke :smiley:

Ich kenne das Programm nicht, mit dem Du zu tun hast und habe auch nicht nachgeguckt, wo Du den Code her hast.

Hinsichtlich dbName fällt mir aber ein: Es werden dort wo der Fehler angezeigt wird, wohl Zugangsdaten verlangt. Probiere mal, dort statt dbName und dbPassword etwas anzugeben wie

"LOGIN", "PASSWORT"

Du musst dort natürlich die tatsächlich nötigen Zugangsdaten angeben, gell.

Gruß

Gregor

Ja das kam mir auch schon in den Sinn aber leider mit dem selben Ergebnis :confused:

Hier mal der Link

Da steht aber auch, dass Du eine corlysis-Datenbank brauchst, was immer das ist.

Hast Du dort schon Deine Datenbank eingerichtet? Dann müsstest Du ja die Zugangsdaten haben, wenn nein, solltest Du das tun.

Gruß Tommy

tommy89:
Hier mal der Link
Simple Weather Station with Amazing Web Monitoring - Hackster.io

Der Code auf Github unterscheidet sich von dem, der auf der Webseite abgebildet ist. Arbeite mit dem Sketch, der direkt auf der Webseite genannt ist:

/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor
  Designed specifically to work with the Adafruit BME280 Breakout
  ----> http://www.adafruit.com/products/2650
  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.
  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!
  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/

/*
 * Sensor connection:
 * BME280 GND --> NodeMCU GND
 * BME280 3.3V --> NodeMCU 3V3
 * BME280 SDA --> NodeMCU D2
 * BME280 SCL --> NodeMCU D1
 */


#include <Wire.h>

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// Wi-Fi settings
const char* ssid = "YOUR-SSID";
const char* password = "YOUR-PASSWORD";

// Sensor settings
const uint8_t sensor_address = 0x76;

// Corlysis Setting - click to the database to get those info
const char* db_name = "YOUR-DB_NAME";
const char* db_password = "YOUR-DB-PASSWORD";
const unsigned long delayTimeMs = 10000;


Adafruit_BME280 bme;
HTTPClient http;


void setup() {
    Serial.begin(9600);
    Serial.println("NodeMCU + BME280 + Corlysis");

    bool status;
    
    // you can also pass in a Wire library object like &Wire2
    status = bme.begin(sensorAddress);  
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
    }
    
    delay(100); // let sensor boot up

    //Wi-Fi connection
    Serial.print("Connecting to the: ");
    Serial.println(ssid);
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
    
    while (WiFi.status() != WL_CONNECTED) {
        delay(100);
        Serial.print(".");
    }

    Serial.println();
    Serial.println("WiFi connected.");
    Serial.print("My IP address: ");
    Serial.println(WiFi.localIP());
    
}


void loop() {
    // read data from sensor
    float temperature = bme.readTemperature();
    //temperature = 9.0/5.0 * temperature + 32.0;
    float pressure = bme.readPressure();
    float humidity = bme.readHumidity();

    sendDataToCorlysis(temperature, pressure, humidity);
    
    delay(delayTimeMs);
}


void sendDataToCorlysis(float temperature, float pressure, float humidity) {
    static long counter = 0;
    
    char payloadStr[150];
    sprintf(payloadStr, "bme280_data temperature=%d.%02d,pressure=%d.%02d,humidity=%d.%02d", (int)temperature, (int)abs(temperature*100)%100, 
    (int)pressure, (int)abs(pressure*100)%100, (int)humidity, (int)abs(humidity*100)%100);
    Serial.println(payloadStr);
    
    char corlysisUrl[200];
    sprintf(corlysisUrl, "http://corlysis.com:8087/write?db=%s&u=token&p=%s", dbName, dbPassword);
    http.begin(corlysisUrl);
    //HTTPS variant - check ssh public key fingerprint
    //sprintf(corlysisUrl, "https://corlysis.com:8086/write?db=%s&u=token&p=%s", dbName, dbPassword);
    //http.begin(corlysisUrl, "92:23:13:0D:59:68:58:83:E6:82:98:EB:18:D7:68:B5:C8:90:0D:03");
    
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");  
    int httpCode = http.POST(payloadStr);
    Serial.print("http result:");
    Serial.println(httpCode);
    http.writeToStream(&Serial);
    http.end();

    if(httpCode == 204) {
        counter = 0;
        Serial.println("Data successfully sent.");
    }else{
        if(counter > 10 && httpCode == -1) {
            Serial.println("WiFi: still not connected -> reboot.");
            WiFi.forceSleepBegin(); wdt_reset(); ESP.restart(); while(1)wdt_reset();
        }
        counter++;
        Serial.println("Data were not sent. Check network connection.");
    }
    Serial.println("");  
}

Da hat offensichtlich mal wieder einer einen Code geändert, ohne ihn danach zu testen. Bei Github treibt sich ja seltsamess Volk herum ... es beginnt zu müffeln.

Gruß

Gregor

/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor
  Designed specifically to work with the Adafruit BME280 Breakout
  ----> http://www.adafruit.com/products/2650
  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.
  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!
  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ***************************************************************************/

/*
 * Sensor connection:
 * BME280 GND --> NodeMCU GND
 * BME280 3.3V --> NodeMCU 3V3
 * BME280 SDA --> NodeMCU D2
 * BME280 SCL --> NodeMCU D1
 */


#include <Wire.h>

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// Wi-Fi settings
const char* ssid = "YOUR-SSID";
const char* password = "YOUR-PASSWORD";

// Sensor settings
const uint8_t sensor_address = 0x76;

// Corlysis Setting - click to the database to get those info
const char* db_name = "YOUR-DB_NAME";
const char* db_password = "YOUR-DB-PASSWORD";
const unsigned long delayTimeMs = 10000;


Adafruit_BME280 bme;
HTTPClient http;


void setup() {
    Serial.begin(9600);
    Serial.println("NodeMCU + BME280 + Corlysis");

    bool status;
    
    // you can also pass in a Wire library object like &Wire2
    status = bme.begin(sensorAddress);  
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
    }
    
    delay(100); // let sensor boot up

    //Wi-Fi connection
    Serial.print("Connecting to the: ");
    Serial.println(ssid);
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
    
    while (WiFi.status() != WL_CONNECTED) {
        delay(100);
        Serial.print(".");
    }

    Serial.println();
    Serial.println("WiFi connected.");
    Serial.print("My IP address: ");
    Serial.println(WiFi.localIP());
    
}


void loop() {
    // read data from sensor
    float temperature = bme.readTemperature();
    //temperature = 9.0/5.0 * temperature + 32.0;
    float pressure = bme.readPressure();
    float humidity = bme.readHumidity();

    sendDataToCorlysis(temperature, pressure, humidity);
    
    delay(delayTimeMs);
}


void sendDataToCorlysis(float temperature, float pressure, float humidity) {
    static long counter = 0;
    
    char payloadStr[150];
    sprintf(payloadStr, "bme280_data temperature=%d.%02d,pressure=%d.%02d,humidity=%d.%02d", (int)temperature, (int)abs(temperature*100)%100, 
    (int)pressure, (int)abs(pressure*100)%100, (int)humidity, (int)abs(humidity*100)%100);
    Serial.println(payloadStr);
    
    char corlysisUrl[200];
    sprintf(corlysisUrl, "http://corlysis.com:8087/write?db=%s&u=token&p=%s", dbName, dbPassword);
    http.begin(corlysisUrl);
    //HTTPS variant - check ssh public key fingerprint
    //sprintf(corlysisUrl, "https://corlysis.com:8086/write?db=%s&u=token&p=%s", dbName, dbPassword);
    //http.begin(corlysisUrl, "92:23:13:0D:59:68:58:83:E6:82:98:EB:18:D7:68:B5:C8:90:0D:03");
    
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");  
    int httpCode = http.POST(payloadStr);
    Serial.print("http result:");
    Serial.println(httpCode);
    http.writeToStream(&Serial);
    http.end();

    if(httpCode == 204) {
        counter = 0;
        Serial.println("Data successfully sent.");
    }else{
        if(counter > 10 && httpCode == -1) {
            Serial.println("WiFi: still not connected -> reboot.");
            WiFi.forceSleepBegin(); wdt_reset(); ESP.restart(); while(1)wdt_reset();
        }
        counter++;
        Serial.println("Data were not sent. Check network connection.");
    }
    Serial.println("");  
}

Den hab ich ja in der ide drin der von der Webseite und ja ich hab dort eine Database bei corlysis dort kann man sich die Daten als plott darstellen lassen

Das paßt nicht zusammen:

const char* db_name = "YOUR-DB_NAME";
const char* db_password = "YOUR-DB-PASSWORD";
...
sprintf(corlysisUrl, "http://corlysis.com:8087/write?db=%s&u=token&p=%s", dbName, dbPassword);

tommy89:
Wie bekomme ich d3n Code als Code hier gepostet wäre nett wenn du mir da grade helfen kannst ich schreibe hier von einem Tablet Danke im voraus

Evtl. einfach mal lesen: How to use this forum - please read - Deutsch - Arduino Forum

@agmue:

Biste so nett und könntest du mir das passend machen das wäre sehr nett

Bitte :smiley:

Den hab ich ja in der ide drin der von der Webseite und ja ich hab dort eine Database bei corlysis dort kann man sich die Daten als plott darstellen lassen

Ups, da habe ich mich verguckt.

Naja, jedenfalls sind im Code die Namen einer Variable unterschiedlich geschrieben: einmal db_name, einmal dbName.

Gleiche das mal an, dann sollte zumindest dieser Fehler verschwinden.

Gruß

Gregor

Perfekt hab's Fehler weg super ihr seid die besten Danke