Nu isses soweit - ich bin auch mitm Adruino angefangen. Mein allerserstes Bastelprojekt mit Mikrokontroller...
Ich habe mit beim Schinesen einen Leonardo Micro und einen SHT31 Temperatur- und Feuchtigkeitsmesser gekauft.
Zusammengetüdelt, noch eine LED an PIN4, von irgendwo eine Library und Testprogramm runtergeladen. Geht. Fast.
Mein Programm läuft, die LED geht an wenn der Taupunkt der gemessenen Luft unter 12°C liegt.
ABER NUR, WENN ICH IN DER IDE DEN SERIAL MONITOR STARTE. Bevor der Serial Monitor gestartet wird läuft das Programm nicht los.
Wenn ich den Arduino nur an 5V anschließe, läuft das Programm auch nicht los.
Was muß ich tun damit das Programm bei Power-Up von selbst losläuft ?
Hier das Programm :
/***************************************************
This is an example for the SHT31-D Humidity & Temp Sensor
Designed specifically to work with the SHT31-D sensor from Adafruit
---->
https://www.adafruit.com/products/2857
These sensors use I2C to communicate, 2 pins are required to
interface
****************************************************/
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"
float ttp = 0; // RK : Definition Variable für Taupunkt
int Fan = 4; // RK : Pin4 heisst Fan und schaltet Lüfter an/aus
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(9600);
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("SHT31 test");
if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr
Serial.println("Couldn't find SHT31");
while (1) delay(1);
}
pinMode(Fan, OUTPUT); //RK : PIN4 als Output = Schaltausgang
digitalWrite (Fan, LOW); // RK : Bei Programmstart Lüfter aus
}
void loop() {
float t = sht31.readTemperature();
float h = sht31.readHumidity();
ttp = t - (100-h)/5; // RK: Berechnung Taupunkt
if (! isnan(t)) { // check if 'is not a number'
Serial.print("Temp *C = "); Serial.println(t);
} else {
Serial.println("Failed to read temperature");
}
if (! isnan(h)) { // check if 'is not a number'
Serial.print("Hum. % = "); Serial.println(h);
Serial.print("Taupkt *C = "); Serial.println(ttp); // RK:Ausgabe Taupunkttemperatur
} else {
Serial.println("Failed to read humidity");
}
Serial.println();
if (ttp < 12) { // RK :Wenn Taupunkttemperatur <12 Grad C Lüfter an
digitalWrite (Fan, HIGH);}
else {digitalWrite (Fan, LOW);}
delay(1000);
}
Bitte um Anschub...
feuchte Grüße
RK