With my ESP32 Board, Wemos Lolin32, I would like to make a http GET request to "http://www.arduino.cc/asciilogo.txt", read the text file and print the text file to the serial monitor.
The question is: Why isn't basically the txt file written to the serial monitor? How can it be achieved? Do I need some kind of conversion of the char?
I am using similar code to that from this example https://www.arduino.cc/en/Tutorial/HttpClient. Basically the code can be reduced to this minimal example:
#include <WiFi.h>
#include <HttpClient.h>
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi..");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println(".");
}
Serial.println("Connected to the WiFi network");
pinMode(LED_BUILTIN, OUTPUT);
Serial.println("SETUP FINISHED");
}
void loop() {
Serial.println("Connecting to httpClient");
HttpClient httpClient;
httpClient.get("http://arduino.cc/asciilogo.txt");
while (httpClient.available()) {
char c = httpClient.read();
//Serial.print(c);
Serial.write(c);
}
}
The expected result is: I would like to see the characters from the txt file (https://www.arduino.cc/asciilogo.txt) in the serial monitor.
The actual result is: The connection to the WiFi can be established. In the serial monitor either question marks or strange symbols are displayed.
I have checked the baud and it is the same in the code and in the monitor. I tried to change this value, but it did not help.
