Avatar for Aleksandrs

Aleksandrs

Member since Sep 2016 • Last active Dec 2016
  • 10 conversations
  • 41 comments

Most recent activity

  • in ESP8266
    Avatar for Aleksandrs

    I have litle bug i don`t understand ...

    function startDevice(){
      require( fs.item('Generalscript').module() );
      var Generalscript = require("Generalscript").Generalscript;
      var gs = new Generalscript();
      gs.getVer();
    }
    
    Uncaught Error: Both arguments to addCached must be strings
     at line 1 col 41
    Modules.addCached(this.k,this.toString()­),this.k;
                                            ^
    in function "module" called from line 1 col 42
    require( fs.item('Generalscript').module() );
                                             ^
    in function "startDevice" called from line 23 col 24
               startDevice();
                           ^
    in function called from system
    
  • in ESP8266
    Avatar for Aleksandrs

    I now found my problem .. MQ135 Analog Out is 0-5V, ESP8266 Analog Read only from 0-1V ... now please help to rising this questions.. need Resistor divider?

  • in ESP8266
    Avatar for Aleksandrs

    I found answer.. http://forum.espruino.com/conversations/­283045/

    I just use

    if need update
    
    var fs = new(require("FlashStoreWrite"))(0x7c000)­;
    // Save module source in EEPROM
    fs.item('MyGeneralScript').wget('http://­MyScript location');
    
    
    E.on('init', function() { 
    var fs = new(require("FlashStore"))(0x7c000);
    
    require( fs.item('MyGeneralScript').module() );
    var MY = require("MyGeneralScript");
    });
    

    Full my code:

    // Init ESP8266
    var ESP8266 = require("ESP8266");
    //ESP8266.setLog(1);
    //ESP8266.printLog();  
    E.setClock(80);
    // 18:FE:34:Cb:33:66
    
    var fs = new(require("FlashStoreWrite"))(0x7c000)­;
    var rfs=new(require("FlashStore"))(0x7c000);­
    var Config = rfs.item('config').valueOf();
    console.log(Config);
    
    
    var sleep = 0;
    var objectToSend = {};
    
    objectToSend.id = 'd03';
    
    // Init WiFi Networks
    var wifi = require("Wifi");
    wifi.setHostname(objectToSend.id);
    wifi.connect("XXX", {password:"XXX"}, function(err){
      setTimeout(function(){
    	objectToSend.internalIp = wifi.getIP();
    	//console.log("connected? err=", err, "info=", wifi.getIP());
    	initDevice();
      },2000);
    });
    wifi.stopAP();
    wifi.save();
    
    
    function initDevice(){
    
        var http = require("http");
        http.get("MYLINK", function(res) {
          res.on('data', function(data) {
    
            var tt = JSON.parse(data);
            sleep = tt.sleep; // Set sleep time
    
            if(tt.ver>Config.ver){
              console.log("GETTING NEW FIRMWARE");
              fs.item('config', tt);
              // Save new general scipt
              fs.item('Generalscript').wget('LINK TO MY SCRIPT');
            }
    
    
    
            if(tt.debug==1){
    
              console.log("DEBUG");
              digitalWrite(D2,0); // Enable LED
              startDevice();
    
            }else{
               digitalWrite(D2,0); // Disable LED
               startDevice();
    
            }
    
          });
        });
    
    }
    
    
    
    function startDevice(){
    
      // Retrieve module source, add to module cache and then use..
      require( fs.item('Generalscript').module() );
      var GeneralScript = require("Generalscript").Generalscript;
    
      var gs = new GeneralScript();
      gs.getVer();
    
    
    }
    
    
    
    
  • in ESP8266
    Avatar for Aleksandrs

    Yes i have 2x device in my home he is WiFi.. sets getting temperature... every time he from Deep sleep he going to my web server and check last Script..,, in WEB server i have Mydevice.min.js and need to be flash automatically.

  • in ESP8266
    Avatar for Aleksandrs

    This is possibly ?

  • in ESP8266
    Avatar for Aleksandrs

    Yes this is good idea..

    • 8 comments
    • 5,297 views
Actions