ESP8266 BASIC

Electronics Learner 123

Well-known member
Hi Guys,

How would I go about using picaxe 14m2 to control relays over Wi-Fi,
I would like to have 3 relays around the house, how would I do this?

I would like the website to be controllable by both phone an website, however I would like a solution that teaches me how I would implement this in a HTML website stored in a free space (like GitHub).

Thanks in advance
Electronics Learner 123
 
Last edited:

westaust55

Moderator
The devices you reference are BASiC language programmable Mirco’s that nominally are in competition with the PICAXE chips this forum supports.
I think you need to quickly explain where the PICAXE is used in relation to you question.
Otherwise this thread may be removed as being advertising for a PICAXE competitor.

please read this (Readme First) post:
 

Buzby

Senior Member
This is a PICAXE forum, you won't get ESP answers here. ( That's like asking a plumber 'how do you knit a Fairisle jumper ?'. )

However, some forum members have used PICAXE to control stuff via a web interface, and I'm sure you don't need 5 chips to drive 5 relays !.

If you are determined to go down the ESP route then you would be best asking your questions on their forum.

But if you want a PICAXE solution, stay here !
 

Electronics Learner 123

Well-known member
This is a PICAXE forum, you won't get ESP answers here. ( That's like asking a plumber 'how do you knit a Fairisle jumper ?'. )

However, some forum members have used PICAXE to control stuff via a web interface, and I'm sure you don't need 5 chips to drive 5 relays !.

If you are determined to go down the ESP route then you would be best asking your questions on their forum.

But if you want a PICAXE solution, stay here !
Hi, could I have a picaxe solution- please see my updated question
 

Electronics Learner 123

Well-known member
The devices you reference are BASiC language programmable Mirco’s that nominally are in competition with the PICAXE chips this forum supports.
I think you need to quickly explain where the PICAXE is used in relation to you question.
Otherwise this thread may be removed as being advertising for a PICAXE competitor.

please read this (Readme First) post:
I apologise for any inconvenience that I may have caused, I have re worded the question and would be great (sorry for the typo here before) if you could still help, I didn’t intent to advertise another company 😅.
Kind Regards
Electronics Learner
123
 
Last edited:

inglewoodpete

Senior Member
I apologise for any inconvenience that I may have caused, I have re worded the question and would be great fuk if you could still help, I didn’t intent to advertise another company 😅.
Kind Regards
Electronics Learner
123
I personally don't have any experience with these wifi devices.

A colleague of mine has successfully interfaced one of the ESPxxxx modules to a PICAXE so that he can access some sensors and set outputs remotely. He used one of the less sophisticated wifi devices - he did mention that there were others available but he was familiar with PICAXE basic and wanted to use DS18B20s to read temperatures remotely.
 

Electronics Learner 123

Well-known member
I personally don't have any experience with these wifi devices.

A colleague of mine has successfully interfaced one of the ESPxxxx modules to a PICAXE so that he can access some sensors and set outputs remotely. He used one of the less sophisticated wifi devices - he did mention that there were others available but he was familiar with PICAXE basic and wanted to use DS18B20s to read temperatures remotely.
Do you think that you could ask him to write down the process that he went through and if he could paste some of the code so that I can understand how he did it?
Thanks in advance
 

Electronics Learner 123

Well-known member
If you just want to get things done, you wouldn't. You'd buy an ESP with enough pins to do the job on its own.
Hi kfil, for my assignment I have to use a Picaxe 14m2, so is there any other way to go about doing what I need?
I also need to use the Picaxe 14m2 to use to run part of the project and can't do the project without it, is there a way to use a dynamic variable e.g. if a url is pressed on a website it sends it to the Picaxe to change the colour of LEDs- for example
 

Hemi345

Senior Member
This article by Charles Hampton should get you started: https://www.allaboutcircuits.com/projects/build-a-picaxe-esp-01-wi-fi-communicator/

The "AT" command firmware is a PITA because versions vary slightly from module to module. If you go that route though, make sure you try communicating with the ESP8266 with a serial converter first so you know the command syntax and what it expects before trying to program the PICAXE to control it. If you know a little C, I'd encourage you to program the ESP using Arduino IDE as you can do all your setup to connect to the access point and such much simpler. The PICAXE code will be much, much smaller too. Charles also has articles on how to program the ESP w/ Arduino too.
 
Last edited:

lbenson

Senior Member
make sure you try communicating with the ESP8266 with a serial converter first so you know the command syntax and what it expects before trying to program the PICAXE to control it
E.g., from your PC using a usb/serial module.
 

Electronics Learner 123

Well-known member
Thanks guys for the response, I have read the boys from all about circuits, how would I go about reading data (receiving data) e.g on thingspeak I want there to be a way to turn an led on/ off, how would I do this? Which at commands will I need to use?
This article by Charles Hampton should get you started: https://www.allaboutcircuits.com/projects/build-a-picaxe-esp-01-wi-fi-communicator/

