If you’ve been following my articles on the new ESP8266 board (https://scargill.wordpress.com/2014/10/05/esp8266-working/ for example) you’ll know that you probably need to FLASH the board to the latest version (0018000922 at the time of writing though it reports 08000902 it has the new baud rate control and defaults to 9600 baud initially) and you’ll know there are a few sites – one to help you flash the ESP8266 and another with a fairly up to date instruction set.
And that’s fine – but today someone was showing me their new all-singing electric car which is controllable by phone – and it has it’s own access point – and I thought – I WANT ONE – which reminded me – how on EARTH do you make an access point from the ESP8266? Well, that’s not obvious – a quick look at instructions show that it CAN be an access point and there is a vague reference to this..
The imagery above comes from NURDSPACE – it’s fairly obvious how to join a network but if you want the ESP8266 to BE the network – what’s that vague reference in CWSAP? What’s an ECN for example – is THIS the command to set up your own Access point – doesn’t look like it as it says “connect to your router”?
BINGO – so actually this is to make your OWN access point with a choice of channel and encryption method. It returns OK incidentally, usually within a second. You need to set CWMODE=3 – and that information survives a power cut – so you only need set it once. And here’s the thing – the CWSAP ALSO survives power cycling – so just as you need only connect to an access point once – and on power up it reconnects – you only need to set the board up as it’s own access point once and it keeps that through power down (though in both cases I’d be checking on power up that it’s still working).
So after username and pass you wish to use to protect the unit, pick a channel (your mobile might have an app to tell you which channels are clear where you are) and a mode 0=no encryption – i.e. open – 1=WEP, 3=WPA_PSK, 3=WPA2_PSK and 4=WPA_WPA2_PSK.
And so where are we now – web server, web client, socket listener, access point. This just keeps getting better and better. Everything is there – provided you don’t mind setting this all up with a serial connection. What would be nice would be for the unit to default to it’s own access point – complete with setup screens just like a simple router – for example the access point seems to have a fixed IP range.. I can’t up to now see how to adjust that. Not sure if I’d want to but there’s always a chance it might conflict with your own setting. When I hooked my phone into it the phone ended up as 192.168.4.100…
So how does that work? Well, the unit IS running DHCP as I disconnected once and reconnected and was told (using the Android tool IPCONFIG) that I was 192.168.1.101 – the constant is the address of the Access point itself which is 192.168.4.1 – it also has an address built in for a DNS server and I have NO idea where that comes from – maybe a hangover from previous connections.
Of course in this mode your phone or whatever device can’t do anything with the REST of the world – it can only talk to the ESP8266 – but that’s the point – you can then control something.
I turned the unit off – hooked it up to my Arduino toy that turns a light on and off – after changing the access point to 192.168.4.1 – and LO AND BEHOLD without using external WIFI I can turn the light on and off – and if I can do THAT – I can control ANYTHING – next stop – WIFI house controller.
This is of course as far as many tutorials would take you – leaving you then to find the problems yourself. it occasionally locks up occasionally and I have no satisfactory solution. You can try as I have, controlling the physical reset line when you see “busy”… I reset for a second and re-issue the main mode command… and that’s fine BUT of course your phone by then has disconnected from you and reconnected to your normal router – so that REALLY isn’t a solution. I found a customised ROM with a new instruction to reset in software – but I don’t yet know which ROM it is BASED on – when I find that out I’ll report back as that’s a definite reason to update the firmware. I have left this on overnight and it’s been absolutely fine – but if you send commands way too quickly it might just lock up. I’m currently requesting the status of my LED every 200ms – so I can see the status of it on the phone – and I have 2 buttons one for off and one for on. By and large it is fine – but there ARE times when it locks up and the reset is the only answer for now.
So – there we are… this incredibly cheap unit looks like it just MIGHT be useful – not sure about that internal aerial though – I was going to order one of the ones with a socket to put a decent whip on it – but they only have 4 pins (ie power, ground, in, out) which means no firmware upgrades from a file – pretty useless then given the current variations of firmware. I hope this is helpful – if you find better sources- please be sure to return the favour. I’m email@example.com and you’ll find my home control stuff at www.scargill.net