Francis Cote in MATLAB Answers
上次活动时间: 2024-1-5

Bonjour, J'essai d'utiliser un DHT11 et un capteur de sol.Seulement,le field1 et field2 s'affichent.Le capteur de solField3ne s'affiche pas. ///////////////////////////////// // Generated with a lot of love// // with TUNIOT FOR ESP8266 // // Website: Easycoding.tn // ///////////////////////////////// #include <ESP8266WiFi.h> #include "DHT.h" #include <ESP8266HTTPClient.h> WiFiClient client; DHT dht2(2,DHT11); String thingSpeakAddress= "http://api.thingspeak.com/update?"; String writeAPIKey; String tsfield1Name; String request_string; HTTPClient http; void setup() { Serial.begin(115200); WiFi.disconnect(); delay(3000); Serial.println("START"); WiFi.begin("xxxxxx","xxxxxx"); while ((!(WiFi.status() == WL_CONNECTED))){ delay(300); Serial.print(".."); } Serial.println("Connected"); Serial.println("Your IP is"); Serial.println((WiFi.localIP().toString())); } void loop() { if (client.connect("api.thingspeak.com",80)) { request_string = thingSpeakAddress; request_string += "key="; request_string += " 577YXKILO0SBRQFS"; request_string += "&field1="; request_string += (dht2.readTemperature( )); request_string += "&field2="; request_string += dht2.readHumidity( ); request_string += "&field3="; request_string += analogRead(A0); http.begin(request_string); http.GET(); http.end(); request_string=""; delay(15000); } Serial.println("Valeurs envoyees en principe"); Serial.println("Temperature"); Serial.println((dht2.readTemperature( ))); Serial.println("Humidity"); Serial.println((dht2.readHumidity( ))); Serial.println("Humidity Sol"); Serial.println(analogRead(A0)); delay(15000); }
manoj senapati in MATLAB Answers
上次活动时间: 2023-10-17

From last one month my thingspeak cloud account is not receiving data from my IoT node.Previously I had sent data, but suddenly it is not working. My id: manojsenapati@nist.edu
George in Discussions
上次活动时间: 2023-1-14

