Rishikesh in Discussions
上次活动时间: 2024-8-24

I am creating an ESP32 device which will upload data to thingspeak channel and I want the data to be displayed on my website after login. I have succesfully completed the first part of uploading the data to thingspeak. Any suggestions with second part will be very much appreciated. How to create an IOT dashboard on my website using data uploaded to thingspeak. Check out these three resources in the doc. Embed Your ThingSpeak Plots on Web Pages You can use your ThingSpeak plot that updates automatically on any website. Embed a Chart Embed ThingSpeak charts on a custom website. Create Customized ThingSpeak Channel View Convert the ThingSpeak channel view into a live data console. In addition to @Christopher Stapels suggestions, and anticipating your next question, I'd recommend looking through this answer on creating a dashboard aggregating views from multiple ThingSpeak channels. esp32 thingspeak iot dashboard thingspeak
Emir in MATLAB Answers
上次活动时间: 2024-5-14

We have a project and we have this eror code. We can only send temprature but we need to send more data to thingspeak . We dont know what to do please help us.
Andrés in MATLAB Answers
上次活动时间: 2024-5-14

Espero puedan ayudarme por favor, explico mi problema, en este momento estoy manejando una ESP32 mediante Arduino, que conectado con un sensor de movimiento, envíe notificaciones a Telegram y a su vez, necesito que envíe datos a ThingSpeak, he hecho todo lo posible, pero cuando va a enviar la información a ThingSpeak, aparece el error -301 en el monitor serial, dejaré el código para ver si me pueden ayudar, agradezco su ayuda. Quisiera clarar que no es problema de red ya que lo he intentado con diferentes redes locales, gracias. #include <WiFi.h> #include <WiFiClientSecure.h> #include <UniversalTelegramBot.h> #include <ArduinoJson.h> #include <ThingSpeak.h> const char* ssid = "******"; const char* password = "*******"; #define BOTtoken "*********" // Tu Bot Token (Obtener de Botfather) #define CHAT_ID "*******" unsigned long channelID = ********; const char * writeAPIKey = "*********"; WiFiClientSecure client; UniversalTelegramBot bot(BOTtoken, client); const int buzPin = 25; const int motionSensor = 27; bool motionDetected = false; // Indica cuando se detecta movimiento void IRAM_ATTR detectsMovement() { motionDetected = true; } void handleNewMessages(int numNewMessages) { for (int i=0; i<numNewMessages; i++) { String chat_id = String(bot.messages[i].chat_id); if (chat_id != CHAT_ID){ bot.sendMessage(chat_id, "Usuario No Autorizado", ""); continue; } String text = bot.messages[i].text; if (text == "/alarma_on") { bot.sendMessage(chat_id, "Alarma activada", ""); digitalWrite(buzPin, HIGH); } if (text == "/alarma_off") { bot.sendMessage(chat_id, "Alarma desactivada", ""); digitalWrite(buzPin, LOW); } } } void setup() { Serial.begin(115200); // PIR Motion Sensor mode INPUT_PULLUP pinMode(motionSensor, INPUT_PULLUP); pinMode(buzPin, OUTPUT); // Set motionSensor pin as interrupt, assign interrupt function and set RISING mode attachInterrupt(digitalPinToInterrupt(motionSensor), detectsMovement, RISING); Serial.print("Connecting Wifi: "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(""); Serial.println("WiFi connected"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); delay(5000); Serial.println("Inicializando ThingSpeak..."); ThingSpeak.begin(client); Serial.println("ThingSpeak inicializado correctamente"); bot.sendMessage(CHAT_ID, "Bot iniciado", ""); } void loop() { int numNewMessages = bot.getUpdates(bot.last_message_received + 1); while(numNewMessages) { handleNewMessages(numNewMessages); numNewMessages = bot.getUpdates(bot.last_message_received + 1); } if(motionDetected){ bot.sendMessage(CHAT_ID, "Movimiento detectado!!", ""); motionDetected = false; delay(5000); int writeResult = ThingSpeak.writeField(channelID, 1,1, writeAPIKey); if (writeResult == 200) { Serial.println("Datos enviados correctamente a ThingSpeak"); } else { Serial.print("Error al enviar datos a ThingSpeak. Código de error: "); Serial.println(writeResult); } } }
athullya in MATLAB Answers
上次活动时间: 2024-5-2

I am doing a project using esp32. The output is visible in serial monitor but it is not showing in thingspeak. What should i do
Germán Chuquimia in MATLAB Answers
上次活动时间: 2024-1-19

Hola buenos dias, cuento con una licencia de thingspeak, mi consulta es la siguiente, como puedo visualizar cada imagen almacenada que toma el esp32cam cuando envia al canal de imagen. revise en preguntas frecuentes el cual dice lo siguiente: 31. ¿Cuántas imágenes puedo enviar a ThingSpeak? Las imágenes enviadas a ThingSpeak se almacenan en su MATLAB Drive. Consulte las preguntas frecuentes de MATLAB Drive para conocer el espacio total permitido en su MATLAB Drive. Una vez que haya excedido el espacio permitido en MATLAB Drive, deberá eliminar algunas imágenes para liberar espacio y almacenar más imágenes. Resulta que revise, y no se hallaba en los archivos de matlab drive las imagenes recopiladas, pero aun asi me sigue consumiendo almacenamientos dentro de Matlab drive, como "others app", y es de mi interes recopilar las imagenes para tener registro diario.
Shreeya in MATLAB Answers
上次活动时间: 2024-1-5

```/* WriteSingleField Description: Writes a value to a channel on ThingSpeak every 20 seconds. Hardware: ESP32 based boards !!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!! Note: - Requires installation of EPS32 core. See https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md for details. - Select the target hardware from the Tools->Board menu - This example is written for a network using WPA encryption. For WEP or WPA, change the WiFi.begin() call accordingly. ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel. Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed. See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation. For licensing information, see the accompanying license file. Copyright 2020, The MathWorks, Inc. */ #include <WiFi.h> #include "secrets.h" #include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros char ssid[] = SECRET_SSID; // your network SSID (name) char pass[] = SECRET_PASS; // your network password int keyIndex = 0; // your network key Index number (needed only for WEP) WiFiClient client; unsigned long myChannelNumber = SECRET_CH_ID; const char * myWriteAPIKey = SECRET_WRITE_APIKEY; // int number = 0; #define sensorPin 34 void setup() { Serial.begin(115200); //Initialize serial ThingSpeak.begin(client); // Initialize ThingSpeak pinMode(sensorPin, INPUT); delay(20000); } void loop() { // Connect or reconnect to WiFi if(WiFi.status() != WL_CONNECTED){ Serial.print("Attempting to connect to SSID: "); Serial.println(SECRET_SSID); while(WiFi.status() != WL_CONNECTED){ WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network Serial.print("."); delay(5000); } Serial.println("\nConnected."); } int smokeValue = analogRead(sensorPin); // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different // pieces of information in a channel. Here, we write to field 1. Serial.println("Smoke value : "); Serial.println(smokeValue); if(smokeValue > 100) { int x = ThingSpeak.writeField(myChannelNumber, 1, smokeValue, myWriteAPIKey); if(x == 200){ Serial.println("Channel update successful, Code : " + String(x)); } else{ Serial.println("Problem updating channel. HTTP error code " + String(x)); } delay(20000); // 20 sec } // change the value // number++; // if(number > 99){ // number = 0; // } delay(2000);// Wait 2 seconds to update the channel again }``` I am getting error of 401 and all my data is correct. // Below is secret.h file // Use this file to store all of the private credentials // and connection details #define SECRET_SSID "Shreyas" // replace MySSID with your WiFi network name #define SECRET_PASS "sarkar2003" // replace MyPassword with your WiFi password #define SECRET_CH_ID 2369873 // replace 0000000 with your channel number #define SECRET_WRITE_APIKEY "QO2EB******TSA" // replace XYZ with your channel write API Key
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
Husnain in MATLAB Answers
上次活动时间: 2023-9-30

