Subtil Songeur in MATLAB Answers
上次活动时间: 2021-12-1

I get the data from my 2x dth11 (2x temp and 2x humidity) sensor and no error with this code, but thingspeak receved no data and i get only one loop. Any one see what wrong? #include <Ethernet.h> #include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros #include "DHT.h" #define DHT1PIN 10 // what pin we're connected to #define DHT2PIN 9 // Uncomment whatever type you're using! #define DHT1TYPE DHT11 // DHT 11 #define DHT2TYPE DHT11 // DHT 11 DHT dht1(DHT1PIN, DHT1TYPE); DHT dht2(DHT2PIN, DHT2TYPE); byte mac[] = { 0xDE, 0xAD, 0xBE, 0xXX, 0xXX, 0xXX }; // Set the static IP address to use if the DHCP fails to assign IPAddress ip(192, 168, X, XXX); IPAddress myDns(192, 168, X, X); EthernetClient client; unsigned long myChannelNumber = XXXXXX; const char * myWriteAPIKey = "XXXXXXXXXXXXXXX"; // Initialize our values int number1 = 0; int number2 = random(0,100); int number3 = random(0,100); int number4 = random(0,100); void setup() { Ethernet.init(10); // Most Arduino Ethernet hardware Serial.begin(115200); //Initialize serial while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo native USB port only } // start the Ethernet connection: Serial.println("Initialize Ethernet with DHCP:"); if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // Check for Ethernet hardware present if (Ethernet.hardwareStatus() == EthernetNoHardware) { Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :("); while (true) { delay(1); // do nothing, no point running without Ethernet hardware } } if (Ethernet.linkStatus() == LinkOFF) { Serial.println("Ethernet cable is not connected."); } // try to congifure using IP address instead of DHCP: Ethernet.begin(mac, ip, myDns); } else { Serial.print(" DHCP assigned IP "); Serial.println(Ethernet.localIP()); } // give the Ethernet shield a second to initialize: delay(1000); ThingSpeak.begin(client); // Initialize ThingSpeak Serial.println("DHT11 Fonctionnel"); dht1.begin(); dht2.begin(); } void loop() { // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float t1 = dht1.readTemperature(); float h1 = dht1.readHumidity(); float t2 = dht2.readTemperature(); float h2 = dht2.readHumidity(); // check if returns are valid, if they are NaN (not a number) then something went wrong! if (isnan(t1) || isnan(h1)) { Serial.println("Failed to read from DHT #1"); } else { Serial.print("Temperature entrée: "); Serial.print(t1); Serial.print(" *C "); Serial.print(" Humidity entrée: "); Serial.print(h1); Serial.println(" %\t"); } if (isnan(t2) || isnan(h2)) { Serial.println("Failed to read from DHT #2"); } else { Serial.print("Temperature sortie: "); Serial.print(t2); Serial.print(" *C "); Serial.print(" Humidity sortie: "); Serial.print(h2); Serial.println(" %\t"); } // set the fields with the values ThingSpeak.setField(1, dht1.readTemperature()); delay(10000); ThingSpeak.setField(2, dht1.readHumidity()); delay(10000); ThingSpeak.setField(3, dht2.readTemperature()); delay(10000); ThingSpeak.setField(4, dht2.readHumidity()); delay(10000); // write to the ThingSpeak channel // write to the ThingSpeak channel int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); if(x == 200){ Serial.println("Mise a jour du Canal."); } else{ Serial.println("Problem updating channel. HTTP error code " + String(x)); } // change the values number1++; if(number1 > 99){ number1 = 0; } number2 = random(0,100); number3 = random(0,100); number4 = random(0,100); delay(20000);// Wait 20 seconds to update the channel again }
Sendhoran Manokaran in MATLAB Answers
上次活动时间: 2020-4-26

Hi i am wondering isit possible for me to send multiple emails to different people? I have already been able to send an email to myself personally using the Matlab analysis but i was wondering if i could do this with other email addresses? What i mean is that if ,my data goes beyond a limit my React function notfies this data change and sends the MATLAB analysis portion to send an email to me and another personnal. Pls do tell me if this is possible and if so, please do tell me how this can be done Thank you

关于 ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.