• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 with ThingSpeak

Q&A Forum › Category: ESP32 › ESP32 with ThingSpeak
0 Vote Up Vote Down
Domenico Carvetta asked 5 years ago

Hi Rui

can you please take a few of your time to dedicate to this?

6 Answers
0 Vote Up Vote Down
Domenico Carvetta answered 5 years ago

I have problem using ESP32 with ThingSpeak; viceversa, when I use the ESP8266 no problem.

The problem is related to that no any data is published.

I attach the code I am using to push the data:

if (client.connect(serverTS,80)) {  //   "184.106.153.149" or api.thingspeak.com
              String postStr = apiKey;
                     postStr +="&field1=";
                     postStr += String(t);
                     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.println("% send to Thingspeak");    
            }
            client.stop();

            Serial.println("Waiting...");    
            // thingspeak needs minimum 15 sec delay between updates
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Domenico.

Modify your first lines so that you have something as follows.

String postStr = "api_key=";
postStr += apiKey;
postStr +="&field1=";
postStr += String(t);
postStr += "\r\n\r\n";

Then, tell me if it works.

Regards,
Sara

0 Vote Up Vote Down
Domenico Carvetta answered 5 years ago

Yes, thanks, I tried it unsuccessfully.
I attach the link to monitor the data, best regards.
https://thingspeak.com/channels/80188
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Domenico.

Try this code instead:
https://pastebin.com/m3gsfgsv

Replace with your network credentials and the thingspeak Write API key.

As an example, it is publishing a random number. Replace with your sensor readings.

I’ve tried the example and it is working fine.

I hope this helps.

Regards,
Sara

0 Vote Up Vote Down
Domenico Carvetta answered 5 years ago

Dear Sara,
thanks it works fine ! BR, Domenico
 

0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Great|
I’ll mark this question as resolved.
If you need further help, you just need to open a new question.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.