The "AT" command firmware is a PITA because versions vary slightly from module to module. If you go that route though, make sure you try communicating with the ESP8266 with a serial converter first so you know the command syntax and what it expects before trying to program the PICAXE to control it. If you know a little C, I'd encourage you to program the ESP using Arduino IDE as you can do all your setup to connect to the access point and such much simpler. The PICAXE code will be much, much smaller too. Charles also has articles on how to program the ESP w/ Arduino too.
 

inglewoodpete

Senior Member
This article by Charles Hampton should get you started: https://www.allaboutcircuits.com/projects/build-a-picaxe-esp-01-wi-fi-communicator/

The "AT" command firmware is a PITA because versions vary slightly from module to module. If you go that route though, make sure you try communicating with the ESP8266 with a serial converter first so you know the command syntax and what it expects before trying to program the PICAXE to control it. If you know a little C, I'd encourage you to program the ESP using Arduino IDE as you can do all your setup to connect to the access point and such much simpler. The PICAXE code will be much, much smaller too. Charles also has articles on how to program the ESP w/ Arduino too.
I spoke to my work colleague Phil today and he advised much the same: follow the Charles Hampton project description on All About Circuits. Phil reflashed his ESP8266 as described in the article (or subarticle) to interface more directly with the PICAXE.
 

lbenson

Senior Member
If you get to the point where using your phone, your pc with a usb/serial module and software like puTTY, and an ESP01 to receive communications from your phone, we can help with the picaxe part. But it's a steep hill to climb to get to that point.
 

Electronics Learner 123

Well-known member
If you get to the point where using your phone, your pc with a usb/serial module and software like puTTY, and an ESP01 to receive communications from your phone, we can help with the picaxe part. But it's a steep hill to climb to get to that point.
Hi thanks for the assurance, how would I go about receiving signals from my phone, let’s start basic e.g turning an led on/off.
 

lbenson

Senior Member
Can you design a browser page which would look like what you want?

