Problem of Low Memory in esp32

Posted on
  • Hi All,

    i am transmitting BME680 data to my server using websocket . To doing this i am using espruino 1v99.
    I am facing issue of low memory every time and unable to write bme680 module code into esp32.
    All this things is working fine in espruino 1v96. but i cant use lower version because i have to use BLE feature too.

    My code :

    //reset();
    //E.setBootCode();
    //ws.send("hello world");
    //I2C1.setup({scl:22,sda:23});

    var wifi = require("Wifi");

    E.on('init',function() {
    var i2c = new I2C();
    i2c.setup({sda:32,scl:33});

    var bme = require("BME680").connectI2C(i2c, {addr:0x77});
    var wifi = require('Wifi');

    wifi.connect("saurabh.verma", {password:"test1234"}, function(err){

    var host = "154.0.82.179";
    var WebSocket = require("ws");
    var ws = new WebSocket(host,{
      path: '/',
      port: 8080, // default is 80
      protocol : "echo-protocol", // websocket protocol name (default is none)
      protocolVersion: 13, // websocket protocol version, default is 13
      origin: 'Espruino',
      keepAlive: 60,
      headers:{ some:'header', 'ultimate-question':42 } // websocket headers to be used e.g. for auth (default is none)
    });
    
    ws.on('open', function() {
      console.log("Connected to server");
    });
    setInterval(function() {
          var data = bme.get_sensor_data();
          var sensor = {};
          sensor.AQI = data;
          ws.send(JSON.stringify(sensor,null,2));
          bme.set_sensor_mode(1);
       }, 100);
    

    });
    });
    save();

    Output :

    New interpreter error: LOW_MEMORY,MEMORY

    =undefined
    WARNING: --- gap_setScan 0
    WARNING: Scan stop failed
    WARNING: set rssi scan not implemeted yet
    WARNING: has central connection not implemented yet
    Compacting Flash...
    Calculating Size...
    Writing..
    Compressed 40000 bytes to 14608
    Uncaught Error: Function "connectI2C" not found!
    at line 5 col 31
    var bme = require("BME680").connectI2C(i2c, {addr:0x77});

    When i check a memory
    1v99
    { "free": 2471, "usage": 29, "total": 2500, "history": 0,
    "gc": 0, "gctime": 1.799 }

    its half of previous

  • I need Ble too on same time .

  • See http://www.espruino.com/Saving and try 'Save on send'.

  • Remove your last save() and turn on save on send in the ide as Gordon suggested.

    This then puts the code into flash memory, so it does not take up the ram space.

    You will then have plenty of free vars for you programme to work.

  • Thanks now its working :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Problem of Low Memory in esp32

Posted by Avatar for Saurabh @Saurabh

Actions