Hi there, I am using the following code in order to try and access th location of my device (via MATLAB visualization): myChannel=*******; ReadAPIKey='xxxxxxxxxxxxx'; myData=thingSpeakRead(myChannel,'ReadKey', ReadAPIKey,'numpoints',100,'outputformat','timetable','location',1); myVector=(myData.Latitude).^2+(myData.Longitude).^2+myData.Altitude.^2; maxVector=max(myData.Latitude)^2+max(myData.Longitude)^2+max(myData.Altitude)^2; myVector=myVector/maxVector; myMap=geoscatter(myData.lat,myData.long,15,myVector,'filled'); geobasemap('satellite'); colormap jet; At the moment, I have only 100 entries. However, I am getting the error : "Error using . Unrecognized table variable name 'lat'. Error in Custom (no starter code) 2 (line 7) myMap=geoscatter(myData.lat,myData.long,15,myVector,'filled');". How do i fix this error? Or where would i predefine "lat"? I do not want to set "lat" as a constant value as my device will be moving around and I want to access the location of the device per message sent, wherever it may be. Please may anyone assist. Location of a moving device, via MATLAB visualization You might try channel 876466 to practice reading data from. Its one of my channels with position data in it. I'm sorrry I didnt clean up the code I shared above. I had it and I wanted to share quickly but I didnt test it. Use myData.Latitude and myData.Longitude and you shouldnt get an error, assuming there is location data in the channel. To make sure there is position data in the channel, you have to use the format for the write REST call that I gave in the other post. The parameters for &latitude=xx and &longtitude=yy have to be written to the channel at least once. Every time you read the channel, you will get the most recent n points that show where your device is. There are a lot of ways to handle the changing number of entries. For one, when you read you can use a set time format parameter, such as days= or minutes=. Then thingspeak will retrurn as many points (up to 8k) that are in that time range. There are alse begin and end parameters, and you can use datatime manipulation to set rolling dates with your code. When you read the data, if you need to know the number of points, MATLAB has lots of functions to help with that (size, and height, for example) Another thing you can do is to increment a channel field witht he number of points, then read that channel value to know how many points there are. Hi there, thank you for this helpful reply. I adjusted the variable names and it seemed to be accepted. Upon searching for information about a REST api call, it said that i must search that call in my web's search bar. Is this the correct way to go about doing this? If not, what else would i do? Regarding the ways to handle changing the number of entries, I am slightly unsure on where to use "days=" or "minutes=" within that MATLAB visualization code which you sent previously.Where would I incorporate this in my code? Also, my aim is to solely see the location of the last message which has been sent, including indications of previous locations (the history of other locations). Would this be the best way to do this? Or is there another code which would do this best? If so, please may you share this code as i have struggled to do this and would greatly appreciate some assistance on this problem. Thank you Hi there Chris, please may you let me know if it is possible to show the location history of the device (thus the location of each of the messages recived) on Thingspeak? If it is possible, please may you guide me on how to do this. Thank you Can you clarify what you mean becasue I feel that was the question I already answered above. My aim is to show the location of each message that has ever been sent to the ThingSpeak channel. Such as the image attached below (an example from a Things.io channel). For each message recieved from my device, I want there to be a map and a pin at the precise location at which the message was sent. I am unsure on how to get the code above to do this. I am also still unsure on how to get the number of messages (the 260 or the 100 number in my case) to increase as the incoming messages increases. Also, I am unsure on how to connect the REST api call to the code. I did some research on it and it said to search the REST api call in your browser's search bar. However, this did not work. Please may you assist. Is there another way I could communicate with you, perhaps on email? Thank you for taking the time to describe your goal carefully. You say "show the location of each message that has ever been sent." If your device did not send its location, it is not possible for ThingSpeak to show you the location. Our service does not get the device location from the server if the device did not send the info. Does your device post its location data when it sends data to ThingSpeak? Is your device aware of its location? Support via email is available for holders of commercial or academic licenses. My dvice is sending information from Sigfox to Tingspeak. My Sigfox Atlas is enabled which allows the location of the device to be seen on Sigfox. This was my initial issue, which was how to send the location of my device from Sigfox to Thingspeak. I have a callback enabled on Sigfox's end which sends the "computedLocation" to my field4 of Thingspeak but nothing appears on Thingspeak's end (my goal here is to have a map showing the "computedLocation" from Sigfox), and this is why I think that I am sending the location from Sigfox incorrecly. Do you know how i could send the location from Sigfox to Thingspeak or any other way in which i could do this? I cannot find any resources which do this. Thanks Thats perfect, thanks for the clarification. I see that some of the info was in your earlier posts, but I didnt quite piece it all together. Can you show what the computed location on field 4 looks like - or can you share your channel ID if it is public? Is the data "lattitude,Longitude" or something like that? It might be easier if your callback from sigfox wrote the data into the lattitude and longitude fields, but we can also extract them form field 4 fairly easily too. Once you show me the data format, I can help you use the code above to read the last points in your channel. If you ask thingspeak for more data than you have, it will return the most recent data up to 8000 points. From what you said the problem about getting an increasing number of locations wont be a problem until you hit 8000. Lets get the map working first and then we can deal with the other issue. Yes I do see how my previous messages could have been confusing, but i really do appreciate all of your help. So on Sigfox this is the location which is being recorded (which is correct and quite precise). Following this, I attempted to make a callback following this blog (which uses thethings.io rather than Thingspeak) : https://blog.thethings.io/computedlocation-sigfox-and-visualize-on-a-map-your-devices/ . From this, I generated the following callback on Sigfox: But I do now recognize how this method could be incorrect since I have not recieved any information to do with location on Thingspeak's end.When I show field 4's visualization, it is a blank graph. This is how i know that I am not recieving anything from Sigfox with the above callback. However, since the link above is the only source that I can find which is doing what I aim to do, I am at a loss. Sigfox does have different variables which can be sent through a DATA-ADVANCED callback, which can be seen here: https://support.sigfox.com/docs/data-advanced . However, when I try to enter variables into the "Body" section of the callback, such as "computedLocation.lat", it says that "computedLocation.lat" is undefined and does not let me save the callback. I have also tried to see why this is the case but cannot find the solution. Thus, computedLocation was the variable which i have been attempting to pass to Thingspeak, as i imagine that once it is sent correclty, I will have access to a map on Thingspeak which illustrates the device's location per message sent, similar to the map above. This is a basically a summary of the root to my issue. I know that you have not worked with Sigfox so I really do appreciate your advice and guidance to solve this issue. I made my channel public so that you can see. My channel ID is 1970146 Thanks Im glad you redacted your API key, but I cant quite see the format you used. Is here any other field information in the URL pattern? Looking at your channel, there seems to be data getting in, was that data a result from the callback above? In the POST body, you should consider using field1=(some data) field3=(other data) field4={computedlocation} or something similar. Otherwise ThingSpeak wont know where you want to put the data. For the sigfox callback, I would consider using the body for your variables (like field4=) as in the JSON example here https://www.mathworks.com/help/thingspeak/writedata.html But I think the {computedlocation} question will have to go to sigfox, I'm sorry. Hi there Chris, thank you for your response. So from what I know, you set the field information in the "URL pattern" section of the Sigfox callback. The callback which is above was simply an attempt to get the {computedLocation} to send, the information which is showing on my page is a result of the callback below: So I set the URL pattern as https://api.thingspeak.com/update?api_key= XXXXXXXXXXXXX&field1={customData#temp}&field2={customData#t}&field3={customData#h} which thus sends information to the fields directly. The {computedLocation} is not sent from the Arduino code so that is why I didn't include it in this URL pattern and tried to create a separate callback for it. If this is not the best way to access location, is Thingspeak able to access the location of the incoming messages indpendently? Further, if this issue is beyond Thingspeak, I will go forward by attempting to ask Sigfox. Thank you! ThingSpeak does not have a way to localize message source. ITs too bad the callback cant access {computed location} becasue that would be a nice thing to write to ThingSpeak without having to add a GPS to your device. Please let us know if you figure out how to get the data from sigfox. I looked the their doc briefly and it seemed liek it should work close to how you had it above. I see. I will let you know when I manage to find a solution, thank you for all of your time and for your help, it was extremely helpful and is greatly appreciated! location dht11 arduino sigfox temperature humidity latitude longitude
George in Discussions
上次活动时间: 2022-12-18