This w3schools page illustrates the most basic stuff for a pushbutton which can toggle something (but you'd need to modify the "onclick" option).


If you copy that source onto you pc, and then navigate to it in your browser (e.g., c:\downloads\testbutton.html, if that's where you put it and how you name it), you will see the page and can click the button (as you can directly on the w3 site).

Then the trick is getting the picaxe to serve that page, and respond to what happens with your modified "onclick".

But before that, if you have an ESP-01, Nodemcu, or ESP8266 D1 Mini with the AT command firmware, and a usb/serial module, then you can do some testing from your PC before you introduce the picaxe.
 

Electronics Learner 123

Well-known member
Hi, I have created this button here: https://codepen.io/aiyush-g/pen/YzXQENJ

I have looked at lots and lots of tutorials on how to connect esp to internet however all of these tuts use Arduino etc...

Unfortunately I haven't purchased the parts listed above yet so cannot test, can you still talk me through the process and the code etc.?

Thanks in advance, I really appreciate the help
Electronics Learner 123

Ps. The button was inspired from here: https://codepen.io/kathykato/pen/gOOjgmP
 
Last edited:

lbenson

Senior Member
Good start. I would try to make your button "latching" (depressed, not depressed) so you have some indication as to whether the led is on or off. And I don't see that your html code does anything to return a value.

If you are in the U.S., you can order 2 of the D1 Minis (my preferred ESP8266) from Amazon for $10.99 with delivery Tuesday:

It might be better to wait until you have those to proceed further into specific code. Have you looked at the AllAboutCircuits project?
 

Electronics Learner 123

Well-known member
Hi Ibenson,

Thanks for your help, I will update the button tomorrow, unfortunately I am not based in the us, however, would this board be okay: https://www.ebay.co.uk/itm/NodeMcu-V3-ESP8266-12E-Development-Board-WIFI-USB-ESP12-ESP-12-Node-Mcu/153600882272?_trkparms=ispr=1&hash=item23c3537660:g:tMsAAOSwg9hdUWE9 . If the wemos will work better I will go for that, I can’t seem to find two that will ship ‘fast and free’ to the UK. I have read the all about circuits blog. Since I probably won’t receive the boards until the end of this week (I haven’t ordered them yet I want to check that they are the right ones with you first) is there any further reading that you recommend or could you describe how the code would work and what other electronics would be necessary e.g what PICAXE board etc...
 

Electronics Learner 123

Well-known member
Hi Ibenson,

I do have a breadboard and the wires, I don’t have a usb aerial connector (is this for the picaxe or the NodeMCU) and which picaxe do you recommend- I have a 14 but was thinking about upgrading to 18M2 for this project.
 

lbenson

Senior Member
The usb/serial modules are all-around useful. I have dozens of them. You can use them connected to your PC to work out protocols and interactions with the NodeMCU and then with the PICAXE before you try to put the two together with a serial connection. I think you would have a very hard time debugging if you went straight to PICAXE<-->NodeMCU.

I have never used the 18M2 for any project. Because of the alignment of pins with the 08M2 and 14M2, I would recommend the 20M2 instead--then if need be you can use an 08M2 programmer to program the 20M2 simply by plugging the 20-pin chip into the 8-pin socket. But the 14M2 is quite powerful in itself if it has as many pins as you need.

You may find that a 20X2 would work best, because of the background serial receive into the scratchpad memory of large strings of data from the NodeMCU. For the M2s, I need to really examine AllyCat's and Hippy's HERSIN-with-POKESFR code in this thread: https://picaxeforum.co.uk/threads/is-hserin-really-this-slow.31549/#post-327171
 

Electronics Learner 123

Well-known member
Good start. I would try to make your button "latching" (depressed, not depressed) so you have some indication as to whether the led is on or off. And I don't see that your html code does anything to return a value.

If you are in the U.S., you can order 2 of the D1 Minis (my preferred ESP8266) from Amazon for $10.99 with delivery Tuesday:

It might be better to wait until you have those to proceed further into specific code. Have you looked at the AllAboutCircuits project?
Hi, I am currently looking at what I am going to order, do we need 1 wifi module or 2?
Just to give some extra background information to my project: I am planning to create a 7 segment display clock using led strips, I will use either and rtc module or use the WiFi module to set the time. The WiFi module will be used to change the colour of the lights or change the mode of the clock.
Thanks for the information on the microcontroller, will you still be able to help if I use the 20m2?
 
Last edited:

Hemi345

Senior Member
You only need one for each PICAXE, but I usually order an extra so if one is DOA or you have a mishap, you'll have a spare and won't have to wait for another to ship.
 

kfjl

Member
The 20X2 is more powerful and easier to use out-of-the-box with the long text strings which you would get from the wifi unit. The 20M2 or 14M2 make for an interesting challenge.
An ESP only sends long text strings if you tell it to.
 

lbenson

Senior Member
An ESP only sends long text strings if you tell it to.
In AT command mode, if you ask for a response to a web page button push, you will get a long text string so far as I know.

Without use of something like AllyCat/hippy's PEEKSFR tricks with the HSERIN pin, the M2s only have a 2-character HSERIN buffer, even though the 14M2 and 20M2 have 512-28 bytes of ram which could be used for storage of long strings.
 

lbenson

Senior Member
What would it need to return, a variable?
You'll have to search. It's well outside the PICAXE realm. I assume the AllAboutCircuits code would give some clues, but I've been unable to download it--it keeps asking me to sign in, even though I already have.

The DS3231 is a good, accurate RTC module.
 

lbenson

Senior Member
What I'm working on also includes one of these 20x4 I2C LCDs, so you might want to get one--currently working with code provided by hippy.

 

Electronics Learner 123

Well-known member
Hi Ibenson,
Thanks for the recommendation, however, I don't think that I will get one at the moment, as I can still view the serial on the computer? I have written a new set of code for the button:

HTML:
<!DOCTYPE html>
<html>
<head>
    <title Submit Button Test</title>
</head>
<style>
input[type=submit] {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 16px 32px;
  text-decoration: none;
  margin: 4px 2px;
  cursor: pointer;
}
</style>
<body>

<form name = "input" method = "get">
    <input name="Off" type="submit"value="Light Off">
    <input name="On" type="submit"value="Light On">
</form>

</body>
</html>
I couldn't attach it as a code pen because the get request doesn't work, but if you run this on your computer browser you will notice that the click of each button changes the URL, do you think that we could work with this?

Kind Regards
Electronics Learner 123
 

lbenson

Senior Member
Didn't work for me because no ">" after "<title". Shows up now. I'd recommend changing the values to single characters: "0", "1"; "-","+", "a","b" or such since that would work better for PICAXE byte-at-a-time processing. For that matter, I also keep the input names to a single character (e.g. A-Z) because that makes it easier for the picaxe. That constraint doesn't apply to other processors which are better at handling text strings.

That way you get a response after the "?" of something like "A=1" (for on) or "A=0" (for off).
 

lbenson

Senior Member
I misspoke about renaming the values--that changes what is displayed within the button. I'm used to using radio buttons which I can label and not pushbuttons.

But if you rename the names, you get a response like "file:///C:/dl/picaxe/buttontest2.html?B=LED+On". Once that gets back to the picaxe, all you have to do is find the character following the "?". If it's an "A", you turn the LED off; if it's a "B", you turn it on. But getting to that point is not trivial.
 
Top