Hi, im trying to send data to Thingspeak in bulk/batches. I adopted this example <https://ww2.mathworks.cn/help/thingspeak/continuously-collect-data-and-bulk-update-a-thingspeak-channel-using-an-arduino-mkr1000-board-or-an-esp8266-board.html> . After 1st batch of data is sent to thingspeak successfully, the code doesnot run loop to continue further buffer the data in JSON. That means it send data to server only once and then do nothing. Please guide to sort this issue. #define MODEM_RST 5 #define MODEM_PWKEY 4 #define MODEM_POWER_ON 23 #define MODEM_TX 27 #define MODEM_RX 26 const char apn[] = "***********"; const char gprsUser[] = ""; const char gprsPass[] = ""; const char simPIN[] = ""; const char server[] = "api.thingspeak.com"; const int port = 80; char jsonBuffer[500] = "["; // Initialize the jsonBuffer to hold data #define SerialMon Serial #define SerialAT Serial1 #define TIMEOUT 5000 // Configure TinyGSM library #define TINY_GSM_MODEM_SIM7600 // Modem is SIM7600 #define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb #include <TinyGsmClient.h> #ifdef DUMP_AT_COMMANDS #include <StreamDebugger.h> StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger); #else TinyGsm modem(SerialAT); #endif TinyGsmClient client(modem); #define IP5306_ADDR 0x75 #define IP5306_REG_SYS_CTL0 0x00 /* Collect data once every 15 seconds and post data to ThingSpeak channel once every 2 minutes */ unsigned long lastConnectionTime = 0; // Track the last connection time unsigned long lastUpdateTime = 0; // Track the last update time const unsigned long postingInterval = 20L * 1000L; // Post data every 2 minutes const unsigned long updateInterval = 2L * 1000L; // Update once every 15 seconds // Sensor Libraries #include <SPI.h> #include <Adafruit_Sensor.h> #include <DHT.h> #define DHTPIN 32 #define DHTTYPE DHT22 DHT dht(DHTPIN, DHTTYPE); void setup() { SerialMon.begin(115200); // Set modem reset, enable, power pins pinMode(MODEM_PWKEY, OUTPUT); pinMode(MODEM_RST, OUTPUT); pinMode(MODEM_POWER_ON, OUTPUT); digitalWrite(MODEM_PWKEY, LOW); digitalWrite(MODEM_RST, HIGH); digitalWrite(MODEM_POWER_ON, HIGH); // Set GSM module baud rate and UART pins SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); delay(3000); SerialMon.println("Initializing modem..."); modem.init(); // Configure the wake up source as timer wake up SerialMon.print("Connecting to APN: "); SerialMon.print(apn); if (!modem.gprsConnect(apn, gprsUser, gprsPass)) { SerialMon.println(" fail"); } else { SerialMon.println(" OK"); SerialMon.print("Connecting to "); SerialMon.print(server); if (!client.connect(server, port)) { SerialMon.println(" Fail"); } else { SerialMon.println(" OK"); } } dht.begin(); } void loop() { // If update time has reached 1 second, then update the jsonBuffer if (millis() - lastUpdateTime >= updateInterval) { updatesJson(jsonBuffer); } } // Updates the josnBuffer with data void updatesJson(char* jsonBuffer) { // Collect Hall effect sensor data //int h = hallRead(); float t = dht.readTemperature(); float h = dht.readHumidity(); Serial.print("Temperature: "); Serial.println(t); // Format a single data point as a JSON object char temp[500]; // Temporary buffer for JSON object //sprintf(temp, "{\"delta_t\":%lu,\"field1\":%d},", (millis() - lastUpdateTime) / 1000, t); sprintf(temp, "{\"delta_t\":%lu,\"field1\":%.2f,\"field2\":%.2f},", (millis() - lastUpdateTime) / 1000, t, h); // Append the JSON object to the jsonBuffer strcat(jsonBuffer, temp); // If 15 seconds have passed since the last update, send the data to ThingSpeak if (millis() - lastConnectionTime >= postingInterval) { // Close the JSON array size_t len = strlen(jsonBuffer); jsonBuffer[len - 1] = ']'; // Send data to ThingSpeak httpRequest(jsonBuffer); // Reset the jsonBuffer for the next batch of data jsonBuffer[0] = '['; jsonBuffer[1] = '\0'; } lastUpdateTime = millis(); // Update the last update time } // Updates the ThingSpeakchannel with data void httpRequest(char* jsonBuffer) { // Format the data buffer as noted above char data[500] = "{\"write_api_key\":\"MY_API_KEY\",\"updates\":"; // Replace YOUR-CHANNEL-WRITEAPIKEY with your ThingSpeak channel write API key strcat(data,jsonBuffer); strcat(data,"}"); // Close any connection before sending a new request client.stop(); String data_length = String(strlen(data)+1); //Compute the data buffer length Serial.println(data); // POST data to ThingSpeak if (client.connect(server, 80)) { client.println("POST /channels/MY_CHANNEL_NUMBER/bulk_update.json HTTP/1.1"); // Replace YOUR-CHANNEL-ID with your ThingSpeak channel ID client.println("Host: api.thingspeak.com"); client.println("User-Agent: mw.doc.bulk-update (ESP8266)"); client.println("Connection: close"); client.println("Content-Type: application/json"); client.println("Content-Length: "+data_length); client.println(); client.println(data); String answer=getResponse(); Serial.println( answer ); } else { Serial.println("Failure: Failed to connect to ThingSpeak"); } delay(250); //Wait to receive the response client.parseFloat(); String resp = String(client.parseInt()); Serial.println("Response code:"+resp); // Print the response code. 202 indicates that the server has accepted the response jsonBuffer[0] = '['; //Reinitialize the jsonBuffer for next batch of data jsonBuffer[1] = '\0'; lastConnectionTime = millis(); //Update the last conenction time } String getResponse(){ String response; long startTime = millis(); delay( 200 ); while ( client.available() < 1 && (( millis() - startTime ) < TIMEOUT ) ){ delay( 5 ); } if( client.available() > 0 ){ // Get response from server. char charIn; do { charIn = client.read(); // Read a char from the buffer. response += charIn; // Append the char to the string response. } while ( client.available() > 0 ); } client.stop(); return response; }
Hans Scharler in Discussions
上次活动时间: 2023-9-21

The ThingSpeak Communication Library for Arduino, ESP8266 and ESP32 enables an Arduino or other compatible hardware to write or read data to or from ThingSpeak, an open data platform for the Internet of Things with MATLAB analytics and visualization. Link: <https://github.com/mathworks/thingspeak-arduino> Installation: In the Arduino IDE, choose Sketch/Include Library/Manage Libraries. Click the ThingSpeak Library from the list, and click the Install button. Compatible Hardware: * Arduino/Genuino or compatible using a WiFi Shield * Arduino/Genuino or compatible using a WiFi Shield 101 (Use the WiFi101 library version 0.13.0 or older.) * Arduino/Genuino or compatible using an Ethernet Shield * Arduino/Genuino or compatible using a MKR ETH Shield * Arduino MKR1000 * Arduino MKR1010 * Arduino VIDOR 4000 * Arduino GSM 14000 * Arduino Uno WiFi Rev2 * Arduino Yún (Rev1 and Rev2) * ESP8266 programming directly (tested with SparkFun ESP8266 Thing - Dev Board and NodeMCU 1.0 module) * ESP8266 via AT commands * ESP32 (tested with SparkFun ESP32 Thing) Tutorial: <https://nothans.com/thingspeak-tutorials/arduino/send-data-to-thingspeak-with-arduino> ThingSpeak Communication Library for Arduino, ESP8266 and ESP32 Along with some performance improvements, the latest version of the library supports reading from multiple fields of a channel to your device with a single command. ThingSpeak.readMultipleFields(ChannelNumber); Mr Chris, How do i read a field value at a specific timestamp The Arduino library doesn't include the ability to read a particular timestamp. We've chosen a reduced number of features to keep the footprint smaller. The best way to achieve the result you are looking for is to use the REST API call for <https://www.mathworks.com/help/thingspeak/readdata.html Read Data> with the start and end parameters to get the date you are interested in. There is an example in the documentation that shows how to send a REST call but its a POST. You need a GET. Instead of these lines in that code: client.println( "POST /update HTTP/1.1" ); client.println( "Host: api.thingspeak.com" ); client.println( "Connection: close" ); client.println( "Content-Type: application/x-www-form-urlencoded" ); client.println( "Content-Length: " + String( postData.length() ) ); client.println(); client.println( postData ); Serial.println( postData ); Use something like this, changing the URL for your needs: url = 'https://api.thingspeak.com/channels/9/feeds.csv?start=2011-11-11%2010:10:10&end=2011-11-11%2011:11:11" client.println(String("GET ") + url); Thank you Chris. you are the best. Hello sir, Where should I move the secrets.h file such as the one for ESP32 https://github.com/mathworks/thingspeak-arduino/tree/master/examples/ESP32/WriteSingleField Already checked the instructions at https://www.arduino.cc/en/Guide/Libraries but I cannot find a method to add a bare .h -file (only .zip files). The secrets file should be located in then same directory as the .ino file. You can create a new file in the Arduino IDE using the plus button by the tabs near the top. hi i was ending data to my channel and then i dont know what happend my channel dosent recive any value plz if u could help me bc my project discussion next week ,if we could speak on e-mail or telegram i apriceat that Start a new question on MATLAB answers pelase. You can see the ask a question button if you scroll past the discussion section. Be sure to include your problem description, your hardware, what youve tried, what you observed, and perhaps even a small snippet of the code you think is causing the problem. I have done some basic testing of the ThingSpeak Communication Arduino library with the Raspberry Pi Pico W board using the Philhower Arduino-Pico implementation for Arduino {Arduino-Pico} and it appears to work correctly. However, there is one complaint generated when building code using the Thingspeak library and that is a warning as follows: WARNING: library ThingSpeak claims to run on avr, esp8266, sam, samd, esp32, samd_beta, megaavr architecture(s) and may be incompatible with your current board which runs on rp2040 architecture(s). To remove this warning, add 'rp2040' to the list of architectures in the "library.properties" file. Hi, I have Arduino UNO SMD, how could I connect it to THingSpeak ? which example should i use ?? Thank you You will need some way to connect the device to a network. Wi-Fi is probably the easiest and most versatile. There is a Wi-Fi adapter board for UNO or you can use an esp32 to connect the UNO to Wi-Fi. In this configuration, you use serial communication to send data from the UNO to the ESP. Since the ESP32 is about as powerful (or more) than the UNO, my preference is just to use the ESP32 directly and skip the UNO. arduino esp32 esp8266
Aqsal Renaldi in MATLAB Answers
上次活动时间: 2023-9-18

when i try to use analog read to read a sensor and connect it to thingspeak, the value is always 4095. but when i only use the analog read without the thingspeak program, it works normal. did anyone know whats wrong? here is my program : #include "WiFi.h" #include "ThingSpeak.h" int ldr = 14; int nilai; #define CHANNEL_ID "my number" #define CHANNEL_API_KEY "my key" WiFiClient client; #define WIFI_NETWORK "name" #define WIFI_PASSWORD "pass" #define WIFI_TIMEOUT_MS 2000 void connectToWiFi(){ Serial.print("Connecting to WiFi"); WiFi.mode(WIFI_STA); WiFi.begin(WIFI_NETWORK, WIFI_PASSWORD); unsigned long startAttemptTime = millis(); while(WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < WIFI_TIMEOUT_MS){ Serial.print("."); delay(100); } if(WiFi.status() != WL_CONNECTED){ Serial.print("Failed"); }else{ Serial.print("Connected"); Serial.println(WiFi.localIP()); } } void setup() { pinMode(ldr, INPUT); Serial.begin(9600); connectToWiFi(); ThingSpeak.begin(client); } void loop() { nilai = analogRead(ldr); Serial.print("Nilai LDR :"); Serial.println(nilai); ThingSpeak.writeField(CHANNEL_ID, 1, nilai, CHANNEL_API_KEY); delay(15000); }
Rainer Gerald in Discussions
上次活动时间: 2023-9-7

I've just bought a rain gauge with esp 32 but the problem is Its code is already programmed on esphome Now I need to send the data to one of my channels so I can perform the logic for my sms API Tell me if it's possible Is it possible to transfer data from ESPhome/HomeAssistant to Thingspeak? You can probably do this via the REST API or MQTT, perhaps via both. If you have access to reprogram the device, I found ways to set up API access here. I also found this ThingSpeak integration, but it may also require you to reprogram. ThingSpeak also has its own MQTT broker that you can communicate with. Here is the MQTT integration. All of these optoins seem to require the ability to reprogram the device. Thank you for the multiple options. I've also found the ThingSpeak Integration that you've stated but I'm still waiting for the product to arrive to work things out. But the other options that you've stated is honestly a big help if things go awry with the ThingSpeak Integration. Thank you esp32 esphome
Tchubby Thésard in Discussions
上次活动时间: 2023-7-31

Hi, I have been using ThingSpeak upload on several CO2 detectors based on ESP32 Arduino board, for six mounth. Some are using direct API requests to write values on ThingSpeak channels. Those are still working. Others with similar programmetion but using ThingSpeak Communication Library for Arduino, have stopped uploading values since 19/07/2022 around 16h. Was there any non publiched modification on the library at this time ? Did any body notice something similar ? I have not investigateg the error yet... Thanks for feed back, TC ThingSpeak Client Secure communication down since 19/07/2022 for ESP32 We are not yet aware of any issues with the library, but can you tell us what you are seeing from the device when the post fails? Are you using the secure connection? ThingSpeak certificate may have been updated near that time, you might need to update the firmware. Hi, Thanks for feedback. Yes, indeed, I am using secure connections. The reason why I suspected an eventual different return from the library request is that fails happened on two different networks at the same time. Thought the ones without library are making the https request through a proxy, so that might be a good hint. I'll be upgrading the ESP dev boar from v 2.0.2 to v2.0.4, and let you know. My other main problem is to monitor the errors, on the actual networks where it failed. But I'll do that soon and let the community know. TC Hi, So I am getting a -301 return code, where I used to get the 200. So this is a simple Failed to connect to ThingSpeak, which I don't understand yet. Firmware update did not help. But I guess I am in the situation where Client is capable of doing SSL and TS_ENABLE_SSL macro is undefined (github page Case 3), still TS_ENABLE_SSL macro is defined. So I am not understanding yet what changed leading to connection fails to ThingSpeak... As I mentioned that happened on two different networks at the same time. Https certificate seems to be valid. I need to switch to non-secured connection to try... I am open to any other suggestion. Thanks. TC I can confirm the -301 for me as well, both using the old fingerprint and the new one. The non - secure connection works for the same device. We are looking into this, ill let you know when we find out what is happening Hi, Yes, I checked unsecured connection, it is working anew. Actually, I retested the 4-case confidentiality versus authenticity: Case 1: TS_ENABLE_SSL defined + Client secure --> normal case by not working with -301 return code ! Case 2: TS_ENABLE_SSL defined + Client unsecure --> get the warning return code 400 , value uploaded but need to change my code logic... Case 3: TS_ENABLE_SSL undefined + Client secure --> expected error connecting with return code -301 Case 4: TS_ENABLE_SSL undefined + Client unsecure --> working with return code 200 (normal but not SSL) I also try different root certificates for secure clients but full secured case 1 is still not working. I am not sure of what to update on my side to make it work, so if you identify something on your side, that would be great. Thank, TC Thanks TT, That explains why I have one working (ESP 01 unsecure I.e. case 4 above) and one stopped working (ESP32 secure I.e case 3 above) Thanks for your patience. It seems some of the library examples for secure connections got jumbled in the last publish. We will plan to update the examples shortly. In the meantime, you can download the new cretificate. In firefox Got to thingspeak.com. Click on the lock icon Click on Connection secure -> More information Click on view certificate Click on "DigiCert Global Root CA" in the tab Click on PEM(cert) under Miscellaneous Right click on the downloaded file. Open with any editor. In Chrome, Got to thingspeak.com. Click on the lock icon Click on Connection secure -> certificate is valid Click Cert path tab select the top level Digicert View certificate Details tab Copy to file Choose base 64 encoded x 509 View with text editor. I was able to use the thingspeak library secure connection with esp32 with this cert, but you need to add these lines in secrets.h: client.setCACert(SECRET_TS_ROOT_CA); #define SECRET_TS_ROOT_CA "-----BEGIN CERTIFICATE-----\n" \ ... (cert you got above) "-----END CERTIFICATE-----\n" in main file: const char* certificate = SECRET_TS_ROOT_CA; % in setup fucntion client.setCACert(certificate); // Set Root Certificate for authenticity check Hello, OK, i'll try again in september as I am away for the month and post the results. Thank. TT Hello again, So, I have tried to roll back to secure connection with esp32 using new downloaded certificate from thingspeak.com, but nothing to do, I am still getting the -301 error return code, either with thingspeak library or direct URL API GET. I also upgraded with new available card firmware v2.0.5, but the same results. I am stuck with non-secure connection which is working fine. TT NOTE : it is not a "DigiCert Global Root CA" but an "ESET SSL Filter CA" doest it mind ? I pulled out this simple case from WriteSingleFieldSecure GitHub's example with the adivesed modifications. It uploads values from 400 to 450 to my TS channel N°5 evry 30 seconds. It is not working I get -301 error code each time (similar code with non secure client do works). Please tel me if there is something obviously wrong, or if it is about CA certificat (I put it clearly the one got from thingspeak.com with the advise method). TT /* WriteSingleField Description: Writes a value to a channel on ThingSpeak every 20 seconds over secured HTTPS connection. Hardware: ESP32 based boards !!! IMPORTANT - Modify the secret.h file for this project with your network connection and ThingSpeak channel details. !!! Note: - Requires installation of EPS32 core and WiFiClientSecure library. See https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md for details. - Select the target hardware from the Tools->Board menu - This example is written for a network using WPA encryption. For WEP or WPA, change the WiFi.begin() call accordingly. ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel. Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed. See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation. For licensing information, see the accompanying license file. Copyright 2020, The MathWorks, Inc. */ #define TS_ENABLE_SSL // For HTTPS SSL connection #include <WiFiClientSecure.h> #include "secret.h" #include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros char ssid[] = SECRET_SSID; // your network SSID (name) char pass[] = SECRET_PASS; // your network password WiFiClientSecure client; unsigned long myChannelNumber = SECRET_CH_ID; const char * myWriteAPIKey = SECRET_WRITE_APIKEY; // const char* certificate = SECRET_TS_ROOT_CA; const char* certificate = "-----BEGIN CERTIFICATE-----\n" \ "MIIDgDCCAmigAwIBAgIQNerH/sDRZ3n9Yvcpt60igTANBgkqhkiG9w0BAQsFADBI\n" \ "MRswGQYDVQQDDBJFU0VUIFNTTCBGaWx0ZXIgQ0ExHDAaBgNVBAoME0VTRVQsIHNw\n" \ "b2wuIHMgci4gby4xCzAJBgNVBAYTAlNLMB4XDTIyMDYzMDA5NDIxN1oXDTMyMDYy\n" \ "NzA5NDIxN1owSDEbMBkGA1UEAwwSRVNFVCBTU0wgRmlsdGVyIENBMRwwGgYDVQQK\n" \ "DBNFU0VULCBzcG9sLiBzIHIuIG8uMQswCQYDVQQGEwJTSzCCASIwDQYJKoZIhvcN\n" \ "AQEBBQADggEPADCCAQoCggEBAN3XvsuwGuJDYyciXcaGG5kyxCPTO9m55OvEu45X\n" \ "KCFiFXAEZPJYWeKptzQfv/RO5hPgIWDHfQPE5fb+61pV7w9dGue3mErg3Zw6DjDN\n" \ "PFk5YYzHlCRlSSocxuuFdKPMnuTPNkPSv8nmoYelhTpNfDRX5TVMml83bXB/ISYL\n" \ "O5SSpvhg0GSJtnJeZZOk5qXpImJr6/Im1BlQaMq8cbE944NPFfaDy3bSpdiTGv8Z\n" \ "WxRsuFiiJLjQ2Xs9HJYw8HUJeI9BBFZZZWpw7HGZaqlW1ADxl8qv3Kwduxb0CsV7\n" \ "R+5Utghg40c0i67bs5vE4IzdqrPrDtNNOx4d3/e7l58/4I8CAwEAAaNmMGQwDgYD\n" \ "VR0PAQH/BAQDAgIEMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFGgdMYoY\n" \ "0JSXdYADatVZUf/UZRpzMB8GA1UdIwQYMBaAFGgdMYoY0JSXdYADatVZUf/UZRpz\n" \ "MA0GCSqGSIb3DQEBCwUAA4IBAQBDGPrqHrG9OCSE8sVC2+yqijcuyGg7EZmEejPU\n" \ "Ev/+Elt6FoYBfSK9b961uVQ61KnDOIOHdm1GAthn2LwroAHCscOg/6Spb6XYybo6\n" \ "otwdt354rEeswh2rJWlwy8F1BUTZKT05XmgzrdSBJEVOcapv1VsmGqLz0aa8tnWw\n" \ "BlXrTXmvBSQRjiKhmv2X3BC/FT/ir8TWxQPyxC6cJTGvN/E3+dCHJsGYBZEzHT60\n" \ "H/PWuDp9B/7BsKHSba/frTqrjnMvGVgyAMy+4DFlqdb8O1tZUke5DBJJ7DmPRYRM\n" \ "AuD9BRS2uo03jjoCMB+8qW/0zyV531BRu8l6+PlNvQW8dZV3\n" \ "-----END CERTIFICATE-----\n"; int number = 400; void setup() { client.setCACert(certificate); // Set Root Certificate for authenticity check Serial.begin(115200); //Initialize serial while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo native USB port only } Serial.println(certificate); WiFi.mode(WIFI_STA); ThingSpeak.begin(client); // Initialize ThingSpeak } void loop() { // Connect or reconnect to WiFi if(WiFi.status() != WL_CONNECTED){ Serial.print("Attempting to connect to SSID: "); Serial.println(SECRET_SSID); while(WiFi.status() != WL_CONNECTED){ WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network Serial.print("."); delay(5000); } Serial.println("\nConnected."); } // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different // pieces of information in a channel. Here, we write to field 1. int x = ThingSpeak.writeField(myChannelNumber, 5, number, myWriteAPIKey); if(x == 200){ Serial.println("Channel update successful."); Serial.println( number); } else{ Serial.println("Problem updating channel. HTTP error code " + String(x)); } // change the value number++; if(number > 450){ number = 400; } delay(30000); // Wait 30 seconds to update the channel again } Does the insecure mothod work for you? The get certificate method is very finiky, I may not have done a perfect job explaining how to get the cert. Please let me know about insecure, and try the get cert method once more. Hello, Yes, insecure method is working. In the same code, if I remove "#define TS_ENABLE_SSL" and replace "WiFiClientSecure client;" by "WiFiCleint client;",this is working. Indeed, the described method to get the cert may not be up to date, but on the principle I think I got the method : getting the PEM(cert) of DigiCert Global Root CA from thingspeak.com web site either with FireFox or Chrome. Actually, this gives the same cert, so I thought it was just right, but if you can confirm that the posted cert is good, that would help. Maybe I got something wrong. Thanks, TT This is the cert I used successfully #define SECRET_TS_ROOT_CA "-----BEGIN CERTIFICATE-----\n" \ "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" \ "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" \ "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" \ "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" \ "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" \ "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" \ "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" \ "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" \ "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" \ "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" \ "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" \ "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" \ "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" \ "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" \ "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" \ "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" \ "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" \ "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" \ "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" \ "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" \ "-----END CERTIFICATE-----\n" Thank you, I am going to try that one. Hello again, YES, this is working with this cert, just like before. So I guess everything is about getting a good cert, and it seems I don't have the right method. I will work on that point, but if you could ever update the method, I could use it right. I am not figuring out yet what I do wrong, so I have my detectors all work with that one cert. Thank you, TT Hello @Christopher Stapels, I happen to have the exact same problem since 25th of July 2023 at 19h (french time), that is about exactly one year, did you had server update by any chance ? Or Is there any kind of expiring date with certificats ? Could you eventually issue a new certificat here please, beacuse I can not get one working from thingspeak.com like last time? Thank you in advance. Regards, TC Hi, I too have been using ThingSpeak upload on a number of detectors and haven't had new code releases for about a year, one is based on ESP32 and its last post was on Tuesday 25th July 2023 at 18:02:09 GMT+0100. I am using a ThingSpeak secure Communication Library for Arduino too. I've re-booted the device twice and the program is running fine but it is still failing to post. I suspect there is a certificate issue. If that's what it is, I don't understand why its expired so soon. Accoding to Digi Cert "Root certificates also typically have long periods of validity, compared to intermediate certificates. They will often last for 10 or 20 years...". My last post on this thread was on 30th July 2022 - uncanny - almost a year to the day. Please do share any updates, my heating and hot water is now in local fallback mode which is much less efficient :-( Hello Austin, Yes, this is exactly that. I'd believe there had been a security update on the server side, like last year. I'am looking for a working CA root certificat to roll back to secure upload, but in the mean time same code are woking switching to non secure upload. TC It does appear that the certificate has changed again, perhaps it is yearly. Ill talk to the devs about that -----BEGIN CERTIFICATE----- MIIEyDCCA7CgAwIBAgIQDPW9BitWAvR6uFAsI8zwZjANBgkqhkiG9w0BAQsFADBh MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH MjAeFw0yMTAzMzAwMDAwMDBaFw0zMTAzMjkyMzU5NTlaMFkxCzAJBgNVBAYTAlVT MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxMzAxBgNVBAMTKkRpZ2lDZXJ0IEdsb2Jh bCBHMiBUTFMgUlNBIFNIQTI1NiAyMDIwIENBMTCCASIwDQYJKoZIhvcNAQEBBQAD ggEPADCCAQoCggEBAMz3EGJPprtjb+2QUlbFbSd7ehJWivH0+dbn4Y+9lavyYEEV cNsSAPonCrVXOFt9slGTcZUOakGUWzUb+nv6u8W+JDD+Vu/E832X4xT1FE3LpxDy FuqrIvAxIhFhaZAmunjZlx/jfWardUSVc8is/+9dCopZQ+GssjoP80j812s3wWPc 3kbW20X+fSP9kOhRBx5Ro1/tSUZUfyyIxfQTnJcVPAPooTncaQwywa8WV0yUR0J8 osicfebUTVSvQpmowQTCd5zWSOTOEeAqgJnwQ3DPP3Zr0UxJqyRewg2C/Uaoq2yT zGJSQnWS+Jr6Xl6ysGHlHx+5fwmY6D36g39HaaECAwEAAaOCAYIwggF+MBIGA1Ud EwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFHSFgMBmx9833s+9KTeqAx2+7c0XMB8G A1UdIwQYMBaAFE4iVCAYlebjbuYP+vq5Eu0GF485MA4GA1UdDwEB/wQEAwIBhjAd BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwdgYIKwYBBQUHAQEEajBoMCQG CCsGAQUFBzABhhhodHRwOi8vb2NzcC5kaWdpY2VydC5jb20wQAYIKwYBBQUHMAKG NGh0dHA6Ly9jYWNlcnRzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydEdsb2JhbFJvb3RH Mi5jcnQwQgYDVR0fBDswOTA3oDWgM4YxaHR0cDovL2NybDMuZGlnaWNlcnQuY29t L0RpZ2lDZXJ0R2xvYmFsUm9vdEcyLmNybDA9BgNVHSAENjA0MAsGCWCGSAGG/WwC ATAHBgVngQwBATAIBgZngQwBAgEwCAYGZ4EMAQICMAgGBmeBDAECAzANBgkqhkiG 9w0BAQsFAAOCAQEAkPFwyyiXaZd8dP3A+iZ7U6utzWX9upwGnIrXWkOH7U1MVl+t wcW1BSAuWdH/SvWgKtiwla3JLko716f2b4gp/DA/JIS7w7d7kwcsr4drdjPtAFVS slme5LnQ89/nD/7d+MS5EHKBCQRfz5eeLjJ1js+aWNJXMX43AYGyZm0pGrFmCW3R bpD0ufovARTFXFZkAdl9h6g4U5+LXUZtXMYnhIHUfoyMo5tS58aI7Dd8KvvwVVo4 chDYABPPTHPbqjc1qCmBaZx2vN4Ye5DUys/vZwP9BFohFrH/6j/f3IL16/RZkiMN JCqVJUzKoZHm1Lesh3Sz8W2jmdv51b2EQJ8HmA== -----END CERTIFICATE----- Hello Christopher, Thank you again. I could roll back to secure upload with this certificate. This is working fine anew. Yes please give us feed back from the devs, if this had to be renewed yearly I'll probably come back next year... The thing I cannot figure out, is why I am not able to get one working certificate myself with the given method : I go to the lock of Chrome on thingspeak.com, click on "secure connection" ,then open "valid certificate" and export one from the small window as a .PEM file. I do get something looking like yours, but not working... I also tried from FireFox, but not better, though different .PEM file. Why do I get it wrong ? Regards, TC @Austin Jacobs I hope you were able to leave the fallback mode now that we have provided the new cert. Our security team shared this quote from digicert. "This year DigiCert started updating default root certificate (DigiCert TLS RSA SHA256 2020 CA1) to second generation public root certificates (DigiCert Global G2 TLS RSA SHA256 2020 CA1) starting from March 2023. One of the reasons is to align with Mozilla's distrust policy regarding old root certificate which will take effect in 2025. Thus, any newly requested certificate after March is by default attached with a second generation root certificate and that is why *.thingspeak.com certificate is updated too. More information about DigiCert's announcement and policy can be found here." They added that due to this policy, if they didnt do it this year, they would need to request an exemtion and still do the update next year. The current root certificate for ThingSpeak is valid till Mar 29, 2031, but you can expect a similar roll out for the root certificate in the year 2029. I've found some confusion myself on the step before valid certificate. There may be two or more certificates to select (root or lower) and you might not be choosing the right one. I'll try again. Thanks. There are two certificates, looking like this in detail tab: ESET SSL Filter CA *.thingspeak.com I think I want the highest; anyway I tried both, but none of them are working. There is definitely something I don't get... Well that explains it. Thanks for investigating. I have applied the new cert and it works just fine now - all tickign along as before. Thanks again for the support. esp32 arduino thingspeak libra
Armando Villegas in MATLAB Answers
上次活动时间: 2023-2-10

Hi everyone. I'm trying to send the ADC value from a potentiometer to the ThingSpeak channel and I'm dealing with the problem that I send data to ThingSpeak and I just receive zero value in the channel even if I turn the potentiometer knob. If I run the program without the ThingSpeak configuration everything work well. Could you help me, please? I leave the source code below. Thank you. /*LIBRARIES*/ #include <Arduino.h> #include "ThingSpeak.h" #include "WiFi.h" /*DEFINITIONS*/ #define ANALOGPIN 15 /*THINGSPEAK CONFIGURATION*/ const char* ssid = "xxxxxx"; const char* password = "xxxxxx"; unsigned long channelID = xxxxxxx; const char* WriteAPIKey = "xxxxxx"; WiFiClient Client; /*PROTOTYPES*/ void readPot (void); /*--START FILE--*/ void setup() { delay(2000); Serial.begin(115200); Serial.println("ESP32 ADC"); /*WIFI CONNECTION*/ WiFi.begin(ssid,password); while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nWifi connected"); ThingSpeak.begin(Client); } void loop() { delay(2000); readPot(); ThingSpeak.writeFields(channelID,WriteAPIKey); Serial.println("Send data."); Serial.println("---------------\n"); delay(18000); } /*FUNCTION*/ void readPot (void) { int potVal = analogRead(ANALOGPIN); while(isnan(potVal)) { Serial.println("Read failed"); delay(2000); potVal = analogRead(ANALOGPIN); } Serial.println("\nADC: "); Serial.println(potVal); ThingSpeak.setField(1,potVal); } /*-- END OF FILE --*/
Andre in MATLAB Answers
上次活动时间: 2022-12-28

I am using the ESP32 to interface the YF-S201 flowmeter sensor and send collected data over to Thingspeak server. The data is updated on serial monitor but the data is not reflected on ThingSpeak server. Could anyone please help me with how to send data of the YF-S201 sensor to Thingspeak server. I am attaching the code which I am presently using. I am not able to figure out what is wrong in the code and thereby would appreciate some help. #include <WiFi.h> #include <SPI.h> #include <Wire.h> String apiKey = ""; // Enter your Write API key from ThingSpeak const char *ssid = ""; // replace with your wifi ssid and wpa2 key const char *pass = ""; const char* server = "api.thingspeak.com"; #define LED_BUILTIN 16 #define SENSOR 4 long currentMillis = 0; long previousMillis = 0; int interval = 1000; boolean ledState = LOW; float calibrationFactor = 4.5; volatile byte pulseCount; byte pulse1Sec = 0; float flowRate; unsigned long flowMilliLitres; unsigned int totalMilliLitres; float flowLitres; float totalLitres; void IRAM_ATTR pulseCounter() { pulseCount++; } WiFiClient client; void setup() { Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); pinMode(SENSOR, INPUT_PULLUP); pulseCount = 0; flowRate = 0.0; flowMilliLitres = 0; totalMilliLitres = 0; previousMillis = 0; attachInterrupt(digitalPinToInterrupt(SENSOR), pulseCounter, FALLING); } void loop() { currentMillis = millis(); if (currentMillis - previousMillis > interval) { pulse1Sec = pulseCount; pulseCount = 0; // Because this loop may not complete in exactly 1 second intervals we calculate // the number of milliseconds that have passed since the last execution and use // that to scale the output. We also apply the calibrationFactor to scale the output // based on the number of pulses per second per units of measure (litres/minute in // this case) coming from the sensor. flowRate = ((1000.0 / (millis() - previousMillis)) * pulse1Sec) / calibrationFactor; previousMillis = millis(); // Divide the flow rate in litres/minute by 60 to determine how many litres have // passed through the sensor in this 1 second interval, then multiply by 1000 to // convert to millilitres. flowMilliLitres = (flowRate / 60) * 1000; flowLitres = (flowRate / 60); // Add the millilitres passed in this second to the cumulative total totalMilliLitres += flowMilliLitres; totalLitres += flowLitres; // Print the flow rate for this second in litres / minute Serial.print("Flow rate: "); Serial.print(float(flowRate)); // Print the integer part of the variable Serial.print("L/min"); Serial.print("\t"); // Print tab space // Print the cumulative total of litres flowed since starting Serial.print("Output Liquid Quantity: "); Serial.print(totalMilliLitres); Serial.print("mL / "); Serial.print(totalLitres); Serial.println("L"); } if (client.connect(server, 80)) // "184.106.153.149" or api.thingspeak.com { String postStr = apiKey; postStr += "&field1="; postStr += String(float(flowRate)); postStr += "&field2="; postStr += String(totalLitres); 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); } client.stop(); }
rene in Discussions
上次活动时间: 2022-12-5

hello, i buy a license for upload images to channel and ESP32CAM, after compile and upload the example code, then reset the esp32. https://la.mathworks.com/help/thingspeak/write-image-to-thingspeak-from-esp32-camera-board.html the serial monitor only show Brownout detector was triggered ets Jun 8 2016 00:22:57 rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:10944 load:0x40080400,len:6388 entry 0x400806b4 i have another code working for esp32cam and send image to telegram... maybe any can show why works there and not here please. esp32cam upload image, example dont work It looks like in your more recent MATLAB answer, you were able to get an image up to ThingSpeak. Can you update this discussion and let us know what the problem was, if you were able to fix it? hi, after compare two codes, i can say this in void setup, activate the cam. WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); but i think is the programer to esp32cam maybe, i have a FT232RL. in the example option here show another. btw here is the code working for me with a magnetic sensor door in pin 2, when sensor is open image upload, or you can delete in the void loop. esp32cam image upload license
Azad Sheikh in MATLAB Answers
上次活动时间: 2022-10-20

Just tried testing esp32 with sim800L on ThingSpeak free channel. Not sure why getting the "http error code 0" because the channel values are getting inserted with new values. It is functioning, but, would be helpful if someone could point out why the http error code 0 is returned ? int i = ThingSpeak.writeField(myBlowerChannel, 1, temp, myBlowerKey); value of 'i' is coming '0' but the temp data is getting inserted
Maria SS in Discussions
上次活动时间: 2022-9-26

I wanted to ask that can we send bulk data through ThingSpeak ESP32 library using: POST /channels/266256/bulk_update.csv HTTP/1.1 Host: api.thingspeak.com Content-Type: application/x-www-form-urlencoded time_format: relative I saw it on mathswork "Bulk-Write CSV Data" (link: https://www.mathworks.com/help/thingspeak/bulkwritecsvdata.html) Does ThingSpeak library supports the capability to send bulk csv data, any guidance? Thanks and looking forward for your positive reply Send Bulk Data via ThingSpeak library, ESP32 The ThingSpeak library does not presently support the bulk update feature. There are good examples that show how to use bulk update on an Arduino like device without the thinglspeak library. That example uses JSON formatiing, but you can easily adapt tit to CSV if you wish. Thankyou very much for your reply Hello Christopher, First of all thanks for your reply, I am working on a project where I need to save sensor data on a file in SD card and than I need to transfer that file to server. I think, in Bulk-Update Using an Arduino or an ESP8266 tutorial on MathsWork, I need to first save json data in json file on SD card and than transfer that file but in client.println("POST /channels/YOUR-CHANNEL-ID/bulk_update.json HTTP/1.1"); file name is only bulk_update.json, not sure whether I can transfer file or not to ThingSpeak. The ThingSpeak bulk endpoint does not accept direct file transfers, but I dont think that is required. Your ESP32 device can write the information from the SD card to the HTTP client without converting to a file. Thanks for sharing some information about your project. What type of sensor data are you measuring? I am measuring vibrations data and I need to bulk update the server(not ThingSpeak cloud) via http rather than sending one vibration reading at a time. I am not using ThingSpeak library now. I am using example provided in mathswork on Bulk update via esp8266 thingspeak esp32
Pete Shepherd in Discussions
上次活动时间: 2022-8-18

I have an ESP32 that has 5 values (solarW, batteryV, pumpW, pumpRPM and pumpLPM) that I'm writing to 5 fields on a Thingspeak channel. if ((millis() - fifteenTstart) > 15000){ Serial.println("Updating Thingspeak...."); ThingSpeak.setField(1, solarW); ThingSpeak.setField(2, batteryV); ThingSpeak.setField(3, pumpW); ThingSpeak.setField(4, pumpRPM); ThingSpeak.setField(5, pumpLPM); int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); if(x == 200){ Serial.println("Channel update successful."); } else{ Serial.println("Problem updating channel. HTTP error code " + String(x)); } } It works fine when there's a good connection to the internet and Thingspeak, but there's a 10 second or so delay when Thingspeak is unavailable (WiFi, internet or website non-connectivity). I would like the code to recognise that there's no ThingSpeak connection musch faster (1 second or less woud be good, but I'll take two!). Or, if it's possible to just send the data out without the code waiting for a confirmation back (I only need the data to go OUT from the ESP32 to Thingspeak, nothing needs to come back). Need faster Thingspeak connection timeout in ESP32 code MQTT is more of a fire and forget routine that you can use with ThingSpeak, though you may still have some connection delay. Our REST interface requires your client to wait for the response from the server. If you disconnect before the response with the REST interface, your data wont be posted. I've also been able to get paralell processes running on an ESP32, here is one tutorial I've used. Thanks Christopher. Looks like the parallel prcoessing route will be a good solution. I didn't know the ESP32 had dual core processing, definitely worth learning about! Multi threading is fun, but it does add some serious complexity to debugging. I would still recomend MQTT for this purpose and do the multi threads for learning sake. Good luck either way. thingspeak esp32 updating speed delay faster code connection
David Evans in MATLAB Answers
上次活动时间: 2022-1-17

The following code runs on an Adafruit ESP32 Feather that connects to the internet via my ASUS RT-N66U router. The ESP32 is "remote" and is accessible only via wifi. It posts to ThingSpeak every 10 minutes and works fine for a day, sometimes a few days, but then it stops posting and returns error -301 ("failed to connect") with every attempt. It only starts posting again after a hard reboot. I suspected heap fragmentation, but free heap is constant at 247k (after an initial quick decline from 250k) and max allocatable heap is constant at 114k from the start. ESP32 hasn't lost wifi connectivity, since I can access the ESP32 via the router (and run the "server.on" commands). I also have an ESP8266 posting to ThingSpeak every five minutes and it has been online for months, so the problem probably isn't with the router or ISP. Even after the ESP32 stops posting, I can successfully manually post from a browser with https://api.thingspeak.com/update.json?api_key=xyz&field5=199, so it seems the problem is with the code. I'm running the latest ThingSpeak library, ESP library and core (but not developmental version), and Arduino IDE. Would appreciate suggestions on things to try or monitor. #include <WiFi.h> #include <WiFiClient.h> #include <WebServer.h> #include <ArduinoOTA.h> #include <ESP_Mail_Client.h> #include <esp_int_wdt.h> // for hard reboot #include <esp_task_wdt.h>// ditto #include "ThingSpeak.h" // "always put this last in the list of includes" WebServer server(80); // OTA and server.on WiFiClient client; // TS only //**** definitions etc **** #define SMTP_HOST "smtp.gmail.com" #define SMTP_PORT 465 #define AUTHOR_EMAIL "xyz@gmail.com" #define AUTHOR_PASSWORD "abc" SMTPSession smtp; void smtpCallback(SMTP_Status status); ESP_Mail_Session session; SMTP_Message message; const char * myWriteAPIKey = "efg"; // TS const byte deltaDecreaseCM = 30; // threshold in cm... 12" = 30.48 cm const int distAvg = 1060; // average distance const unsigned long myChannelNumber = 123; // TS bool paused = false; bool savedPaused; bool intruder = false; bool alarmSounded = false; bool snowing = false; bool snowTriggeredOnce = false; bool distSaving = true; byte reqdNumBreaks = 6; byte lastTSalarmFlag; byte snowFactor = 1; byte savedSnowFactor; byte snowCount; byte saveDist[100]; byte saveIdx = 99; int distCurrent; int savedDistance; int lastTScode = 200; int wiFiFailsTS; unsigned long numIntruders; // can be very large if beam is blocked for a long time (eg. by parked car) unsigned long alarmTriggeredTime; unsigned long prevTSfailTime = 0; unsigned long startSnowingTime; unsigned long firstSnowTrigger; unsigned long pauseStartTime; unsigned long pauseDuration; //**** setup **** void setup() { Serial1.begin(115200); // TF03 default rate = 115200 WiFi.begin(); while (WiFi.waitForConnectResult() != WL_CONNECTED) { delay(5000); ESP.restart(); } setupMail(); server.on("/", handleRoot); server.on("/reboot", reBootMe); server.on("/postTS", doTSpost); server.on("/showTS", showTScode); server.onNotFound(handleNotFound); ArduinoOTA.begin(); server.begin(); ThingSpeak.begin(client); readTFxTimes(50); // clear serial1 buffer } //*************************************************************************************** //**** loop **** //*************************************************************************************** void loop() { ArduinoOTA.handle(); // this works even if posting to TS does not work server.handleClient(); // ditto unsigned long currTime = millis(); const unsigned long writeTSinterval = 600000UL; // post to TS every 10 min (and upon sounding alarm) static unsigned long prevTSwriteTime = 0; const unsigned long maxAlertInterval = 600000UL; // no duplicate alarms for 10 min after an alarm // reset pause flag if time is up if (paused && (currTime - pauseStartTime > pauseDuration)) { paused = false; } // reset alarm flag if time is up if (alarmSounded && (currTime - alarmTriggeredTime > maxAlertInterval)) { alarmSounded = false; } readTFxTimes(1); // read TF03 once every loop if (! paused && ! alarmSounded) { // chk for intruder, but only if not paused and not w/in 10 min of an alarm chkForIntruder(); if (intruder && (numIntruders == reqdNumBreaks * snowFactor)) soundAlarm(); // sound alarm if sufficient number of sequential brks } // post to thingSpeak if (prevTSfailTime) { // if an alarmFlag=1 write failed (posted too soon after an alarmFlag=0 post) if (currTime - prevTSfailTime > 20000UL) { // try again after 20 sec (15.1 sec didn't seem to work on 1/27 when there was a collision) prevTSfailTime = 0; prevTSwriteTime = currTime; writeThingSpeak(1, savedDistance, savedSnowFactor, savedPaused); //this will only do one re-try. If this fails again with -401 (for whatever reason) //it will just continue on with normal (alarmFlag=0) posts after 10 minutes. } } else if ((currTime - prevTSwriteTime > writeTSinterval) && (! intruder)) { prevTSwriteTime = currTime; writeThingSpeak(0, distCurrent, snowFactor, paused); // zero indicates no alarmFlag } } //*************************************************************************************** //**** writeThingSpeak **** //*************************************************************************************** void writeThingSpeak(byte alarmF, int distC, byte snowF, bool pausD) { if (WiFi.status() != WL_CONNECTED) { // should already be connected, but check again anyway wiFiFailsTS++; //this has never been > 1 while (WiFi.status() != WL_CONNECTED) { WiFi.begin(); delay(5000); } } int freeHeap = ESP.getFreeHeap(); int maxAllocatable = ESP.getMaxAllocHeap(); ThingSpeak.setField(1, distC); ThingSpeak.setField(2, alarmF); // 0 = no intruder; 1 = intruder; 4 = manual test post ThingSpeak.setField(3, snowF); // 1 = no snow; other = snowing ThingSpeak.setField(4, pausD); ThingSpeak.setField(5, lastTScode); ThingSpeak.setField(6, freeHeap); ThingSpeak.setField(7, maxAllocatable); ThingSpeak.setField(8, wiFiFailsTS); lastTScode = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); readTFxTimes(50); // in case the above takes "a while". 100 = about one second of reads, so 50 is about half a second /* https://github.com/mathworks/thingspeak-arduino Return Codes Value Meaning 200 OK / Success 404 Incorrect API key (or invalid ThingSpeak server address) -101 Value is out of range or string is too long (> 255 characters) -201 Invalid field number specified -210 setField() was not called before writeFields() -301 Failed to connect to ThingSpeak <------------------------------- -302 Unexpected failure during write to ThingSpeak -303 Unable to parse response -304 Timeout waiting for server to respond -401 Point was not inserted (most probable cause is the rate limit of once every 15 seconds) 0 Other error */ } //**** chkForIntruder **** void chkForIntruder() { int deltaDist = distAvg - distCurrent; if (distSaving) { // not currently accessible (deleted the associated server.on) saveIdx = (saveIdx + 1) % 100; if (deltaDist < 0) { saveDist[saveIdx] = 0; } else { saveDist[saveIdx] = deltaDist; } } if (deltaDist > deltaDecreaseCM) { // if distance descreases more than the limit, then there's an intruder intruder = true; numIntruders++; // number of sequential breaks, actually } else { if (snowing) { if (millis() - startSnowingTime < 1800000UL) { if ((reqdNumBreaks / 2 < numIntruders) && (numIntruders < reqdNumBreaks)) snowCount++; } else { // time is up if (! snowCount) { // if snowCount == 0, reset flag and factor snowing = false; snowFactor = 1; } else { // snowCount was > 0, so need to keep checking... startSnowingTime = millis(); // reset time, so check again later snowCount = 0; // restart count for this new period } // end "else" (snow count > 0) } // end "else" (time is up) } else { // end "if snowing" if (snowTriggeredOnce) { if (millis() - firstSnowTrigger > 300000UL) { // triggered once, but time expired, so re-set flag snowTriggeredOnce = false; } else if ((reqdNumBreaks / 2 < numIntruders) && (numIntruders < reqdNumBreaks)) { // triggered once, time not expired, meets criteria...set snowing flag, etc. startSnowingTime = millis(); snowing = true; snowFactor = 4; snowTriggeredOnce = false; distSaving = false; } //end snowTriggeredOnce } else if ((reqdNumBreaks / 2 < numIntruders) && (numIntruders < reqdNumBreaks)) { // not triggered yet, but meets criteria, so set triggered once flag, etc. snowTriggeredOnce = true; firstSnowTrigger = millis(); } // end not triggered yet but meets criteria } // end "not snowing" intruder = false; numIntruders = 0; } // end "else" distance not decreased...so no intruder, and numIntruders reset to zero } //**** soundAlarm **** void soundAlarm() { alarmTriggeredTime = millis(); alarmSounded = true; sendMyMailNow(); //send an alert if (snowing && (startSnowingTime - alarmTriggeredTime < 5000)) { snowing = false; snowFactor = 1; } writeThingSpeak(1, distCurrent, snowFactor, paused); // 1 indicates intruder if (lastTScode == -401) { prevTSfailTime = millis(); savedDistance = distCurrent; savedSnowFactor = snowFactor; savedPaused = paused; } } //**** readTFxTimes **** void readTFxTimes(byte numOfReads) { for (byte i = 0; i < numOfReads; i++) { while (! readTF03once()) { //read until a number is obtained } } } //**** readTF03once **** bool readTF03once() { int check; // checksum byte uart[9]; // stores each byte of data returned by LiDAR (was int... I changed to byte) const byte HEADER = 0x59; // data package frame header...the letter "Y" in ASCII (was int... I changed to byte) if (Serial1.available()) { //check whether the serial port has data input if (Serial1.read() == HEADER) { // determine data package frame header = 0x59 uart[0] = HEADER; if (Serial1.read() == HEADER) { // determine data package frame header = 0x59 uart[1] = HEADER; for (byte i = 2; i < 9; i++) { // store rest of data to array uart[i] = Serial1.read(); } check = uart[0] + uart[1] + uart[2] + uart[3] + uart[4] + uart[5] + uart[6] + uart[7]; if (uart[8] == (check & 0xff)) { // check the received data as per protocols 0xff = 0b11111111 // Not sure why bitwise and (&) is used. distCurrent = uart[2] + uart[3] * 256; // calculate distance value return true; //got a reading } } } } distCurrent = 0; return false; //didn't get a reading } void handleRoot() { if (server.arg("pause") != "") { // i.e., if not zero, then user entered ...?pause=(a number) paused = true; pauseDuration = (unsigned long) server.arg("pause").toInt(); // in minutes pauseStartTime = millis(); if (pauseDuration <= 0) { // if neg, do nothing paused = false; } else if (pauseDuration > 1200) { // if large, limit to 1200 minutes = 20 hours pauseDuration = 1200UL; intruder = false; // so posting to TS continues during pause numIntruders = 0; } else { // otherwise, use received value intruder = false; // so posting to TS continues during pause numIntruders = 0; } pauseDuration *= 60000UL; // convert minutes to milliseconds server.send(200, "text/plain", "pausing"); } else { // not break or pause server.send(200, "text/plain", "ESP32 eye .151"); } } void reBootMe() { // run with /reboot // see e32hardReset in test_espB folder for basis of this server.send(200, "text/plain", "reboot in 2"); delay(2000); esp_task_wdt_init(1, true); esp_task_wdt_add(NULL); while (true); } void doTSpost() { // run with /postTS server.send(200, "text/plain", "posting a 2 to TS"); writeThingSpeak(2, distCurrent, snowFactor, paused); } void showTScode() { // run with /showTS char myCstr[15]; snprintf(myCstr, 15, "TScode=%d", lastTScode); server.send(200, "text/plain", myCstr); } void handleNotFound() { server.send(404, "text/plain", "404: Not found"); } void smtpCallback(SMTP_Status status) { Serial.println(status.info()); if (status.success()) { Serial.println("----------------"); Serial.printf("Message sent success: %d\n", status.completedCount()); Serial.printf("Message sent failled: %d\n", status.failedCount()); Serial.println("----------------\n"); struct tm dt; for (size_t i = 0; i < smtp.sendingResult.size(); i++) { SMTP_Result result = smtp.sendingResult.getItem(i); localtime_r(&result.timesstamp, &dt); Serial.printf("Message No: %d\n", i + 1); Serial.printf("Status: %s\n", result.completed ? "success" : "failed"); Serial.printf("Date/Time: %d/%d/%d %d:%d:%d\n", dt.tm_year + 1900, dt.tm_mon + 1, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec); Serial.printf("Recipient: %s\n", result.recipients); Serial.printf("Subject: %s\n", result.subject); } Serial.println("----------------\n"); } } void setupMail() { smtp.debug(0); // 0 = none smtp.callback(smtpCallback); session.server.host_name = SMTP_HOST; session.server.port = SMTP_PORT; session.login.email = AUTHOR_EMAIL; session.login.password = AUTHOR_PASSWORD; session.login.user_domain = "mydomain.net"; message.sender.name = "ESP Mail"; message.sender.email = AUTHOR_EMAIL; message.subject = "Test sending plain text Email"; message.addRecipient("Someone", "phoneNum@mms.cricketwireless.net"); message.text.content = "This is simple plain text message"; message.text.charSet = "us-ascii"; message.text.transfer_encoding = Content_Transfer_Encoding::enc_7bit; message.priority = esp_mail_smtp_priority::esp_mail_smtp_priority_normal; message.response.notify = esp_mail_smtp_notify_success | esp_mail_smtp_notify_failure | esp_mail_smtp_notify_delay; message.addHeader("Message-ID: <abcde.fghij@gmail.com>"); } void sendMyMailNow() { if (!smtp.connect(&session)) { Serial.println("failed to connec to smtp sesh"); return; } else if (!MailClient.sendMail(&smtp, &message)) { /* Start sending Email and close the session */ //Serial.println("Error sending Email, " + smtp.errorReason()); } }
Risto Vesanto in MATLAB Answers
上次活动时间: 2021-9-27

Hi the aplication works fine but the command TURN_ON does not pass to the if-sentense. I saw some ware else solution to this poblem adding a senstence index on the POST function? Unfortunately I have lost the it an dcan not any more locate it. If there are no commands in the que it returns 0 and the lenght is 5. Below is the print outs from serial monitor First no commands in the que 16:23:25.180 -> checking queue... 16:23:25.180 -> Latest command from queue: 16:23:25.180 -> 0 16:23:25.180 -> 16:23:25.180 -> 16:23:25.180 -> command lenght = 5 Then with TURN_ON 16:26:16.684 -> Latest command from queue: 16:26:16.684 -> 7 16:26:16.684 -> TURN_ON 16:26:16.684 -> 0 16:26:16.684 -> 16:26:16.684 -> 16:26:16.684 -> command lenght = 17 The else sentence else{ Serial.println(" Nothing new."); } also does not react to no new commands. Any help is needed!
MIGUEL MACIEL SILVA in MATLAB Answers
上次活动时间: 2021-8-13

I'm new here and I'm starting, I'm developing an app to control leds, I created field 1 in the thingSpeak that will be a led, and I want in the Arduino ide to check the status of this field, if it is connected, in this case with parameter 1 I I want esp32 to send the command to turn on the led. I followed below images of how I was doing, can you help me?
Raghunath H in MATLAB Answers
上次活动时间: 2021-7-30

I am working on a project to send GPS data from a Neo 6M GPS module connected to TTGO board, to Thingspeak and Blynk using the SIM800L module on the TTGO. For this i have combined two sketches avaiable on the internet.(Thank you to original coders) The first sketch sends GPS Data to Blynk using SIM800L. (Using ESP32 TTGO board) The second sketch sends GPS data to Thingspeak via Wifi. (Using ESP8266) So I combined the two sketches with a bit of editing to achieve what i want. However, the code is not compiling and unable to upload to the TTGO board. I am sure in the cut and paste of sketches i might have made some errors. I am just a newbie and just tinkering with the code. The error is : no matching function for call to 'ThingSpeakClass::begin(ThingSpeakClass&)' Can anyone please point out the error and correct it. Thanks /* GPS Tracker With SIM. Uploading data to Blynk APP and Thingspeak. * */ // TTGO T-Call pin definitions #define MODEM_RST 5 #define MODEM_PWKEY 4 #define MODEM_POWER_ON 23 #define MODEM_TX 27 #define MODEM_RX 26 #define I2C_SDA 21 #define I2C_SCL 22 #include <TinyGPS++.h> //https://github.com/mikalhart/TinyGPSPlus #include <AceButton.h> // https://github.com/bxparks/AceButton #define BLYNK_PRINT Serial #define BLYNK_HEARTBEAT 30 #define TINY_GSM_MODEM_SIM800 #define ThingSpeak client #include <TinyGsmClient.h> // https://github.com/vshymanskyy/TinyGSM #include <BlynkSimpleSIM800.h> //https://github.com/blynkkk/blynk-library #include <Wire.h> #include "utilities.h" #include "ThingSpeak.h" // Variables for storing GPS Data float latitude; float longitude; float speed; float satellites; String direction; // Set serial for GPS Module #define SerialMon Serial // Hardware Serial for builtin GSM Module #define SerialAT Serial1 //const char apn[] = "www"; const char apn[] = "airtelgprs.com"; const char user[] = ""; const char pass[] = ""; // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). const char auth[] = "2xxxxxxxkbBOa3ZlPf"; unsigned long myChannelNumber = 1xxxxxx30; const char * myWriteAPIKey = "XxxxxxxxxxxAF"; static const uint32_t GPSBaud = 9600; TinyGPSPlus gps; WidgetMap myMap(V0); BlynkTimer timer; TinyGsm modem(SerialAT); unsigned int move_index = 1; void setup() { // Set console baud rate Serial.begin(115200); delay(10); // Keep power when running from battery Wire.begin(I2C_SDA, I2C_SCL); bool isOk = setPowerBoostKeepOn(1); SerialMon.println(String("IP5306 KeepOn ") + (isOk ? "OK" : "FAIL")); // Set-up modem reset, enable, power pins pinMode(MODEM_PWKEY, OUTPUT); pinMode(MODEM_RST, OUTPUT); pinMode(MODEM_POWER_ON, OUTPUT); pinMode(SMS_Button, INPUT); pinMode(Call_Button, INPUT); digitalWrite(MODEM_PWKEY, LOW); digitalWrite(MODEM_RST, HIGH); digitalWrite(MODEM_POWER_ON, HIGH); // Set GSM module baud rate and UART pins SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); delay(3000); // Restart takes quite some time // To skip it, call init() instead of restart() SerialMon.println("Initializing modem..."); modem.restart(); String modemInfo = modem.getModemInfo(); SerialMon.print("Modem: "); SerialMon.println(modemInfo); // Unlock your SIM card with a PIN //modem.simUnlock("1234"); SerialMon.print("Waiting for network..."); if (!modem.waitForNetwork(240000L)) { SerialMon.println(" fail"); delay(10000); return; } SerialMon.println(" OK"); if (modem.isNetworkConnected()) { SerialMon.println("Network connected"); } SerialMon.print(F("Connecting to APN: ")); SerialMon.print(apn); if (!modem.gprsConnect(apn, user, pass)) { SerialMon.println(" fail"); delay(10000); return; } SerialMon.println(" OK"); Blynk.begin(auth, modem, apn, user, pass); timer.setInterval(5000L, checkGPS); ThingSpeak.begin(client); ///////////////////////////////////////////// //Error on this line } void checkGPS() { if (gps.charsProcessed() < 10) { Blynk.virtualWrite(V4, "GPS ERROR"); } } void loop() { while (Serial.available() > 0) { if (gps.encode(Serial.read())) displayInfo(); } Blynk.run(); timer.run(); sms_button.check(); call_button.check(); } void displayInfo() { if (gps.location.isValid()) { double latitude = (gps.location.lat()); double longitude = (gps.location.lng()); double speed = (gps.speed.kmph()); float satellites =(gps.satellites.value()); String direction = TinyGPSPlus::cardinal(gps.course.value()); String latbuf; latbuf += (String(latitude, 6)); Serial.println(latbuf); String lonbuf; lonbuf += (String(longitude, 6)); Serial.println(lonbuf); String speedbuf; speedbuf += (float(speed)); Serial.println(speedbuf); String dirbuf; dirbuf += (String(direction)); Serial.println(dirbuf); float satbuf; satbuf += (float(satellites)); Serial.println(satbuf); ThingSpeak.setField(1, latbuf); ThingSpeak.setField(2, lonbuf); ThingSpeak.setField(3, speedbuf); ThingSpeak.setField(4, dirbuf); ThingSpeak.setField(5, satbuf); ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); delay(20000); } else { Serial.print(F("INVALID")); } Serial.print(F(" Date/Time: ")); if (gps.date.isValid()) { Serial.print(gps.date.month()); Serial.print(F("/")); Serial.print(gps.date.day()); Serial.print(F("/")); Serial.print(gps.date.year()); } else { Serial.print(F("INVALID")); } Serial.print(F(" ")); if (gps.time.isValid()) { if (gps.time.hour() < 10) Serial.print(F("0")); Serial.print(gps.time.hour()); Serial.print(F(":")); if (gps.time.minute() < 10) Serial.print(F("0")); Serial.print(gps.time.minute()); Serial.print(F(":")); if (gps.time.second() < 10) Serial.print(F("0")); Serial.print(gps.time.second()); Serial.print(F(".")); if (gps.time.centisecond() < 10) Serial.print(F("0")); Serial.print(gps.time.centisecond()); } else { Serial.print(F("INVALID")); } Serial.println(); } { if (gps.location.isValid() ) { latitude = (gps.location.lat()); //Storing the Lat. and Lon. longitude = (gps.location.lng()); Blynk.virtualWrite(V1, String(latitude, 6)); Blynk.virtualWrite(V2, String(longitude, 6)); myMap.location(move_index, latitude, longitude, "GPS_Location"); speed = gps.speed.kmph(); //get speed Blynk.virtualWrite(V3, speed); direction = TinyGPSPlus::cardinal(gps.course.value()); // get the direction Blynk.virtualWrite(V4, direction); satellites = gps.satellites.value(); //get number of satellites Blynk.virtualWrite(V5, satellites); } }
Christopher Stapels in Discussions
上次活动时间: 2021-6-24

Are you using ESP32 and want to help us develop functionality for it? We are looking to add support for ESP32 boards in MATLAB. If you have experience with ESP32 and care to share your workflows with us, please let me know here and we will reach out to you for a short interview. ESP32 support for MATLAB thingspeak esp32 new features matlab
MIGUEL MACIEL SILVA in Discussions
上次活动时间: 2021-4-7

I am new to the subject but I want to learn, I wanted to know how I use my esp32 to activate a relay (to connect devices and or lamps) from a distance with my cell phone. what do I have to use for this or what procedures should I follow, thank you how to trigger a relay with esp32 and the thingSpeak ESP32 subscribes to a ThingSpeak channel. App on your phone sends API command to the ThingSpeak channel. have any tutorial or video showing how this is done? I am having trouble finding it, I speak Portuguese I am researching in English because there are more things, but it is more difficult for me, I even write this using the translator if there is something wrong, sorry I don't have a specific one that I know about. This video on connecting the ESP32 to ThingSpeak might help: <https://www.youtube.com/watch?v=F1fQ8m3S8-4> relay esp32 noob

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