espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.76k stars 741 forks source link

esp8266 does not work when disconnected from IDE #1261

Closed aminjoharinia closed 6 years ago

aminjoharinia commented 6 years ago

Hi, i wrote this code and it is perfectly run on esp8266 ,but when i disconnect it from IDE , IT does not work at all , it even not connected to wifi Am i doing sth wrong? Help me pls

var wifi = require("Wifi");
wifi.setHostname("SAJWWOODY");
wifi.connect("Ultra Speed", {password:"sajwoodind"}, function(err){
 console.log("connected? err=", err, "info=", wifi.getIP());
});
wifi.stopAP();
wifi.save();

var led = new Pin(NodeMCU.D7);

var http = require("http");
var server = http.createServer(function(request,response){
  if(request.url === '/on')
  {
    response.writeHead(200,{'Content-Type':'text/plain'});
    response.end("The Lamp Turned On !");
    digitalWrite(led, 1);
  }
  if(request.url === '/off')
  {
    response.writeHead(200,{'Content-Type':'text/plain'});
    response.end("The Lamp Turned OFF !");
    digitalWrite(led, 0);
  }
  if(request.url === '/'){
    response.writeHead(200,{'Content-Type':'text/plain'});
    response.end("Welcome To SAJ WOOD IND");
  }
});

server.listen(80);
gfwilliams commented 6 years ago

Are you disconnecting it from power or resetting it between? If you haven't explicitly saved your code then that could be the problem?

aminjoharinia commented 6 years ago

@gfwilliams i press "send to espruino" and then it works but if i press reset button or unplug it from power , then plug it in , it does not work at all like there is no program uploaded even after i connected to ide, it does not work i should send my code to espruino again to work Is it because of firmware? i use version 1v94

gfwilliams commented 6 years ago

Just type save() on the left hand side, or choose save on send when uploading. If you have any other questions please ask on the forum - that's what it's for: http://forum.espruino.com/

It'd also be worth looking at the Espruino Quick start and FAQ - they'd probably answer a bunch of your other questions.

aminjoharinia commented 6 years ago

when i type save() or enable save on send i got this error >image<

PrimeTime416 commented 6 years ago

I guest you put the save() on the right hand side of the webIDE, also make sure you only have one save not multiple.

Anthony G. Kerr

On Oct 25, 2017 07:47, "Amin" notifications@github.com wrote:

when i type save() or enable save on send i got this error [image: >image<] https://user-images.githubusercontent.com/6470623/31997055-7d496ddc-b997-11e7-9165-faed298ac076.JPG

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/espruino/Espruino/issues/1261#issuecomment-339303681, or mute the thread https://github.com/notifications/unsubscribe-auth/ATUm_mGyRj7232RDqiP6awCgLebFNv8Rks5svx-5gaJpZM4QB6qf .

aminjoharinia commented 6 years ago

i got this error even my code is

console.log("hi");