As the title says... Chat on...

User avatar
By DoubleMintBen
#63590 I'm new here, and I'm not sure if this is the right sub to post this in here, if it isn't please let me know and I can move it.

I have a device called a PL Duino. Its an Open source PLC that uses the atmega 2560 chip, and it also uses the ESP 8266. They communicate with each other using serial. I've programmed arduino's for quite some time now, but I've never worked with something like the ESP, and I'm running into some weird issues that I'm struggling to figure out.

I've never flashed a controller until now, and I've never worked with lua until now. I got this product with demo code on the atmega, and the esp flashed with nodemcu and demo code loaded on it as well. With the demo code on it, I could connect to the esp through the atmega using a helper sketch, I could upload code, and reset the device and it would be fine. I could then upload more code to the esp no problem. While uploading the code to the existing demo code, I wasn't changing very much, just putting in simple print statements to try to understand how things were working. I got comfortable enough with it that I decided to make my own files and give it a go. On this chip I have 3 lua files. init.lua, server.lua, and atmega.lua. These are the same names as the files that were on it previously, just with mostly new code on them.

The problem is, as soon as i upload MY code to the ESP, then I reset the device, I am no longer able to upload files to it. The code runs, the server is created, I can see the data its outputting over the wireless just fine, no problems with it, I can open a serial monitor and see the output there as well, no problem, just, whenever I try to upload new code to it, it times out. At this point, the only thing I have been able to figure out to get it back to where I can put new code on it, is to reflash it with nodemcu, which I have to do twice because it doesn't fully work after the first time. Someone told me its an issue with it reading or writing to memory when I try to flash it. I'm not entirely sure what to do, I've done a ton of googling trying to figure this out and I'm just plum stuck.

I'm using ESPlorer to connect to the ESP through the arduino using a helper sketch, which I can put on pastebin if anyone thinks thats relevant to see. I have taken the time to upload the demo lua files to pastebin, as well as my files to pastebin. If someone can see what could cause this to happen, I would greatly appreciate some advice.

DEMO lua files for ESP:
init.lua: http://pastebin.com/7Pg7zZ3J
server.lua: http://pastebin.com/gRm74xAf
atmega.lua: http://pastebin.com/nTymhC9G

MY lua files for ESP:
init.lua: http://pastebin.com/6VuaJCRr
server.lua: http://pastebin.com/T2AasMeN
atmega.lua: http://pastebin.com/P0gV7NHP