Gast
#6203585
Hallo, bräuchte Bitte hilfe beim Programmieren von Arduino sketch für DHT /HX711 mit Thingspeak verbindung. DHT sketch habe ich soweit geschafft zu Programmieren mit Thingspeak verbindung: #include <DHT.h> #include <HX711.h> #include <ThingSpeak.h> #include <ESP8266WiFi.h> #define DHTTYPE DHT21 #define DHTPIN 12 WiFiClient client; const char *ssid = "FRITZ!Box 7430 XX"; // Your wifi ssid const char *password = "xxxx455929745151"; //Your wifi password unsigned long myChannelNumber = xxxxxx; const char * myWriteAPIKey = "xxxxxxxxxxxxxx"; const char* server = "api.thingspeak.com"; DHT dht(DHTPIN, DHTTYPE); void updateThingSpeak(float t, float h){ ThingSpeak.setField(1,t); ThingSpeak.setField(2,h); ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey); delay(20*1000); } void setup() { // put your setup code here, to run once: Serial.begin(115200); dht.begin(); ThingSpeak.begin(client); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("waiting for wifi to be connected"); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } void loop() { // put your main code here, to run repeatedly: delay(2000); float h = dht.readHumidity(); //celcius float t = dht.readTemperature(); //fahrenheit float f = dht.readTemperature(true); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celcius float hic = dht.computeHeatIndex(t, h, false); Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hic); Serial.print(" *C "); Serial.print(hif); Serial.println(" *F"); if(client.connect(server,80)){ updateThingSpeak(t,h); } } Meine HX711 sketch habe ich Programmiert und Kalibriert läuft auch alles. Habe nur ein problem das ich den HX711 sketch nicht in den DHT mit Thingspeak impletieren kann. Bin leider noch ein Anfänger. Könnte mir Bitte vielleicht einer helfen den HX711 in den DHT sketch zu impletieren ? #include "HX711.h" #define calibration_factor 20966.9 #define zero_factor 354555 #define LOADCELL_DOUT_PIN 5 #define LOADCELL_SCK_PIN 4 HX711 scale; void setup() { Serial.begin(9600); Serial.println("Demo "); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); scale.set_scale(calibration_factor); scale.set_offset(zero_factor); Serial.println("Readings:"); } void loop() { Serial.print("Reading: "); Serial.print(scale.get_units(), 2); Serial.print(" gramm"); Serial.println(); } Würde mich sehr freuen für eure Hilfe. Komme einfach nicht weiter damit. Danke