Cannot find library after changing board

HI ,
Please can someone explain how the library's are associated to the boards..

My project works fine when I compile and upload it to an ESP32 DEV v1
But as soon as I switch to a NODEMCU-32 v1 It failed to find HTTPClient.h and WiFi.h.

I have read that HTTPClient should be lowercase HttpClient.h now.
I tried changing this and it finds the lower case library
but then line 21 "HTTPClient http;" crashes .. it finds the library but even if i change this line to lower case to match the library it doesn't like it .
I took this section of code and this library from someone on youtube but I don't have enough understanding to get this working with the lower case library.

Also, once I switch to the NODEMCU it fails to find WiFi.h "No file or Directory also..

Why does changing the board to another ESP module does it loose the library's .

// https://api.callmebot.com/whatsapp.php?phone=4479&text=This+is+a+test&apikey=356
#include <Stream.h>
#include <Arduino.h>
#include <HTTPClient.h>
//#include <HttpClient.h>
#include <UrlEncode.h>
#include <WiFi.h>

char ssid[] = "Paul5";           // network SSID (name)
char password[] = "abcdeabcde";  // network password
const int ard = 5;
int ardtest=1;
int count=1;
// Change these values to your own!
String telephoneNumber = "44790679";
String whatsappAPIKey = "12986";

 namespace whatsApp {
  void sendWhatsAppMsg() {
  String url = "https://api.callmebot.com/whatsapp.php?phone=" + telephoneNumber + "&apikey=" + whatsappAPIKey + "&text=" + urlEncode("** Garage Entry ! **  ") +count;
  HTTPClient http;
  http.begin(url);
  http.addHeader("Content-Type", "application/x-www-form-urlencoded");
  int httpResponseCode = http.POST(url);
  if (httpResponseCode == 200) {
       Serial.print("WhatsApp message1 sent successfully");
  } else {
        Serial.print("Error sending WhatsApp message1. HTTP response code:");
  }
      http.end();
}
} // End namespace WhatsApp

void setup() {
  pinMode(ard, INPUT_PULLUP);
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      delay(500);
   }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);
  // Power up message before loop
  whatsApp::sendWhatsAppMsg();
}
void loop() {
ardtest = digitalRead(ard);
   if (ardtest==1){

     whatsApp::sendWhatsAppMsg();
     //Serial.print("Cat Detected ");
     //Serial.println(count);  
     count=count+1;
      delay(8000);
    }   else {
    delay(100);
        }
   }

I have additional boards manager set at:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

the error message is :

C:\Arduino\sketches\ESP32WhattsappGarage\ESP32WhattsappGarage.ino:7:10: fatal error: WiFi.h: No such file or directory
7 | #include <WiFi.h>
| ^~~~~~~~
compilation terminated.
exit status 1

Compilation error: WiFi.h: No such file or directory

But this all compiles ok if I go back to the ESP32 DEV board.

Thank you
Paul

The wifi libraries for an ESP8266 have different names than those for an esp32.

WiFi.h doesn't exist but

ESP8266WiFi.h

does.

Also some of the functions may be named differently.

You will have to go through the examples included in the core for specifics on each and everyone of them unfortunately.

a lot of sketches that are made to run on either board type include compiler directives to tell the compiler which library to use for what board.

Hi !
I think you may have misread my problem!
I am not using ESP8266 I am using NodeMCU-32 and ESP32 Dev 1
They are both ESP32 Wroom-32 chips.
So they should surely use/work with the same library's.
Changing between the 2 boards surely should not result in one not finding the correct library.

I have managed a work around, selecting the ESP-WROVER-Module has allowed me to compile and write to the Nodemcu how bazar.
I wish i understood it lol

Hmmm must be something wrong in the boards definitions. Would be interesting to investigate, have you tried a different core version ?

I think the core is also on Github, you could also mention the issue there and maybe they can fix it for future versions.

yes they should. I always wonder why there are so many definitions for what are nearly identical boards.

Hi @puterpaul.

I'm going to ask you to provide the full verbose output from compiling the sketch for each of the boards:

Provide output from "ESP32 DEV v1" compilation

Please do this:

  1. Open the sketch in Arduino IDE.
  2. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  3. Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Select the "ESP32 DEV v1" board from Arduino IDE's Tools > Board menu.
  6. Select Sketch > Verify/Compile from the Arduino IDE menus.
  7. Wait for the compilation to finish.
  8. Right click on the black "Output" panel at the bottom of the Arduino IDE window.
    A context menu will open.
  9. Select Copy All from the menu.
  10. Open a forum reply here by clicking the "Reply" button.
  11. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  12. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  13. Move the cursor outside of the code block markup before you add any additional text to your reply.
  14. Click the "Reply" button to post the output.

Provide output from "NODEMCU-32 v1" compilation

Please do this:

  1. Open the sketch in Arduino IDE.
  2. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  3. Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Select the "NODEMCU-32 v1" board from Arduino IDE's Tools > Board menu.
  6. Select Sketch > Verify/Compile from the Arduino IDE menus.
  7. Wait for the compilation to fail.
  8. You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  9. Open a forum reply here by clicking the "Reply" button.
  10. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  11. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  12. Move the cursor outside of the code block markup before you add any additional text to your reply.
  13. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.