Wemos D1 mini loses sketch after reconnect

Hello, I have this kind of issue. My sketch is being compiled and runs ok to my Wemos D1 mini and Blynk, but once I pull out the usb cable that powers the Wemos and reconnect it then it acts like it wasn’t uploaded so I have to re-upload it again through Arduino or press reset button while Blink writes “Device is offline”.

Do you have anything connected to the pins of the D1 mini?

Pete.

What does Serial monitor show after reconnecting? If it shows wdt reset, have another look at your code, especially if some of virtual pins are overlapping.

Yes Pete, I have in D7 a motion pir sensor and in D4 is the inbuild led, but I’ve also tried to upload code without connecting anything

where should I write the line so it can check the serial monitor at the beginning, by now it only checks if a person passed by a pir sensor and sends message, I just use one virtual pin (V0)

To see the messages from the D1 Mini (as opposed to messages from the uploaded code running on the device) you’ll need to have your serial monitor set to 74880 baud.

That’s why it’s a good idea to use serial.begin(74880), so that the messages from the D1 mini itself and the messages from serial prints in your code can be seein in the same serial window without changing the baud rate settings.

Pete.

Ok I changed the baud rate and when I reconnect the power nothing is written, on the other hand when I press reset it tells me this :
ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld

i think this is the normal “message” on button reset. you should get something similar message when the error happens, and that would be interesting to google.

But it doesn’s “say” anything when I reconnect it’s just empty that’s the problem, do you think that I should put any 10k resistor between 3v3 and D3 or any other external connection or wemos takes care all of these connections.

That’s really strange. I work with Mini D1, never had similar problem. Every flash is successful, if the code is not right, you will have wdt reset in Serial monitor. Blank Serial monitor means that module flash memory is empty. Maybe your module is faulty.

no, you shouldn’t.
based on the information you provided, maybe you have a defective unit… probably the flash chip.

if you have soldering skills and equipment, you can try to replace the flash chip, or, at least try to “rework” the solder on the chip pads. maybe one is not making a good contact…

but considering the price of those wemos units, it could be better to buy a new one.

2 Likes

Something last I’ve noticed this happens when I reconnect the power from the usb port, so if a project is powered by my pc for example and reconnect it, it loses the sketch BUT if I power it through a wall adaptor then the sketch isn’t lost…strange things…

Sorry for this silly comment in advance…just a small joke…:sweat_smile:

1 Like

Do you have a decent wall adapter? They can be quite picky…

I think it’s the OP’s computer that’s being picky.

2 Likes

Also possible, not all USB ports are created equally …

1 Like

It’s quite rare for a PC’s USB to be below spec but quite common for wall adaptors to be utter cr*p (I have quite a few).

1 Like

@KOTSOS5 let us know which version of the ESP Arduino core you are using?

Where can I check this Costas?

Mentioned a few times already in recent topics (and Google :stuck_out_tongue_winking_eye: )… Using your IDE, the ESP core can be determined by ToolsBoard:Board Manager… Filter search for ESP.