B4R Question ESP8266/ ESP32 wifi library

RJB

Active Member
Licensed User
Longtime User
I believe the ESP8266 and ESP32 use the same wifi library, is that true?
when I try to run the same software on these two devices the I get different results. The 8266 is OK. The ESP32 gives following error:
B4X:
C:\Program Files (x86)\Arduino\libraries\ESP8266wifi-master/ESP8266wifi.h:23:26: fatal error: avr/pgmspace.h: No such file or directory
what am I doing wrong?
Thanks
 

thetahsk

Active Member
Licensed User
Longtime User
A short look into the r8266wifi.h answered your question and choose the right board in the Board Selector.
B4X:
#pragma once
#include "B4RDefines.h"
#ifdef ESP32
#include <WiFi.h>
#include <WiFiClientSecure.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <WiFiUdp.h>
 
Reactions: RJB
Upvote 0

RJB

Active Member
Licensed User
Longtime User
I'm using 'ESP32 Dev Module' for the ESP32 and 'Generic ESP8266 Module' for the 8266 so what am I missing here?
Any help appreciated.
Thanks
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
Post your complete Project. Have you installed the latest esp32 and esp8266 cores in your Arduino IDE ?
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
esp8266 is working and I updated the arduino IDE and added esp32 to it before trying it yesterday. I also downloaded and installed B4R twice to make sure it wasn't that. I'll try removing and re-adding esp32/ 8266 again just in case. Then I'll strip down the project to the minimum that shows the problem before uploading it.
Thanks
 
Upvote 0

RJB

Active Member
Licensed User
Longtime User
The problem was in some in-line C which had: #include <ESP8266WiFi.h> in it.
I've used the code from #2 above to select as follows:
B4X:
#ifdef ESP32
#include <WiFi.h>
#endif
#ifndef ESP32
#include <ESP8266WiFi.h>
#endif

#else doesn't seem to be available here (error parsing....)

thanks thetahsk for your help.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…