Ich habe mir eine Wetterstation gebaut, die die Daten über die IOT Cloud übermittelt.
Mein Programm kann ich ohne Probleme hochladen und über den Seriellen Monitor werden mir die Daten angezeigt, auch über das Dashboard werden die Daten zunächst angezeigt.
Nach ca. 3 Stunden (nie wirklich auf die genaue Zeit geachtet) werden keine neuen Daten mehr an die IOT Cloud übermittelt, auch wenn das Board dort als online angezeigt wird.
Meine aktuelle Lösung ist es das Programm immer wieder neu aufzuspielen. Das ist ja aber auch keine Lösung ... ich weiß auf jeden Fall nicht mehr weiter.
Kann mir jemand helfen dieses Problem zu lösen?
hier ist mein Code:
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/15f4fa14-2298-4c75-aba6-40e17ee54ea2
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float luftdruck;
CloudTemperatureSensor temperatur;
CloudIlluminance helligkeit;
int buttonPushCounter;
int buttonState;
int lastButtonState;
int luftfeuchtigkeit;
int regenSen;
CloudVolume regenmenge;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include <ArduinoIoTCloud.h>
#include "thingProperties.h"
#include <BH1750.h>
#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;
BH1750 lightMeter;
#include "RTClib.h"
RTC_DS3231 rtck;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// 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();
Wire.begin();
pinMode(2, INPUT);
lightMeter.begin();
Serial.println(F("BH1750 Test"));
while (!Serial); // time to get serial running
Serial.println(F("BME280 test"));
unsigned status;
// default settings
status = bme.begin(0x77);
// 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();
#ifndef ESP8266
while (!Serial); // wait for serial port to connect. Needed for native USB
#endif
#ifndef ESP8266
while (!Serial); // wait for serial port to connect. Needed for native USB
#endif
if (! rtck.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
Serial.println("Setting the time...");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtck.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
void loop() {
ArduinoCloud.update();
// Your code here
// read the pushbutton input pin:
buttonState = digitalRead(2);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button went from off to on:
buttonPushCounter++;
}
}
// Delay a little bit to avoid bouncing
delay(50);
regenmenge = buttonPushCounter * 0.45;
delay(50);
DateTime now = rtck.now();
if (now.hour() == 22) {
if (now.minute() == 1) {
if (now.second() == 1){
buttonPushCounter = 0;
}
}
}
delay(50);
luftdruck = bme.readPressure() / 100.0F;
luftfeuchtigkeit = bme.readHumidity() ;
temperatur = bme.readTemperature();
helligkeit = lightMeter.readLightLevel();
float lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
delay(50);
printValues();
delay(50);
Serial.println("--------------------");
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC );
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.println(now.second(), DEC);
delay(50);
Serial.print("heutige Regenmenge: ");
Serial.print(regenmenge);
Serial.println(" l");
}
void printValues() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" °C");
delay(50);
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
delay(50);
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
delay(50);
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
delay(50);
Serial.println();
Serial.println();
}

