I already have MQTT with the ESP32 working via Wifi using the ‘Esp32MQTTClient’ library but now I want to sent the MQTT message via a BG96 modem which is connected to a UART of my ESP32. I already have configured the BG96 to connect to the APN of my SIM card provider. How do I configure the project in a way that the MQTT data is sent via the BG96?
I’ve never used the BG96 modem. So, I’m not sure how things should be done.
Were you able to connect to the internet using that modem and the SIM card?
I guess that after having established an internet connection, you can use the regular commands to work with MQTT.
You probably need to search the AT commands to establish an internet connection: https://www.quectel.com/UploadImage/Downlad/Quectel_BG96_AT_Commands_Manual_V2.1.pdf
In that case, you need to use a cloud MQTTT broker, otherwise you would need to have a broker running on the same network that your SIM card.
I’m sorry that I can’t help much.
Thanks you for your quick reply.
I have configured the BG96 with AT coimmands in a way that it has internet connection. I am using the Arduino MQTT example to send data to a Azure cloud broker and that is working fine. My code is based on the following example: https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/
However, that example is using WIFI to connect to the internet. My question is if I connect to the internet with the BG96 will the code automatically direct the data to the BG96 or what should I do to make that happen?
I think that once you connect to the internet using the BG96 with the AT commands, the code will automatically use that network.
I guess it’s the same principle when using a SIM800 module with internet connection as shown in this example: https://randomnerdtutorials.com/esp32-sim800l-publish-data-to-cloud/