0

Can someone post an example code for sending data in a URL using HTTPClient on a ESP32 (I'm using dweet as an example, I have a different site)?

Say I have a sensor data of temperature (24'C - nevermind the "'C", sensor only shows the number which is what I want) and humidity (30%) and want to send those as URL like this: http://dweet.io/sensor.php?temperature=24&humidity=30

I guess header should be "HTTP/1.0".

Ways to send over HTTPS without CA or fingerprint would also be helpful.

Practices to avoid memory leaks and to prevent errors or crashes would be a delightful bonus. :-)

Bluelight
  • 9
  • 4
  • 3
    Try to run all the examples that came with the [HTTPClient library](https://github.com/espressif/arduino-esp32/tree/master/libraries/HTTPClient/examples) first to understand how to use the library. – hcheung Jun 12 '21 at 01:13

1 Answers1

0

You might find the protocol examples provided by ESP-IDF to be very helpful. And there are some tutorials that help with writing those requests as well.

If you do not want to use a CA and just want to have https for testing purposes, then I have found the https-mbedtls example provided by ESP-IDF to be very helpful here, as there is an option to optionally verify the certificate. MBEDTLS_SSL_VERIFY_OPTIONAL can be set to MBEDTLS_SSL_VERIFY_NONE in the https_mbedtls_example_main.c file meaning that you can use self-signed certificates without receiving an error.

Dharman
  • 30,962
  • 25
  • 85
  • 135
MuxD
  • 43
  • 1
  • 6