I’m trying to use my RP2040 to send error messages to my WhatsAPP account, and am using the example code below. However I keep getting errors around the line “HttpClient http;”. From what I can gather this code works with the ESP32. What changes need to be made to make this work with a RP2040 board?
To test this I am just taking the code below and compiling it for a RP2040 board and after changing all the code from HTTPClient to HttpClient I get the following error. It compiles fine when I use the ESP32 board.
/tmp/.arduinoIDE-unsaved2025829-19497-1kq7ncw.to0nk/sketch_sep29a/sketch_sep29a.ino: In function 'void sendMessage(arduino::String)':
/tmp/.arduinoIDE-unsaved2025829-19497-1kq7ncw.to0nk/sketch_sep29a/sketch_sep29a.ino:28:14: error: no matching function for call to 'HttpClient::HttpClient()'
HttpClient http;
^~~~
The error occurs because you are trying to instantiate HttpClient (note the capital H and C) without parameters. On Arduino, there are two different libraries that people call HttpClient, and they are not interchangeable.
For the one commonly used on RP2040/Arduino (from ArduinoHttpClient), the constructor requires a WiFiClient and the server info, for example:
(Typed here - Check documentation)
#include <WiFiNINA.h>
#include <ArduinoHttpClient.h>
WiFiClient wifi;
HttpClient http(wifi, "example.com", 80); // must provide WiFiClient, host, and port
You cannot just do HttpClient http; with this library
I think you need to loool at he standard Arduino WiFiNINA library together with HTTPClient for HTTP or HTTPS.
I got it mostly working, appreciate the help. The only issue I think I have now is what is the Server I use. Is it the arduino’s IP address or the URL from the WhatsApp API or something else.