Introduction: World Wide Web Control for Under $30.00

Applications for this project include:

Controlling items and getting information using any browser on any device (tablet/PC/phone) and also using low power mode to send back information from a remote locations for example monitoring water levels, wildlife etc.

To demonstrate what can be done the project has a temperature and humidity sensor that can be read and an LED that can be controlled. It is not intended to be an end product but more of an illustration of what can be achieved. It is hoped that the reader is inspired to create their own project for something more specific.

Parts list

BV502 Mini-Max Microcontroller Aprox. £7.00 (ByVac)
ESP8266 Wi-Fi Controller Aprox £4.00
USB to Serial device Aprox £4.00 (ByVac)
Power supply (ByVac)
DST11 Temp + Humidity control Aprox £0.90
LED, 1000uF, 4k7 resistor
Breadboard and hook up wire

Complete kit of parts with software pre-loaded (ByVac) About £18.00

Step 1: Circuit Diagram & Building

The circuit is built on a solderless breadboard with the USB to serial supplying power for all of the circuit. The separate power supply which MUST be set to 3.3V, takes its input from the +V pin of the BV502 as this is the input from the USB. This separate supply powers the ESP8266.

Although the Mini-Max (BV502) has a built in 3.3V regulator it cannot supply enough power for the ESP8266 as well (it can but only just). There MUST be a large capacitor (about 1000uF) across the supply to the ESP8266 as it has been found by experimentation that unreliable results are obtained without it.

The Mini-Max circuit board has the port and pin named marked on it so C0 for example is port C pin 0. It is possible to build the circuit without a breadboard if the pins on the Mini_Max are soldered facing upwards. The kit

There are three switches shown, these are not actual switches but just wire jumpers on the breadboard. The firmware is written to read these switches to control the flow of the program. The program can also be controlled by the serial interface using the free IDE. For this project there is NO NEED to connect any of the switches, for now leave lines C7 to C9 unconnected.

If you are new to ByPic then it is best to simply connect up the BV502 and USB to serial first, then get the IDE going to give a feel for how the system works. This is fully explained here. ByPic is an interactive Rapid Application Development system which is an ideal partner for the ESP8266 Wi-Fi controller.

The next step is a quick introduction to ByPic

Step 2: Introduction to ByPic

ByPic is an interactive language that has been optimized for speed and for a simple for next loop can run at 1,250,000 lines per second, this compares with other interactive languages that can only manage about 25,000 lines per second for the same speed processor.

It is a cross between C and BASIC so should not be that difficult to learn. The reason for the speed optimization is so that it can be 'purposed' for a particular application. What does this mean? Well in a standard language you have many functions that perform particular jobs, In ByPic you write those functions yourself - or in the case of this project the functions have been written for you.

Using the example for this project we have a function called join() that will connect the ESP8266 to an existing Wi-Fi. It can be used interactivity as follows:

join("mySSID",myPassword")

and will return success or fail. Using the function interactively mains that you can have instant feedback without the bother of compiling and downloading as you would need to do with say the Arduino.

In practice the functions can be built into modules or files, so for example the join() function is part of the ESP8266 file, there is another file which is added later called http_server.bas which uses some of the functions in the ESP file. This modular approach makes it easy to reuse code and modify the device for a particular application.

The language uses functions as the building block, so a typical function would be as in the picture, it always starts with the function keyword and ends with endf. A function is called simply by typing its name, functions can of course call other functions.

When a function is written (the free IDE can be used instead of the terminal screen) it goes to the RAM. If this function will be needed again at reset then it can be saved to Flash using the keyword flsave(""). In this way (or using the IDE) functions can be gradually built up until a complete system is achieved.

A special function called main() can be created that when saved to flash will automatically be run at start up, thus a turnkey system can be built.

Step 3: Wi-Fi Firmware

When the circuit has been built and ByPic is up and running (it will be up and running as soon as the serial is connected) it is time to download the firmware.

The firmware is currently available for ByPic version 2.30+ and the MX170 (newer Mini-Max BV502) and can be downloaded from here. The IDE must also be working to accept this script file. When the loading has completed (about 1 and 1/2 minutes) type .r (dot r) a couple of times to reset the processor, the kit comes with this software pre-loaded.

Without any of the 'switches' connected (C7 to C9 left disconnected) the Mini_Max will say wait... for a few seconds and then come up with the menu as shown in the picture.

You can play around with the commands, for example:

menu 5 to set the ESP8266 as a station

menu 6 - enter the SSID and password for your network

You should now be able to get the date and time from google (menu 11)

There is more on the use of the menu in the next section.

Step 4: Setting Up a Server (1)

A server is used in this context to provide a web page for a browser, so the setup will effectively be a HTTP server providing (all be it one) a web page to any browser that is connected. A server is useful for controlling things such as lights and heating as it can be contacted by any browser (potentially anywhere) and will respond straight away.

Select 3 to run info:

The important bits have been highlighted in white. This tells us that the current mode of operation is as an access point and if we were to scan on another device (laptop, phone etc.) we would see 'LINK3' as an open (the last 0) access point that we could connect to. We can communicate with it via the IP address as shown. This is 192.168.4.1 and cannot currently be changed. If Wi_Fi mode is not 2 then press 4 as we need the module to be an Access Point (AP)

Now press 9 to run the HTTP server. Go to the laptop or other device and connect to the SSID as shown in info, in this case LINK3. Because of the way the firmware is set up you will also need to place a shorting link between C9 on the Mini-Max and ground. Removing the link enables you to get out of the continuous server loop.

With the server up and running we will be able to see the SSID of the access point on another device, this depends whart device it is for example the picture shows a typical dongle Wi-Fi device connected to a PC, most laptops have built in Wi-Fi and for an Android device use the settings. Set the Wi-Fi link in the remote device PC/Laptop/Phone etc. to the SSID of the ESP8266 (LINK3 in the example but not on yours).

The remote device must obtain an IP address form the ESP8266 before communication can begin, this may take a few seconds or a few minutes. When an IP address has been obtained (an Android device will tell you) then in the address bar of the browser browse to 192.168.4.1.

You should see the yellow web page as in the picture, if you also have the USB to serial connected to the Mini-Max you will also see activity there.

You will see that from here you can control the LED and get results from the sensor. To stop the server running remove the link at C9.

Step 5: Setting Up a Server (2)

In part 1 of setting up a server, the ESP8266 was used as an access point. This was convenient because it meant that ANY device could link with it and control it even though they were not part of any network. However it is more likely or convenient that the ESP8266 is connected to an existing network, yet can still be a server.

Select option 5 to make the ESP8266 a station

Select option 6 (if not already done so) and put in your own home SSDI and password

Select option 3 and make a note of the IP address, also make sure that it is in mode 1 (station)

Select option 9 but this time brows to the IP address given in info, in the case of above this will be 192.168.11.54

You should be able to now connect without reconnecting to another access point. This is the most useful application for controlling a home network. For example powering up/down computer equipment, turning lights on and off. Even though it needs to be powered all of the time the power is very small about 1/3 Watt on average which is probably much less then most equipment on standby.

Comments

author
allecsx (author)2014-10-30

Hello good sir,

I was wondering if, with some modifications, could make a soil moisture sensor that I could monitor over the internet, just like in your example above. Also, I was wondering if it really is possible to access the device from almost anywhere without a hosting server up and running. I am kinda newbie at this, so i'm sorry if this question sounds stupid.

Thank you in advance

author
jimeer01 (author)allecsx2014-10-30

A soil monitor is an ideal application. But it lets assume it needs to be battery operated so it would be done with a client not a server, this is the ways you could do it:

1) You would need a friendly Access point, by friendly I mean one that you knew the SSID and password to (i.e. your own)

