Home › Forums › Mayfly Data Logger › EspressifESP32
- This topic has 7 replies, 2 voices, and was last updated 2026-08-04 at 6:46 PM by
Sabin.
-
AuthorPosts
-
-
2026-07-21 at 10:11 PM #19738
How to connect to Wifi while using this in Mayfly data logger?
I have been trying this codebase or even the one with tinygsm library but nothing works. Is there any pre-configuration that is needed to be done?1234567891011121314151617181920212223242526272829303132333435363738394041424344#include <ModularSensors.h>#include <modems/EspressifESP32.h>#include <Arduino.h>#include "arduino_secrets.h"#define XbeeSerial Serial1const int8_t modemPowerPin = 18;const int8_t modemResetPin = -1;const int32_t modemBaud = 115200;// wifi detailsconst char* wifiId = WIFI_SSID;const char* wifiPwd = WIFI_PASS;EspressifESP32 modem(&XbeeSerial, modemPowerPin, modemResetPin, wifiId, wifiPwd);void connectWiFi() {Serial.println("connecting to wifiiiiii");if (!modem.connectInternet()) {Serial.println("Connection not possible");delay(10000);return;}Serial.println(" success");Serial.println("Wifi is connected");}void setup() {Serial.begin(115200);delay(1000);Serial.println("esp32 test");XbeeSerial.begin(modemBaud);delay(3000);connectWiFi();Serial.println("connection successful");} -
2026-07-22 at 8:35 AM #19739
Never mind. The wifi worked. I used
AT+CWMODE?and change it from SoftAP to Station mode.
But I am struggling to use this to connect to mqtt broker. -
2026-08-04 at 5:29 PM #19766
Were you able to connect to your MQTT broker?
It looks like you’re working from the modem component within Modular Sensors. That component wraps TinyGSM and adds physical pin support for power management. But the wrapping makes it a bit confusing because you have to access objects with pointers and creator functions. And if you’re trying to use the ModularSensors master branch as of 8/4/26, it’s broken. (The last release is fine, just not the current master branch.) Until you have your communication set, I would work directly from the TinyGSM example set which is more direct. After you’ve got your communication set, figure out power.
-
2026-08-04 at 5:36 PM #19767
I have.
Before opening a tcp connection, the Socket Receiving Mode should be made to 1 (passive mode). I have no idea why it works only while doing this. But it works.12345void ExpressifESP32::extraSetupForMQTT(){// See :https://docs.espressif.com/projects/esp-at/en/release-v2.4.0.0/esp32/AT_Command_Set/TCP-IP_AT_Commands.html#at-ciprecvmode-query-set-socket-receiving-mode// This should be done before opening tcp connection_modem.sendAT(GF("+CIPRECVMODE=1"));}I found the modularsensor implementation difficult. Therefore wrote my own small class that wraps tinygsm for the functions that I need.
One thing I found is modemBaud is 57600 which is different from the comments in the esp class
-
2026-08-04 at 5:51 PM #19768
Are you using the original TinyGSM or the EnviroDIY fork? The EnviroDIY fork is far ahead of the original right now. (It’s on my to-do list to have a proper PR.)
I’d (strongly) recommend updating your AT firmware. The current version of TinyGSM on the EnivroDIY fork expects firmware >= 3.2.0.0. Because of changes in the memory mapping for SSL certificates (and other stuff) around version 3.2, you’ll need to completely re-flash the board with esptools/ESP flash download tools instead of using the AT+CIUPDATE function.
-
2026-08-04 at 6:31 PM #19769
I am using EnviroDIY fork. Until now everything is working. I am able to make both http post, and mqtt connection.
I checked and mine esp32 firmware version is 2.4.0. So,Is it because of this lower version, I had to do some hack around for ssl connection?
Below is the part of workaround I coded to make it work with hydroserver.1234567891011121314151617void ExpressifESP32::extraSetupForHTTPS(const char* host, const int port) {// Some HTTPS servers(like playground instance of hydroserver) host multiple domains on the same IP address.// During the TLS handshake, the modem must send the hostname using// Server Name Indication so the server can present the correct// SSL/TLS certificate. Without SNI, the connection may fail even// though DNS resolution and TCP connectivity succeed._modem.sendAT(GF("+CIPRECVMODE=1"));// Ref: https://docs.espressif.com/projects/esp-at/en/release-v2.4.0.0/esp32/AT_Command_Set/TCP-IP_AT_Commands.html#at-cipsslcsni-query-set-ssl-client-server-name-indication-sni_modem.sendAT(GF("+CIPSSLCSNI=0,\""), host, GF("\""));_modem.sendAT(GF("+CIPSSLCSNI=1,\""), host, GF("\""));delay(3000);// See : https://docs.espressif.com/projects/esp-at/en/latest/esp32/AT_Command_Set/TCP-IP_AT_Commands.html#cmd-start// same as above. This also need to be done twice_modem.sendAT(GF("+CIPSTART=0,\"SSL\",\""), host, GF("\","), port);_modem.sendAT(GF("+CIPSTART=1,\"SSL\",\""), host, GF("\","), port);} -
2026-08-04 at 6:43 PM #19770
Yes, those are because of the old firmware. If you’ve got it working, it may not be worth updating, but it should eliminate those work-around.
If you want to use custom SSL certificates, upgrade. The only way to push custom certificates with the old firmware (or with an ESP8266) is to use a python script to write the memory blocks with the new certificate data. And getting that working is much harder than upgrading the firmware. AWS IoT core requires custom certificates.
-
2026-08-04 at 6:46 PM #19771
Thank you so much.
I am not using the AWS stuff for now but I will be deploying mosquitto on cloud at some time.
if this old firmware create problem at that point, I will update the firmware.
Thank you again.
-
-
AuthorPosts
- You must be logged in to reply to this topic.
Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of