Hi there, I am attempting to obtain a location history (thus the location of each of the previous messages recived) and the current location of my device on Thingspeak. I have not found any examples of how to do this on Thingspeak. Please may someone guide me or advise me on how to do this. Thank you Location history and current location mkr1200 arduino dht11 location sigfox
George in Discussions
上次活动时间: 2022-12-10

Hi there, I am trying to reach out to anyone who has successfully completed the project of building a weather station using an Arduino MKRFOX1200 board, a dht11 sensor across the Sigfox and Thingspeak networks. I’ve been attempting to build the weather station over the SigFox and things.io network for over a year now but I was unsuccessful. I then found this tutorial on how to build this using Thingspeak: https://create.arduino.cc/projecthub/masteruan/arduino-mkr-fox-1200-sigfox-meteo-station-423609 . I have now been attempting to build it using this network but am still unsuccessful. My SigFox and arduino is working. I made the arduino code convert temperature to Celsius (rather than Kelvin which is what the tutorial does). However, I am unable to access the location of the device on Thingspeak (my SigFox atlas is activated) and I am getting humidity values of approximately -30k. Please may someone assist me or give me a detailed approach on how to fix these issues. My goal is to have my thingspeak like this: https://thingspeak.com/channels/227248. I have followed the tutorial and projecthub but I cannot figure out why I am obtaining a confusing humidity reading. Please please may someone help. Thank you so much for your time. Weather station using dht11 sensor, Thingspeak and Sigfox This sounds like a hardware problem more than a ThingSpeak problem. You could try the projecthub if they have a forum or perhaps Arduino, though that is a stretch again since the problem seems to be with the sensor. I recomend drastic simplification. Write a program to read the sensor from your Arduino and output it to the serial monitor. Once you have that working, add another layer of complexity one at a time. Hi there, that makes sense, I will do that, thank you. However, I also wanted to know if you knew how to sned the location of the device per reading from Sigfox to Thingspeak (my Sigfox Atlas is enabled). I have found sources to do this with thethings.io but i am unsure on how to do it using thingspeak. When i try to do the "channel location" option on thingspeak, it gives me a default poaition og Lat.=0 and Long.=0. However, on my "device" tab on Sigfox, i can see a pretty accurate computed location of where my device is. How do I send this to Thingspeak? I am unsure on how to create a callback for this. Please may you assist if you can. Thank you The channel location is the base location of the device, such as your business or home. The device location parameters are in the channel feed data. See the Write data documentation for the parameters. https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=10&lat=40.2&long=50.1&elevation=200 Here is code to create a map from that data. You can create a MATLAB visualization to run this code and add it to your channel. Note the change from the word alititude to elevation. I modified this code from a different application, so if you get errors please let me know so I can fix it. myChannel=999999999999999; ReadAPIKey='xxxxxxxxxxxxxxxx'; myData=thingSpeakRead(myChannel,'ReadKey', ReadAPIKey,'numpoints',260,'outputformat','timetable','location',1); myVector=(myData.Latitude).^2+(myData.Longitude).^2+myData.Altitude.^2; maxVector=max(myData.Latitude)^2+max(myData.Longitude)^2+max(myData.Altitude)^2; myVector=myVector/maxVector; myMap=geoscatter(myData.lat,myData.long,15,myVector,'filled'); geobasemap('satellite'); colormap jet; %ax=gca; %ax.ZoomLevel=15; %probably dont need this since scale is set above Thank you very much for this helpful response. Will this line of code (https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=10&lat=40.2&long=50.1&elevation=200) be the Sigfox callback? Also, when running the MATLAB visualization code, i get the following error: "Channel ID must be a positive integer." . However, I do not see where my Channel ID is being used (nor where it could be a negative or not an integer). How could i ammend this? Or where is it reading my channel ID? Sorry, I've never used Sigfox, I probably should check it out. If you find out, please let us know. Regarding the error the channel ID is the first line in the code. The channel ID must exist. myChannel=999999999999999; Channel 999999999999999 does not exist. Change it to your channel ID. Also be sure to change the Read API key. So where would the line: "https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=10&lat=40.2&long=50.1&elevation=200" be used? As previously I would have assumed it to be a SigFox callback And I see, thank you. I got this error: "Warning: 'Unable to read 260 points as requested. Only 68 points available in the channel. Error using . Unrecognized table variable name 'lat'." Where could I change the number of points? Would it affect the output? Also, where can i define the variable "lat"? sigfox thingspeak mkrfox1200 dht11 location arduino humidity weather station
Adeola in MATLAB Answers
上次活动时间: 2022-4-14

