Arduino RP2040 Message to WhatsApp

Hello,

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;
              ^~~~

Thank You

Are the errors a secret?

Yep I like to keep you guessing, updated original post.

which HttpClient library and which RP2040?

HttpClient.h library, as I am using the exact code from the tutorial for now to try and test the functionality.

Board is - Arduino Nano RP2040 Connect with headers

Thank You

You use the wrong forum. Good night.

That was a joke - he added the info

1 Like

So the one from Arduino?

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 will look into it, thank you.

Bad taste but it doesn’t matter. It’s not my territory. The thought was asking for information for You, knowing people.

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.

Thanks

This is the host you want to reach out to, so whatever WhatsApp makes available (I don’t use it).