Arduino IOT Cloud

Hallo zusammen, ich bin leider "noch" kein Profi was die Programmiererei angeht. Dennoch habe ich es geschafft die IOT Cloud einzurichten und einen Code für einen BME280 einzubauen. Der Code wurde erfolgreich hochgeladen, ein Dashboard erstellt und mit den dazugehörigen Werten (Bsp.: float Luftdruck) verknüpft. Der Arduino UNO R4 WIFI wurde über die Cloud erfolgreich ins mein WLAN Netz eingebunden, der Code hochgeladen und der Sensor richtig über SDA und SCL, GND und 3V verkabelt. Ich kann es mir jedoch nicht erklären wieso mir keinerlei Werte ausgegeben werden. Anbei der von mir verwendete Code. Hat einer von euch eine hilfreiche Idee? Ich möchte es gerne wissen und daraus lernen. Vielen Dank und liebe Grüße.

#include "thingProperties.h"
#include "Wire.h"
#include "SPI.h"
#include "Adafruit_Sensor.h"
#include "Adafruit_BME280.h"

#define LuftdruckMeeresHoehe (1013.25)

Adafruit_BME280 bme;

int Wartezeit = 5000;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1000); 
  
  // I2C über SCL/SDA oder A5/A4
  if (!bme.begin()) {
    Serial.println("Kein BME280-Modul gefunden");
    while (true);
  } else {
    Serial.println("BME280-Modul gefunden");
  }

  Serial.println();

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  
  String Temperatur = String(bme.readTemperature());
  Temperatur.replace(".", ",");
  Serial.println("Temperatur: " + Temperatur + " °C");

  String Luftfeuchtigkeit = String(bme.readHumidity());
  Luftfeuchtigkeit.replace(".", ",");
  Serial.println("Luftfeuchtigkeit: " + Luftfeuchtigkeit + " %");

  String Luftdruck = String(bme.readPressure() / 100.0);
  Luftdruck.replace(".", ",");
  Serial.println("Luftdruck: " + Luftdruck + " hPa");

  String Hoehe = String(bme.readAltitude(LuftdruckMeeresHoehe));
  Hoehe.replace(".", ",");
  Serial.println("Ungefähre Höhe: " + Hoehe + " m");

  Serial.println();
  delay(Wartezeit);
}

Als erstes wurde versuchen ohne Cloud ob funktioniert der Beispiel aus der Lib. wen das Funktioniert dann weiter suchen.
Serieller Monitor auf 9600 einstellen.
Nutze keine Wolken aus einfachem Grund, lokal ist es schneller, wie lange die Cloud wird existieren weis keiner, Server Kosten Geld und das nicht wenig

/***************************************************************************
  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
  See the LICENSE file for details.
 ***************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {
    Serial.begin(9600);
    while(!Serial);    // time to get serial running
    Serial.println(F("BME280 test"));

    unsigned status;
    
    // default settings
    status = bme.begin();  
    // You can also pass in a Wire library object like &Wire2
    // status = bme.begin(0x76, &Wire2)
    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
        Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
        Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
        Serial.print("        ID of 0x60 represents a BME 280.\n");
        Serial.print("        ID of 0x61 represents a BME 680.\n");
        while (1) delay(10);
    }
    
    Serial.println("-- Default Test --");
    delayTime = 1000;

    Serial.println();
}


void loop() { 
    printValues();
    delay(delayTime);
}


void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" °C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");

    Serial.println();
}

Bei Wolle ist ein Beispiel wie man die nutzt. im Vergleich zum deinem Sketch ist er ganz anders keine Strings usw., viel Spaß :wink:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.