Hello! I'd like to know if Proteus 8 Professional simulation can send sensor data directly to Thingspeak cloud without any hardware implementation and how to do that. Thank you!
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 }
Mufudzi Moses Tembo in Discussions
上次活动时间: 2021-9-21

Kindly assist I have been trying to create a small weather station with with DHT11 sensor and CC3200 launchpad and connect it to ThingSpeak but the code won't compile as I am using an Arduino code. Anyone to please help if true #include <SPI.h> #include <WiFi.h> #include <WiFiClient.h> #include <DHT.h> // Including library for dht String apiKey = ""; // Enter your Write API key from ThingSpeak const char *ssid = "Virus"; // replace with your wifi ssid and wpa2 key const char *pass = ""; const char* server = "api.thingspeak.com"; #define DHTPIN 11 //pin where the dht11 is connected #define DHT dht(DHTPIN, DHT11); WiFiClient client; void setup() { Serial.begin(115200); delay(10); dht.begin(); Serial.println("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); } void loop() { float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com { String postStr = apiKey; postStr +="&field1="; postStr += String(t); postStr +="&field2="; postStr += String(h); postStr += "\r\n\r\n"; client.print("POST /update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n"); client.print("Connection: close\n"); client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr); Serial.print("Temperature: "); Serial.print(t); Serial.print(" degrees Celcius, Humidity: "); Serial.print(h); Serial.println("%. Send to Thingspeak."); } client.stop(); Serial.println("Waiting..."); // thingspeak needs minimum 15 sec delay between updates delay(1000); } end Interfacing CC3200 Launchpad With ThingSpeak We recommend using the <https://github.com/mathworks/thingspeak-arduino ThingSpeak communication library>. It takes care of most of the communication issues with the server. You can download it in the Arduino IDE, and then use the examples from the library to build your code. Please change this line right away // thingspeak needs minimum 15 sec delay between updates delay(1000); That delay is only 1 second, not 15 seconds, as the comment says. If you are a free user, you will be rejected in the server 14 times for each accepted update. This is wasteful of our resources, and may cause you to be blocked if it goes on too long. Also, you are listing the static IP address. I'm glad you aren't actually using it, but it will be deprecated in the future, so I would definitely nor recommend having it in your code. Start with something really simple and build from there. For example, use one of the examples to just write a static value to ThingSpeak and then build on that. You might even start by making sure you can update your channel using a web browser. Look on the API keys tab of your channel for the right syntax. Is it possible to use Texas Instruments CC3200 Launchpad and Energia IDE instead of Arduino ? I did find an HTTP library for the CC3200, so I am sure it is possible to connect to ThingSpeak. The ThingSpeak library does not support this device, but you can still write your own interface. cc3200 dht11 arduino
Md. Najmul Hasan in MATLAB Answers
上次活动时间: 2021-5-25

i am using arduino mega and esp 01.i am getting reading on serial monitor.but thingspeak shows 0 for 5 sensors data fields.where is the problem in this code please help me. Esp 01 code- #include "ThingSpeak.h" #include <ESP8266WiFi.h> char ssid[] = "xxxxxxx"; // SSID here char pass[] = "xxxxxxxx"; // Passowrd here unsigned long Channel_ID = xxxxxx; // Channel ID const char * myWriteAPIKey = "xxxxxxxx"; // Write API key const int Field_Number_1 = 1; const int Field_Number_2 = 2; const int Field_Number_3 = 3; const int Field_Number_4 = 4; const int Field_Number_5 = 5; String value = ""; int value_1 = 0, value_2 = 0, value_3 = 0, value_4 = 0, value_5 = 0; WiFiClient client; void setup() { Serial.begin(115200); WiFi.mode(WIFI_STA); ThingSpeak.begin(client); internet(); } void loop() { internet(); if (Serial.available() > 0) { delay(100); while (Serial.available() > 0) { value = Serial.readString(); if (value[0] == '*') { if (value[11] == '#') { value_1 = ((value[1] - 0x30) * 10 + (value[2] - 0x30)); value_2 = ((value[3] - 0x30) * 10 + (value[4] - 0x30)); value_3 = ((value[5] - 0x30) * 10 + (value[6] - 0x30)); value_4 = ((value[7] - 0x30) * 10 + (value[8] - 0x30)); value_5 = ((value[9] - 0x30) * 10 + (value[10] - 0x30)); } } } } upload(); } void internet() { if (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) { WiFi.begin(ssid, pass); delay(5000); } } } void upload() { ThingSpeak.writeField(Channel_ID, Field_Number_1, value_1, myWriteAPIKey); delay(15000); ThingSpeak.writeField(Channel_ID, Field_Number_2, value_2, myWriteAPIKey); delay(15000); ThingSpeak.writeField(Channel_ID, Field_Number_3, value_3, myWriteAPIKey); delay(15000); ThingSpeak.writeField(Channel_ID, Field_Number_4, value_4, myWriteAPIKey); delay(15000); ThingSpeak.writeField(Channel_ID, Field_Number_5, value_5, myWriteAPIKey); delay(15000); value = ""; } arduino code- #include <dht.h> #define soilWet 56 #define soilDry 50 const int LM35 = A0; // Soil Temperature pin // lowest and highest sensor readings (Rain Detection) const int sensorMin = 0; // sensor minimum const int sensorMax = 1024; // sensor maximum #define sensorPower 5 // Motor pin int obstaclePin = 10; // IR sensor pin 7 int hasObstacle = HIGH; // High means no obstacle const int trigger = 34; const int echo = 35; long T; float distanceCM; dht DHT; #define DHT11_PIN 30 int humi,temp; void setup(){ pinMode(sensorPower, OUTPUT); // Initially keep the Motor OFF digitalWrite(sensorPower, HIGH); pinMode(obstaclePin, INPUT); pinMode(trigger, OUTPUT); pinMode(echo, INPUT); Serial.begin(9600); } void loop() { int moisture = (100 - ((analogRead(A1)/1023.00)*100)); digitalWrite(trigger, LOW); delay(10); digitalWrite(trigger, HIGH); delayMicroseconds(10); digitalWrite(trigger, LOW); T = pulseIn(echo, HIGH); distanceCM = T * 0.034; distanceCM = distanceCM / 2; int ADC; float tempS; ADC = analogRead(LM35); tempS = (ADC * 4.88); tempS = (tempS / 10); int sensorReading = analogRead(A2); // Rain detection pin A2 int range = map(sensorReading, sensorMin, sensorMax, 0, 3); // Rain detection switch (range) { case 0: // Sensor getting wet Serial.println("Rain Status : ***Raining***"); break; case 1: // Sensor getting wet Serial.println("Rain Status : **Rain Warning**"); break; case 2: // Sensor dry - To shut this up delete the " Serial.println("Not Raining"); " below. Serial.println("Rain Status : *Not Raining*"); break; } DHT.read11(DHT11_PIN); humi=DHT.humidity; temp=DHT.temperature; Serial.print("Air Temperature = "); Serial.print(temp); Serial.println("°C "); Serial.print("Air Humidity = "); Serial.print(humi); Serial.println(" %"); Serial.print("Distance = "); Serial.print(distanceCM); Serial.println("cm"); Serial.print("Soil Temperature = "); Serial.print(tempS); Serial.println("°C"); Serial.print("Soil Moisture = "); Serial.print(moisture); Serial.println(" %"); if (moisture < soilWet) { Serial.println("Status: Soil is too wet"); } else if (moisture >= soilWet && moisture < soilDry) { Serial.println("Status: Soil moisture is perfect"); } else { Serial.println("Status: Soil is too dry - time to water!"); } if (moisture < 35) { digitalWrite(sensorPower, HIGH); // turn ON motor Serial.println("Motor is ON"); } if (moisture > 35 && moisture < 37) { digitalWrite(sensorPower, HIGH); //turn ON motor Serial.println("Motor is ON"); } if (moisture > 38) { digitalWrite(sensorPower, LOW); // turn OFF motor Serial.println("Motor is OFF"); } hasObstacle = digitalRead(obstaclePin); //Reads the output of the obstacle sensor from the 7th PIN of the Digital section of the arduino if (hasObstacle == LOW) //LOW means something is ahead { Serial.println("Something is ahead !!!"); } else { Serial.println("Path is clear"); } Serial.println("--------------------------------------------------------------------------"); Serial.println(""); delay(3000); }
Alex Miranda in File Exchange
上次活动时间: 2021-3-22

Código Arduino para funcionamento da EMS Guamá
Pankaj Thakur in MATLAB Answers
上次活动时间: 2020-7-25

Using a Nod-Red flow on my raspberry pi 3b+ model running on Rasbian, I setup a DHT11 sensor to send Temperatrure and Humidity values to first and second field of my channel on Thingspeak after every 10 minutes. But it is only uploading Temperature value or Humidity value at a time. Both are not updated.

关于 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.