• Hi,
    For some odd reason the code is as follows; Just playing around and bumped into the issue.
    Is anyone else seeing this issue ? I am uploading directly to the ESP8266

    var wifi = require("Wifi");
    var server = "";
    var mqtt = require("MQTT").create(server);
    mqtt.on('connected', function() {
    mqtt.on('publish', function (pub) {
      console.log("topic: "+pub.topic);
      console.log("message: "+pub.message);
      for(x in data)
      //wifi.connect("ABC", {password:"xyz"}, function(err){
      //  console.log("connected? err=", err, "info=", wifi.getIP());
      wifi.connect("Zain-E5577-0462", {password:"85887536"}, function(err){
        console.log("connected? err=", err, "info=", wifi.getIP());
          keep_alive: 60, // keep_alive[seconds]
          port: 1883, // port number
          clean_session: 1883, // port number
          username: "xyz", 
          password: "xyz", 
          protocol_name: "MQTT", // or MQIsdp, etc..
          protocol_level: 0, // protocol_level

    Error As follows;

    Uncaught Error: Function "write" not found!
     at line 1 col 35
    ....log("Client connected");b.write(a.mqttConnect(a.clie­nt_id))...
    in function "d" called from line 3 col 143
    in function "connect" called from line 1 col 184
    in function called from system
  • Same problem here. Could you find a solution?

  • I think this is related to module size. What build are you using on ESP8266?

    When the ESP8266 port started we had 1300 JSVars. We had to cut down the MQTT module to bare basics to get it to load and leave some space for application code.

    But there are now some ESP8266 builds out there with 1600 (even 1700 JSVars) and I do wonder if the core module would run in this - I haven't had opportunity to test.

    Maybe seek out one of the latest builds - with 1600/1700 JSVars, and try again or try this cut down MQTT module which has worked very well for myself and a couple of others.


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

[Uncaught Error: Function "write" not found!] MQTT on ESP8266

Posted by Avatar for NodePool @NodePool