The following error messages are copied from the Arduino IDE:
D:\embedded_projects\Random Nerd Tutorials\Random Nerd Tutorial – Smart Home\Smart-Home-eBook-main code\Module_5\5_2_Publish_Subscribe\ESP32_Publish_Subscribe\ESP32_Publish_Subscribe.ino: In function ‘void WiFiEvent(arduino_event_id_t)’:
D:\embedded_projects\Random Nerd Tutorials\Random Nerd Tutorial – Smart Home\Smart-Home-eBook-main code\Module_5\5_2_Publish_Subscribe\ESP32_Publish_Subscribe\ESP32_Publish_Subscribe.ino:46:10: error: ‘SYSTEM_EVENT_STA_GOT_IP’ was not declared in this scope; did you mean ‘IP_EVENT_STA_GOT_IP’?
46 | case SYSTEM_EVENT_STA_GOT_IP:
| ^~~~~~~~~~~~~~~~~~~~~~~
| IP_EVENT_STA_GOT_IP
D:\embedded_projects\Random Nerd Tutorials\Random Nerd Tutorial – Smart Home\Smart-Home-eBook-main code\Module_5\5_2_Publish_Subscribe\ESP32_Publish_Subscribe\ESP32_Publish_Subscribe.ino:52:10: error: ‘SYSTEM_EVENT_STA_DISCONNECTED’ was not declared in this scope; did you mean ‘WIFI_EVENT_STA_DISCONNECTED’?
52 | case SYSTEM_EVENT_STA_DISCONNECTED:
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| WIFI_EVENT_STA_DISCONNECTED
exit status 1
Compilation error: ‘SYSTEM_EVENT_STA_GOT_IP’ was not declared in this scope; did you mean ‘IP_EVENT_STA_GOT_IP’?
I tried to compile the source file “ESP32_Publish_Subscribe.ino” as released (no modifications except for user, password, local host, etc) and received the above errors.
I’m following the tutorial in the book “Smart Home V1.4” and using Arduino IDE 2.3.2. All libraries were installed as per the book.
I’m programming both ESP32 and ESP8266 modules. The ESP8266 version of the software compiled and uploaded to ESP8266 OK.
Code where errors occur:
Hi.
Please copy the code from the github links provided in the eBook.
https://github.com/RuiSantosdotme/Smart-Home-eBook/blob/main/Module_5/5_2_Publish_Subscribe/ESP32_Publish_Subscribe/ESP32_Publish_Subscribe.ino
Those links are always updated.
Don’t copy the code from the PDF.
There was an update on the ESP32 boards and those System_events are no longer used, but the Github link provides the most up-to-date codes.
All codes were recently updated, so always copy them from the link.
For that specific example this is the link: https://github.com/RuiSantosdotme/Smart-Home-eBook/blob/main/Module_5/5_2_Publish_Subscribe/ESP32_Publish_Subscribe/ESP32_Publish_Subscribe.ino
Let me know if this solves your issue.
Regards,
Sara
Thanks for your immediate response!
The answer you provided resolved the issue, but I downloaded the course files from the link on the course webpage that is labeled ” ∙ Download All eBook Resources >> ” . This link is the following:
https://github.com/RuiSantosdotme/Smart-Home-eBook/archive/refs/heads/main.zip
So I unzipped the files into a directory and tried to use them. Obviously, this zip file has an earlier version that does not account for the ESP32 update.
May I suggest that the ” ∙ Download All eBook Resources >> ” link be deleted and replaced with a statement similar to what you told to me, i.e., to ensure that the latest version of the files are being used, retrieve the individual files from GitHub. Thanks to your advice I know better now, but it may help others who try to do the same thing I did. 🙂
Hi.
If you click that link now, it will download the latest code versions.
You probably downloaded it previously to the update.
But, yes, you are right. I’ll try to make it more straightforward and error-proof so that the latest version is always used.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara