BASIC for ESP8266

Don’t get me wrong, we don’t yet have a fully working interpreter, but a link appeared on my ESP8266WIFI Facebook page thanks to Michael Molinari this morning and I thought I’d give it a whirl.

I grabbed the Windows loader (Windows 10 put up a SEVERE warning about this which I totally ignored), plugged an ESP-01 into my FTDI and blew in the interpreter, all of which took a couple of minutes and zero effort.

At first I didn’t know what to expect, I looked at the serial port – nothing.. then realised it outputs at 9600 baud, not my usual 115K…. I then started typing stuff into the serial – nothing – at which point I noted it already knew about my router – I can only assume that is because the WIFI passwords were already in the board, normally you’d have to use the board as an access point just to put in your WIFI details… anyway, I managed to bypass that.

I checked the examples on the page – hello world and a graphics example – which worked right out of the box!! Imagine that – simple BASIC commands putting out graphics on a web browser from a twopenny WIFI board all on it’s own!!

At this point, things went down a little. I tried editing the code (in the web browser!!) and it wasn’t having a SAVE – I noted on the serial that it had crashed… but then if you look at the dates this is all very new.

Seriously this has to be worth a few minutes of your time – assuming the project continues and these niggles go away, you just don’t get a quicker, simpler and cheaper way to get a web page with buttons into an embedded device – even if just to do some simple stuff. This is now ENTIRELY down to how much effort the author puts into this.

Go take a look! These images should enlarge on click/touch. Well impressed IF development comes quickly enough….

Basic Interpreter for ESP8266   Graphics on the ESP8266


26 thoughts on “BASIC for ESP8266

  1. Can't access the URL through the work firewall so the site must be on some blacklists !

    Will have a look later this evening.

    (I'd run a full virus scan just in case !)

      1. Hi Erik - thanks for that clear explanation - I'm sure others will find that useful. I'd kind of figured that consts would stay in Flash but I'd never really thought it out as you have - because if you put arrays in flash - 8 bit - and don't access them correctly they WILL keel over and hence have to be accessed 32 bits at a time on the boundary with a function.. so I can only assume that when the compiler stores a string - it actually deliberately stores it on the boundary... interesting. Again, thanks for that.

    1. Hi Bill (and all) I took a look at that - I think you're right - the site must've been down. Now, while the esp8266basic seemed to be free and REALLY easy to use - but too early, the ZBASIC seems to have been around for a while in other guises - but here's the catch - they want $200 for it by the look of it - and testing the IDE I could not for the life of me figure out how to actually get it to compile and send off to the chip - the compile menu item wasn't greyed out - but when I added garbage to a test program - nothing happened. There are so many good free tools out there I think they might have a little trouble with this one. I'll not try again unless someone tells me I have this all wrong. But thanks for bringing it here - better to be aware than not.

    1. I hope so but sadly that is often the way of non-commercial (and even some commercial) projects - if the person pushing loses interest..... I think this could be a nice little number for quick, simple jobs... if I hear more I'll be sure to put it in here.

  2. I can assure you that the project is alive and well.

    Continuing to bug fix and add commands. New features and commands are starting to slow right now as I was picking off low hanging fruit first and the things I am working will take a bit longer to figure out and code.

    1. Oh excellent, well do let us know in here how it is coming along, I think you'll have some interested takers. If you want to add a link by all means do so, I'm looking forward to writing about this as the project develops.

      1. I have been doing a whole lot of work here lately and there are lots of new features.
        ESP8266 basic can now do more general web server stuff and now support uploading html, images and javascrip that can used in the pages the basic produces.

        Lots of stability improvements and more. Might be a good time to take another look at it.

        1. Hi there

          Some feedback for you and thanks for visiting to let us know you've been working on this.

          I went over to your site - and got quite excited about the new features - clearly something I had to try out.

          So my first issue was the intructions - there were pictures of ESP-01 and indications that the minimum size you could use was 512k. But then - there's this Arduino for programming and I was thinking.. "what has an Arduino got to do with this". At this point I think a beginner would have been put off - a picture of an Arduino connected to a board - but how does that work?

          I figured it was out of date info and grabbed the loader. No mention of whether it was for PC or MAC... but again I made the assumption of a PC. I downloaded and ran it. Windows 10's immediate reaction - I'm not running this. I happen to know that you can just ignore that - many might not.

          I THEN discovered that the 512K option is no longer available. I hunted out an ESP-12. To many beginners (we are talking BASIC here) this needs WAY more explanation. I set up the ESP-12 for programming and off it went to program the chip. I did not see any indication that it was programming other than the flashing lights on my FTDI (would people know to use an FTDI?)

          I rebooted the chip and... nothing but garbage. I tried changing from my normal 115k baud rate to 9600 and... sure enough - BASIC - YES! But where is it explained that you should use 9600 baud to start off?

          Then it went downhill. I realised it did not have my access point and having done this before went off on my phone to set ESP as the service - and off to - and sure enough - it wanted me to put my access point details in. I did and I got them WRONG. I started again and corrected the incorrect password I'd initially entered.

          Simple Basic Interperter For ESP8266...

          Connected to wififorus
          IP address :

          (note- "Interpeter" should be "Interpreter"). I'm thinking this might have been a memory test but why stop at 30606?? - and stop it did. I could get no further. Nothing on a web browser - nothing on serial, just dead.

          The original access point was still there but would not respond, serial would not respond... nothing.

          I started again - loading up the program - I noted that Windows popped up a message - with a yellow exclamation - but a whole load of full stops instead of a message... meant nothing.

          The ESP meanwhile was happily connecting to my WIFI access point - reloading the program had not cleared anything - and I was still no further forward....

          But with the serial display stuck at a count of 30606 and not taking any key input, I then realised I could access the unit via a browser - so this much was working.

          At this point the ESP PC program would not close - I had to use task manager to close it.

          With the web browser working, I went to edit and typed "print 'hello" - and saved - and ran - and... nothing. I THEN realised as I just happened to have kept the serial link open - that it was indeed working.

          I wrote this response - and in the meantime - the BROWSER now said "hello" - why did that take so long and what to do next?

          I went back to edit - and my one line program had disappeared.

          I typed "print 'hello again'" - saved that (it did not ask me for a file name) and ran - again on the serial I could see "hello again" - but nothing on the browser. Again I came here to update my response and shortly thereafter - "Hello again" appeared in the browser. I've no idea why it took several seconds to appear.

          Again back to edit - again no sign of my program.

          At this point I gave up to complete this reply. Clearly something happening here, obviously working - but not enough information. Several seconds later. my latest one line program ran again in the browser.

          I hope this feedback is useful... I await further development - this was not at all intuitive to me.


          1. More feedback. At this point I decided to have a further play with the browser (Chrome latest on Windows 10). I went to SETTINGS - it took at least 20 seconds for that to come up. I went to file manager... no sign of my one-liner there.

            I went to edit - and there was an empty box next to "open" - I pressed open - nothing seemed to happen - no dialog - but then about 20 seconds later my original program appeared - and this was called "default" - I modified it and saved it. A Windows box popped up to say "Saved" but then wanted to give me the option to stop further dialogs coming up - I'm sure that's not right. I closed that window.

            I pressed run... nothing... The SERIAL was now showing the results of my program and then.. after around 20 seconds - it appeared in the web browser. WHAT is all that about? Surely one or the other? At this point the browser input box is showing "" - I guess you have to know to get rid of the "Input?" to get back to the editor. Again, pressing "open" with nothing in the BASIC "open" dialog box eventually produced my one liner - but not for at least 20 seconds. I'd dread to think how long a complex program would take?

            Am I missing something here?

          2. The reason the program takes o long to execute is because it did not contain an end or wait statement.

            The basic interpreter reads each line of the program from flash memory and is hard coded for 254 lines of code at the moment. I opted for the easier option of storing each line as a separate file. This is probably the cause of your slowness.

            The below program will be almost instant when run.
            print "Hello world"

            Another simple program that will run quickly is the common on/off program.
            See below.

            button "On" [turnon]
            button "Off" [turnoff]

            'this will turn the device on pin 2 off
            wprint " ON"
            po 2 1

            'this will turn the device on pin 2 off
            wprint " Off"
            po 2 0

  3. Mniscool, Pete, great to hear more will be forthcoming on this.

    All I want/need is simple 1 or 2 digital on/off input status reporting to my cell phone/laptop and maybe for other devices to control 1 or 2 outputs.

    With such minimal requirements, I see no reason to give myself a brain aneurysm at my advanced age to use any flavor of "C". Even assembly is much easier for me to understand. My problem and my problem alone.

  4. There has been a lot of stability and bug fixes lately.

    Still working on i2c but as people write code and discover bugs it keeps getting better.

    1. Did you document which I2c OLED units....? That could be useful. I look forward to the day there is an MQTT library built into this so I can use it for one-off projects - I communicate with all of my boards by MQTT.

  5. OK, I've been playing with this BASIC for a while - I am using the "legacy" version 2 since the "alpha" version 3 scared me off. It seems pretty quirky at the moment. I'd like to see errors in my code pointed out, and a list of error in the Language Reference. It seems that labels are case sensitive, and when referenced in a go to statement, they must have square brackets around them. And I MUST hit the Save button before attempting to run the program, or any changes are ignored. When I put a name in the text box to save, and then hit the Save button, a message box comes up that says, " Saved" instead of referencing my filename. And when I go to the File Manager, I don't see my file saved there. Lots of little things... this looks like its going to take a lot of hard work to clean up. I really hope that work gets done! Its a great idea.

    1. It was "quirky" when I looked at it - but I thought I'd better write about it as there is potential there for people who're not so keen on C etc. not sure why labels should be case-sensitive - one of things I hate most about other languages... You should send a copy of this to the designer. Feedback helps to improve.

    2. All of these problems have been addressed in the version 3 branch (except saving before running).

      I suggest that you give it a try. I just put out a new build tonight that has an interactive debugger. It animates the code as it runs and lets you see all of your variables. There were also a hudge number of bugs that have been resolved. Version 2 still works but I think it will be going away here soon.

  6. So esp8266 Basic has come along way in the past year.

    You might want to take it for a spin again here at some point.

    It has an interactive browser based debugger and support for simple mqtt. There are more gui widgets and things are much more stable. Give it a shot if get a moment.

Comments are closed.