Finally - cheap WiFi?

Posted on
of 4
/ 4
Last Next
  • My 2 cents :-)
    TI got a chance to sell a product. This failed because of bad support and ignoring problems. Why should somebody try again immeadiately. The ball is in their hand now, to change behavior.
    In the meantime its a good idea to test other options. One more reason is the price, if Gordon gets the ESP8266 up and running, this will be a better choice than (potentially) wasting more time with TI tools.

  • Looks like there's now a forum for the chip on

    Lots of interesting info there, and it seems they're getting close to being able to compile software that runs on the chip itself. Sadly I'm not sure it's got enough internal memory to be able to run Espruino - that would have been awesome :)

    The main reason for this module is the price - I don't think TI is ever going to be able to hit the $5/module price point, no matter how hard they try.

  • Just got mine through the post from ElectroDragon. I was up and connected to my WiFi network in 10 mins vs. roughly 1 week for CC3000.

    I'll try and write a page with instructions as I go along.

    It's still a bit of work to write a module for Espruino (to interface with the HTTP client/server), but it doesn't look like it'll be that hard.

  • Mine should arrive next week.
    I would like to help in testing the module, once a first version is available.

  • I've ordered a couple. Would like to help testing. Can't believe the price!

  • There's a branch of the code where I'm working towards basic ESP8266 support... It's on GitHub here

    I haven't tested it yet, but it should be enough to send 'AT+RST' and wait for a response. Once that's going, actually implementing the socket send/receive part shouldn't be too hard.

  • Well, the code on GitHub is going to need a bit more work, but in the mean time put this code in, and do each of the commands in comments one after the other:

    Serial4.setup(115200, { rx: C11, tx : C10 });
    var line = "";
    Serial4.on('data',function(c) {
      line += c;
      if (line.substr(0,5)=="+IPD,") {
        // input data
        var colon = line.indexOf(":",5);
        if (colon>=0) {
          var len = parseInt(line.substr(5,colon-5));
          if (line.length-colon > len) {
            line = line.substr(colon+len+1);
      } else {
        // simple lines
        var i = line.indexOf("\n");  
        while (i>=0) {
          line = line.substr(i+1);      
          i = line.indexOf("\n");
    Serial4.print('AT+CIPMUX=0'); // single connection
    var cmd = "GET / HTTP/1.0\r\n\r\n";

    Part of me is wondering if it's not easier to just implement the whole driver in JavaScript :)

  • Good news - the following now works:

    Serial4.setup(115200, { rx: C11, tx : C10 });
    var wifi = require("ESP8266").connect(Serial4, function() {
      wifi.connect("BTHub4-5ZN2","2f3b5659ad",­ function() {
        console.log("Waiting 10 secs for connect...");
        setTimeout(function() {
          require("http").get("­", function(res) {
        }, 10000);

    Although received data is not passed back - but it at least shows it can work.

    Also it doesn't fit in flash any more - we may need an specific compile for this like we do for WIZnet :(

  • Neat! Looking forward to trying it out!

    At the prices people are talking about these modules going for, assuming they actually do work well (ie, unlike TI's Constant Crash 3000), this is gonna blow all the other MCU-network-connectivity options out of the water. Hell, for that matter, why even use an NRF24, if you can get WiFi for the same price? Very exciting times.

  • It doesn't fit in flash anymore is a bad limitation.
    Specific compiled version like the WIZnet could be an option. Bad side of the medal is grow in maintenance.
    I wonder if there could be a way to load additional precompiled modules into flash, something like requireASM("CC3000")
    This way we could have a base Espruino, and a lot of additional modules. Optional modules (from my point of view) could be:

    • CC3000 (including WLAN and all of http...)
    • WIZnet(including WLAN and all of http...)
    • debug (sizeOf,...)
    • ESP8266(including WLAN and all of http...)
    • fs + File
    • FFT and others

  • IMO, neither 256k flash nor 48k of ram are enough for Espruino...

  • Order on 7th of sept, and got the ESP8266 via certified mail here in Germany 5 minutes ago.
    Hope to find some time this week to play with.

  • Pulling in extra functionality is possible for smaller stuff, but for anything like WiFi it's a lot of extra work, a lot of extra scope for bugs, and will never be as efficient as if the code was compiled in. Realistically the best option is probably to offer an online 'configurator' that lets you build a firmware image with the features that you want.

  • Realistically the best option is probably to offer an online 'configurator' that lets you build a firmware image with the features that you want.

    I like that solution. It sounds mostly straightforward to implement - though it gets more complicated when you have to figure out how to handle the time it takes to compile, and make sure that two people don't try to build at once.

    Also - what's the state of ESP8266 support right now? does httpRequest return the data yet? (I haven't gotten a chance to play with this at all, as I've been spending most of my spare time rebuilding computers. Had 3 system failures in a month, one of which took out my development system, which I just got back on weds... and they'd reinstalled stock win 8.1, so I had to retame/rebuild it). I may have a chance to give it a try this weekend, now that I've finally got all my computers working again.

  • I got my ESP8266 on tuesday.
    First problem was powersupply of 3.3V, which cannot be solved by Espruino board.
    Had to wait 2 more days to get an regulator.
    Things working in a module, something like pre-alpha status is:

    • reset
    • connect to my wifi at home
    • read ip, this was a complex part, at the end a 10 sec delay made it more reliable
    • get data from my local server using IP-address (192.168.1....)
    • get data from, there might be undetected problems with DNS
      Next step will be to get data from subdirectory on server, the example I found looks strange to me, so lets wait and see.
      Main problems I ran into are:
    • esp8266 returns commands first, before sending requested information (like getIP)
    • in console.log I often get double charaters (like instead of given espruino)
    • its hard to recognize end of data comin from esp8266, (e.g. whats the end of get data, could be "OK\r\nOK\r\n", but need more testing
    • didn't find a command to setIP
    • DNS is hardcoded, according to some information I found
      All together its a 3.50€ chip and I got a lot working in short time. Reliability is not a question as long as I still have to get functions like "get Data from url" up and running. And last not least, status of coding is something like pre-alpha.
  • @JumJum did you just write your own module in JS, or are you using the one that I have integrated with Espruino? The thing about the Espruino one is you'll get the HTTP client/server as well as sockets/websockets when I get around to implementing them.

    Was the 3.3v regulator info I put on helpful?

    Does DNS 'just work', or is it a separate command that you need to send in order to get the IP?

    @DrAzzy the code in GitHub will do HTTP GET, returning the data correctly and everything. It doesn't 'know' when WiFi is connected though - hence the 10 sec delay. There's no support for HTTP server yet, or multiple HTTP sockets - but that those shouldn't be that hard to add.

  • Hello Gordon,
    I created my own module in Javascript. Main reason was to get my hands on. As soon as Espruino supports this, I will switch.

    Regulator would have been helpful, but I did not get it quickly, so I ordered another one (LF33CV) which has different layout. I added capacitor on input and output.

    I'm unsure about DNS. Just tried to read /modules/servo.js from and got a 404.
    Reading / from at least returns something, but it is not your homepage.
    Reading a file in subdirectory from a server in my home network, using ( works fine.

  • Cool. I was considering doing that too. It's a lot faster to develop :)

    Yes, you'd expect that with the website... like a lot of servers, the Espruino one serves up different websites (Espruino, pur3, morphyre) from the same ip.

    I think you have to specify the website name in a header field to get the correct one - can't remember which one though - you'd have to Google it or see what your pc does.

  • Hello Gordon,

    just tried it with my own server ( and got it working with this:
    cmd = 'GET ' + adr + ' HTTP/1.0\r\n Host:' + host + '\r\n\r\n';
    where host="" and adr="/Juergen/index.htm"

    trying the same with host="" and adr="/modules/servo.js" returns a 404 from

    using host="" and adr="/modules/servo.js" gives a totally strange feedback, echo of command is this: "Host:http://www.Espruino.comrvo.js"which is very strange in my eyes

    testing with a subdomain from my server it works fine
    host="" adr="/"

    hope this helps a little bit for your testing.

  • It could just be case sensitivity... Did you try it with all lowercase letters?

    The strange feedback is probably just the terminal. /r/n gets used for newline, and /ris carriage return, which will move the cursor to the beginning of the line.

  • lowercase helped in (2nd version), thanks

    host="" and adr="/modules/servo.js"
    returned an 301 (object moved permanently)

    host="" and adr="/modules/servo.js"
    made it
    why in .... is www. missing in 2nd option ? In editing I see it, but in forum its missing.
    One more try it should be w w

  • Finally I got a first version up and running (at least in my environment) which

    • initializes ESP8266
    • connects to wireless
    • gets IP adress
    • reads html from a server
    • listens to a port
      To get it running, you have to change mySSID and myPassWD in attached code.
      Give it some time, about 20 secs, and you should then get:
      init true
      getIP: true IP in your network can be different
      readUrl: true Copyright.... source of servo.js
      ***} ***
      Simple test for listening is to open a browser and open "
      then you should get a line :
      listen: /?hugo=27

      function ESP8266(s,bd,rx,tx){
      var sp = s, rdata = "", wText = "",cb,timr,command = "",me = this; 
      me.dbg = false;
      function sendCommandWaitFor(cmd,waitText,waitFor,­callback,skipCommand){
      var rdata = '', timr,scmd = 'AT+' + cmd + '\r',p;
      timr = setTimeout(function(){ 
        rdata += d;
          p = rdata.indexOf(scmd + '\r\n');
          if(p >= 0){
            rdata = rdata.substr(p + scmd.length + 2);
        if(rdata.indexOf(waitText) >=0){
      function sendCommandWait(cmd,waitFor,callback){
      sp.print('AT+' + cmd + '\r');
      setTimeout(function(){ callback(true,""); });
      function connect(ssid,passwd,callback){
        sendCommandWaitFor('CWJAP="' + ssid + '","' +passwd + '"','OK',5000,function(f,d){
      function getIP(callback){
      function init(callback){
      function readUrl(host,adr,port,callback){
      var cmd,rdata,timr,p;
      sendCommandWaitFor('CIPSTART="TCP","' + host + '",' + port,'Linked',1000,
            cmd ='GET ' + adr + ' HTTP/1.0\r\nHost:' + host + '\r\n\r\n';
            sendCommandWaitFor('CIPSEND=' + cmd.length,'>',10000,function(f,d){
              timr = setTimeout(function(){
                rdata += d;
                p = rdata.indexOf("Unlink\r\n");
                if(p >= 0){
      function extractData(d){
      var p,r = "",l;
      p = d.indexOf('+IPD,');
      while(p >= 0){
        d = d.substr(p + 5);
        p = d.indexOf(':');
        r += d.substr(p + 1,parseInt(d.substr(0,p),10));
        p = d.indexOf('+IPD,');
      p = r.indexOf("Content-Length");
      l = parseInt(r.substr(p,r.substr(p).indexOf(­'\r\n')).split(":")[1],10);
      r = r.substr(r.length - l);
      return r;
      function extractListen(d){
      var p,r = "";
      p = d.indexOf("+IPD,");
      if(p >= 0){
        r = d.substr(p).split(" ")[1];
      return r;
      function listen(port,handler){
      var rdata = "",p,q;
        sendCommandWaitFor("CIPSERVER=1," + port,'OK',2000,function(d,f){
              rdata += d;
              p = rdata.indexOf("\r\n");
              if(p >= 0){
                q = extractListen(rdata.substr(0,p));
                if(q !== ""){ handler(q);}
                rdata = rdata.substr(p + 2);
      me.connect = connect;
      me.getIP = getIP;
      me.init = init;
      me.readUrl = readUrl;
      me.listen = listen;
      var esp = new ESP8266(Serial4,115200,C11,C10);
      var mySSID = "changeThis", myPassWD = "changeThis";
  • Great! glad it's working. The replacement of www is just the forum detecting the link.

    It seems like the forum also changes www to http://www in the preformatted code (which anyone copying this example would need to be aware of). I'll see if microcosm can do anything about it...

    Also, just FYI: If you have a website that's available on and then google treats it as two websites and indexes it twice - so I've got just with a redirector, which is what you were hitting.

  • Just seen in another conversation, you are working to support ESP8266.
    Please take care to new versions of firmware.
    There are some interesting commands and changes:

    • commands need to be followed by /r/n, in older version /r only worked fine
    • AT+CIUPDATE is a command to update firmware from a cloud, if modul is connected to wifi
    • ATE0 switches echo off and ATE1 switches it on again. This can help, you don't have to skip echo anymore
      Another new version, which I cannot get running is V0.922 which adds AT commands to change baudrate, changing default from 115200 to 9600 same time. There is another command for watchdog handling, but as said before I didn' get it running reliably.
  • Thanks for the update... Hopefully I'll provide something basic (HTTP client+server, sendCommandWaitFor, etc) and will leave the more advanced stuff like the firmware update (which is a great addition!) to the user.

    Did you ever find a solution to the wait after CWJAP? It would be nice to get a callback after connection happened, rather than having these arbitrary waits.

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

Finally - cheap WiFi?

Posted by Avatar for Gordon @Gordon