• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Firebase and WebSockets on the same ESP32 seem to clash because of JSON

Q&A Forum › Category: ESP32 › Firebase and WebSockets on the same ESP32 seem to clash because of JSON
0 Vote Up Vote Down
Michael Rogulla asked 4 years ago

Hi all, I try to get the “firebase_ESP_client” together with websockets running on the same ESP32. But both seem to use identical JSON definitions, so during compilation I get dozens of errors (see at the end of my post).
 
This is my configuration:
– ESP32 running in WiFi mode softAP plus station AP: “WiFi.mode(WIFI_AP_STA);”
– I use AsyncTCP + ESPASyncWebServer + ASyncElegantOTA
– I can start an AsyncWebserver + Websokets, and I can distinguish between traffic from SoftAP and StationAP.
– the handler of websockets uses a function “handleWebSocketMessage()” which in turn gets the states from a function “getOutputStates()”, and in this function there is a JSON-structure which depends on the include-file named “Arduino_JSON.h”. I got this idea from your book “Build Web Servers with ESP32…” / modue 3 / chapter 2.5 for example.
– When I comment “#include Arduino_JSON.h” and clear “getOutputStates()” everything compiles just fine, and my two APs (soft and station) are responding, but the websocket obviously is silent.
So my conclusion is that firebase_ESP_client and websockets both use JSON from different include-files and the two files use the same names (see error messages below). What can I do to get websockets running?
 
Why do I have this configuration?
– I would like to have a simple webserver running on port 80 on my softAP. I can onnect to this website over WiFi. This website contains a simple webformular to enter new SSID and PASS. SSID and PASS get stored via SPIFFS
– When I reboot my ESP32 the stationAP connects with this freshly configured SSID / PASS to the internet and connects to my firebase.
– The softAP and its IP is static, that way I can always connect to them. That way I can configure the stationAP with different SSIDs, because I want to use my ESP32 in different locations.
 
*********************************************************************************
libraries/Arduino_JSON/cjson/cJSON.c.o: In function `cJSON_GetErrorPtr’:
/home/nutzer/Dokumente/Arduino/Sketches/libraries/Arduino_JSON/src/cjson/cJSON.c:71: multiple definition of `cJSON_GetErrorPtr’
libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/json/cJSON/cJSON.c.o:/home/nutzer/Dokumente/Arduino/Sketches/libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/src/json/cJSON/cJSON.c:103: first defined here
libraries/Arduino_JSON/cjson/cJSON.c.o: In function `cJSON_Version’:
cJSON.c:(.text.cJSON_Version+0x0): multiple definition of `cJSON_Version’
libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/json/cJSON/cJSON.c.o:cJSON.c:(.text.cJSON_Version+0x0): first defined here
libraries/Arduino_JSON/cjson/cJSON.c.o: In function `cJSON_InitHooks’:
cJSON.c:(.text.cJSON_InitHooks+0x0): multiple definition of `cJSON_InitHooks’
libraries/Firebase_Arduino_Client_Library_for_ESP8266_and_ESP32/json/cJSON/cJSON.c.o:cJSON.c:(.text.cJSON_InitHooks+0x0): first defined here
…etc
 

Question Tags: Firebase websockets JSON
4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
 
Yes, the FirebaseClient library uses its own JSON library: https://github.com/mobizt/Firebase-ESP-Client#create-edit-serializing-and-deserializing-the-json-objects.
So, that’s probably what is causing the issue.
 
To be honest, I’m not sure what’s the best way to use both libraries at the same time. Maybe you can ask on the library page and see what they suggest: https://github.com/mobizt/Firebase-ESP-Client/discussions
 
Regards,
Sara 
 
 

0 Vote Up Vote Down
Steve Mercer answered 4 years ago

I would guess that one of those libraries is either a later version of the other or one is a fork of the other. Try deleting one of the JSON library’s and give it a try. If that doesn’t work. try the other way around.

0 Vote Up Vote Down
Michael Rogulla answered 4 years ago

Hi all,
I got in touch with the developer of firebase-client library. He took care of my issue and it seems to be resolved, just update to firebase-client library v2.7.0 After that I can use both libraries together and both with JSON.
Best, Michael.

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

That’s great!
Thanks for letting us know. 
I’ll mark this issue as resolved.
If you need further help, you can open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.