2) For battery operation the idea is to only use power for short bursts of time, possibly every hour - or even every day for soil moisture? The ByPic can go to sleep for a user settable amount of time and in this state only consumes uA. The ESP8266 has a low power state but in that state it still consumes about 1mA. This can be reduced to nothing by introducing an electronic switch.

So we have a device that will wake up, measure the moisture content (easily done) and activate the ESP8266. The ESP8266 will then connect to the friendly access point and then it will have access to the friendly network and WWW.

3) Now you have choices:
a) set up a HTTP server on your PC (see aprelium) and communicate using HTTP
b) set up a socket on your PC and communicate directly (see Python)
c) use a public server, you may have got some free space when you signed up with an IPS
d) using the friendly network and the WWW, let it send you an email via SMTP

* I realise that the above could possibly mean nothing but those are the choices. I think the email solution is the easiest where you could set trigger points for email alerts. In fact I am not finished with this module yet so a plant monitor may be just the example to do.

If you were to still use a server instead of a client then it would be easier to access but it would require a constant power source as it would need to listen all of the time.

In this instance you would still set the ByPic and ESP8266 device connected to a friendly Access Point (AP) but you would need to configure the AP to forward a port when contacted from the outside. An IP address would also be needed for your access point. So if your access point IP address is say 84.125.66.44 and you set the server to say port 9000 then putting http://84.125.66.44:9000 in any browser anywhere would contact the ESP8266 and thus get information from the ByPic device. This assumes that the ByPic has been set up for HTTP communication.

This is obviously the most interesting way to measure the soil moisture content (and other things) and it would not only need to be one way, you could say turn on irrigation via the browser. It does present some problems though:

a) Port forwarding is a security risk, all be it very minor as it can only contact a microcontroller.

b) You need to know the IP address of the AP in order to contact it, most ISP will give you a dynamic (changing) IP address so you will need to make arrangements for this (see noip)

Thank you for the interesting question

author
SaptarshiG (author)2015-02-23

Awesome tutorial,absolutely loved it.

But I was wondering if it is somehow possible for a user to change the password on the fly i.e. without having to program it.

author
jimeer01 (author)SaptarshiG2015-02-24

Not really but it is 'user programmable'. There has been quite a few updates since this was written, the latest is here: http://www.bypic.co.uk/index.php/IoT_Wi-Fi_Kit

author
SaptarshiG (author)jimeer012015-02-24

Thanks so much. :)

author
rlarios (author)2014-11-23

Hi there jimeer01,

Your article and product look interesting. I have my wifi network setup in such a way that I need to enter the MAC address of the device to be connected to the network before it can have any access to it. Does your controller work this way?

Thanks and keep up the good work!

author
jimeer01 (author)rlarios2014-11-24

The ESP8266 does have a MAC address so the answer is probably yes. Having said that it is not an 'out of the box' device and so does require some experimentation.

author
seamster (author)2014-10-23

Nice.

About This Instructable

14,341views

39favorites

License:

Bio: I own and run a small electronics business that specialises in products for making complex things a bit easier.
More by jimeer01:You Have Mail! Gets the Latest email and displays to an LCDWorld Wide Web Control for under $30.00Colour Addressable LED Dsiplay
Add instructable to: