Hey guys, so i currently have an Arduino and a WeMoS D1 Mini connected to each other, using the WeMoS as wifi access point, i have the two devices connected as follows:
Arduino
WeMoS
5V
5V
GND
GND
1 (TX)
5 (RX)
As i only need to send data from the Arduino to the WeMoS to send online i don't have the RX of the Arduino connected to the TX from the WeMoS.
The issue i'm having is that after ~30 seconds, the WeMoS stops receiving anything from the softwareserial that's listening to pin 5, disconnects from the MQTT broker and thus stops transmitting data to the server. When resetting it manually, it does re-connect to the MQTT broker for a few seconds and then disconnects again, but never transmits nor receives data over the softwareserial.
I double checked if my Arduino maybe stopped sending data but it does this every 5 seconds constantly so the problem is not on the Arduino board.
Through a regular cable (USB-B to USB-A)
Not the barrel jack, the Arduino does function as it should with everything connected to it, and the WeMoS is only a wifi access point.
pert:
What firmware do you have on the WeMos? If it's a custom sketch, please post it here.
The regular, didnt install any, it's the stock firmware
wvmarle:
Make sure you have a voltage divider on the Arduino TX as the WeMOS is a 3.3V device.
What output do you get from the WeMOS? Any stack dump on the Serial console? That's often a great help in debugging and finding crashes.
Nothing, no stack dumps or any errors, it just stops working, do you think powering through 3.3v instead would fix the issue? It works fine on another device, which hss a different purpose. However that one is the newer LOLIN model.
So i decided to power the WeMoS on its own to rule out the powering issues, and when they are not connected through any power cables, just data, and both are powered with their own USB cable, it still crashes.
This may be your problem.
If an incomplete string comes in, this function times out after 1,000 ms.
The ESPs WDT times out and resets the module after 250 ms.
Use something like this, non-blocking, just reads the character when it's available:
char buffer[20];
uint8_t pos;
void loop() {
if (Serial.available()) {
char c = Serial.read();
if (c == '\n') {
// string complete. Handle it.
}
pos++;
if (pos == 20) {
// string too long!
}
}
}
GSerum:
So i decided to power the WeMoS on its own to rule out the powering issues, and when they are not connected through any power cables, just data, and both are powered with their own USB cable, it still crashes.
That is not what the suggestion is, the Arduino is 5V logic, the WeMOS is 3.3V logic.
Have you tried a potential divider on the Arduino Tx to drop the 5V logic signal the WeMOS 3.3V logic?
I hope the gnds of both controllers are connected together.
Thanks.. Tom...
TomGeorge:
Have you tried a potential divider on the Arduino Tx to drop the 5V logic signal the WeMOS 3.3V logic?
That is not normally a cause of the ESP crashing. It's more likely a cause of the ESP burning. So that means it's not crash and burn, but crash or burn
Crashing (stopping to communicate but recovering just fine after a reset) points to a software issue or power supply issue. As OP hasn't mentioned motors or other common troublemakers I'm expecting the first. Blocking functions like Serial.readString() are a very common cause of an ESP crashing.
This may be your problem.
If an incomplete string comes in, this function times out after 1,000 ms.
The ESPs WDT times out and resets the module after 250 ms.
Use something like this, non-blocking, just reads the character when it's available:
char buffer[20];
uint8_t pos;
void loop() {
if (Serial.available()) {
char c = Serial.read();
if (c == '\n') {
// string complete. Handle it.
}
pos++;
if (pos == 20) {
// string too long!
}
}
}