ESP8266 WiFi serial module

julianE

Senior Member
So as not to waste time while watching television I have run an 8266 module on a single 500mA LiPo cell regulated by a low drop out 3.3 volt regulator. That way I can program and watch tv and be portable, just a laptop and 8266 module. The modules do draw some current and it's not worth risking my laptop USB port, tho, most are current limited so it's probably possible to power it of the laptop USB, i'm just risk averse.
 

srnet

Senior Member
I would like to ask the forum whether the 8266 is at all suitable for standalone battery (3AA batteries) powered applications, in view of its high power consumption.I can see a one way communication, say, every few hours, where the unit is powered, data sent, and then shutdown again. However it wouldn't be possible to have the 8266 on standby to receive signals.
Is this right or am I missing a trick?
Nope, you have that right.

Unless you implement power mangement as you suggest, and have the 8266 powered down most of the time, battery operation is not really feasible, unless you have very large batteries.
 

rmeldo

Senior Member
Last edited:

srnet

Senior Member
I found this resource (great website)

http://www.esp8266.com/wiki/doku.php?id=esp8266_power_usage

It talks about a standby mode. I wonder whether that could be a "listening for questions" mode. Some reading to do tonight...

Also one of this could be an option for high capacity rechargeable battery.

Riccardo
Well yes, but 'receive' mode is still 60ma, whch would flatten some AAs in a day or so.

Otherwise you have to shut it down, wake it up, and log it back in. So in effect you cant have it constantly on listening in power save mode.
 

julianE

Senior Member
The ESP8266 modules are a disaster, I can't believe I'm the only one having issues with them. I spent 2 hours messing with the modules.
About a week ago I had everything working just right using the AT command set issued by an 08M2. I'm doing another project that I want to incorporate 8266 into and all of a sudden it's super flakey using Firmware 0.9.5.0 AT (which was very good in the past), so I flash it with a bit newer Firmware 0.9.5.2 AT, still bad, I went back to 0.9.2.2 and voila, it works. To increase my frustration another module just blinks the blue light and keeps sending gibberish, i try to reflash but it looks like it's a goner. I gave Lua a try and it has it's own set of issues. I will try the Lua again but not as a standalone instead as a helper to picaxe. It might be that I am just spoiled by the rock solid Picaxe.
Does anyone have a recommended firmware for the 8266 and a download location, the modules are very intriguing and I had one sending data to Thingspeak for 24 hours with near perfection and today it's nothing but woes.
 

srnet

Senior Member
i would expect that the different firmwares have slightly different setups and timing, so your program may need adapting to cope with changes. It would seem unlikley that someone would publish firmware that just does not work.

I would go back to the same hardware (and firmware) you had working a week ago and go forward from there ..............
 

srnet

Senior Member
I can't believe you just said that !.
I will repeat it then, I think it unlikely that someone would publish firmware that just does not work.

The firmware may well need some particular hardware version, or baud rate, or particular configurrqation or setup to work, but its a reasonable assumption that the person publishing it had it working on thier own setup.
 

julianE

Senior Member
Thanks for the replies. After posting on the forum I continued working on the three 8266 modules I have. The one I thought was bricked is working now so I am happy with that, not really sure what was hanging it up, maybe it just had to dump a buffer because it was spewing gibberish for a long while. I'm not sure how to make sense of differences between modules, hard to believe that they are changing hardware, perhaps the bootloader is different between factory runs. Just to add a little from the last outing with the modules,
here are the 3 crucial lines of code the picaxe sends out, I have an FTDI chip on the receive line of the 8266 so I see the exact data picaxe is sending and it's always correct,

AT+CIPSTART="TCP","api.thingspeak.com", 80
AT+CIPSEND=70

GET https://api.thingspeak.com/update?key=thinspeakAPIkey&field1=55

I tried this on different firmware on the same module, the first two lines work it's when the GET statement is executed that it fails on firmware 0.9.5.0 AT, the same code on the same module runs perfect on firmware 0.9.2.2.

On a different module, same type but probably different time of manufacture 0.9.5.0 AT firmware works on all 3 lines.

My plan going forward is to have a collection of firmware and a test program and just test the modules and see what firmware works on it.

I have one module that I never flashed firmware on, it's as it came from the factory. I'm far from bored and would not bother changing firmware but the modules are significantly different in their responses to the AT commands, so if you have a program waiting for a particular response from the module, the response may change from module to module, sometimes it's just "OK" other times it's more verbose.
 

Buzby

Senior Member
I know nothing about these modules, or the format of the commands, so I may be wrong here.

The GET command, after the key, has 'thinspeak' in it.

Should it be 'thingspeak' ?
 

julianE

Senior Member
I know nothing about these modules, or the format of the commands, so I may be wrong here.

The GET command, after the key, has 'thinspeak' in it.

Should it be 'thingspeak' ?
That section is where the private thingspeak API key goes, I did not want to publish it so I just put anything as a place holder. I saw the misspell as I was pressing the Post key :)
 

steliosm

Senior Member
I have come to realise after a bit of experimentation that those modules are very picky in the way you send them the CR,LF string. I have found that you have a consistent proper behaviour if you send along the characters 13,10 after your AT command and not the other way around (10, 13). As far as it goes for the firmware stability, I have tried several versions of AT firmwares and Lua firmwares. I stick with the AT ones. Since I work with ESP-01 versions, I have limited flash available (512Kb) and I have found that the Ai-Thinker 0.9.5.2 seems to be stable enough and also supports the smart-link WiFi configuration options, which is cool if you're building a project with a friend and will have to work on his WiFi network.
 

julianE

Senior Member
I have found that you have a consistent proper behaviour if you send along the characters 13,10 after your AT command and not the other way around (10, 13). As far as it goes for the firmware stability, I have tried several versions of AT firmwares and Lua firmwares. I stick with the AT ones. Since I work with ESP-01 versions, I have limited flash available (512Kb) and I have found that the Ai-Thinker 0.9.5.2 seems to be stable enough and also supports the smart-link WiFi configuration options, which is cool if you're building a project with a friend and will have to work on his WiFi network.
I just checked my program and I have been sending 13, 10 all along, I use CR LF which is same as 13,10.
 
Last edited:

rmeldo

Senior Member
Changing the baud rate + which firmware?

Hi,

I am having problems changing the BAUD rate on my ESP8266 ESP-03. When I type the command: AT+UART_CUR=9600,8,1,0,0 results in an ERROR string being returned.

I have been able to use all the other commands (I am communicating with it with a FTDI USB adaptor) but failed to change the baud rate so I am stuck at 155200, beyond the reach of my 18M2.

Any suggestions?

Also I am a complete loss at locating different firmware. I find the Espressif website very confusing and I could not find the AT firmware but only a "esp_iot_sdk_v1.3.0_15_08_08". Nowhere I could find the AT firmware mentioned.

Could someone please post a link to the latest (or a previous fairly recent working version) firmware?

By the way, I am trying to replicate the following instructable: http://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/

I think this approach is quite interesting, as I would like to avoid going through a third party server, like thingspeak, and do my data manipulation instead. I managed to replicate the server side behaviour and to post fake sensor readings with requestmaker.com (very useful), but I am stuck at driving the ESP with the 18M2 until I manage to change the BAUD rate

Many Thanks
Riccardo
 

julianE

Senior Member
When I type the command: AT+UART_CUR=9600,8,1,0,0 results in an ERROR string being returned.
What works for me is just this,

AT+UART=9600,8,1,0,0 will set the baud speed to 9600

I have also done it with just,

AT+UART=9600

I would advise against the following since it's not persistent but might help for troubleshooting, it will revert to original speed on reset,

AT+CIOBAUD=9600

I will look for my links for firmware very soon and post.
 

rmeldo

Senior Member
An update:

I managed to change the frequency with:

AT+CIOBAUD=9600

I also found out that it is persistent and survives the reset, so I am ready to go now without having to try out new firmware. Thanks for the help.

Also on another subject:
Has anyone installed Thingspeak on their own server or Raspberry pi? I saw that their code is open source.

Thanks
Riccardo
 

rmeldo

Senior Member
Hello again,


I got the ESP8266 working with a Picaxe M2 and logging data to a website. Code below:

Code:
#picaxe 18M2

symbol TCP_Send  = C.1

eeprom  0, (190,10)

Startup:
   read 0,b0 
   read 1,b1
   setfreq m16
   serout TCP_Send,T19200_16,("b0 = ",#b0,",   b1 = ",#b1,13,10)

Main:
   ;--------------------------------------------
   gosub connectToRouter
   pause 10000
   gosub sendSplit
   b0 = b0 - 1
   b1 = b1 + 1
   write 0, b0
   write 1, b1

   read 0,b0 
   read 1,b1
   setfreq m16
   serout TCP_Send,T19200_16,("b0 = ",#b0,",   b1 = ",#b1,13,10)

   Nap 10   '16s nap
goto main

connectToRouter:
   pause 5000
   setfreq m16
   serout TCP_Send,T19200_16,("AT+RST",13,10)
   pause 10000
   serout TCP_Send,T19200_16,("AT+CWMODE=1",13,10)
   pause 10000
   serout TCP_Send,T19200_16,("AT+CWJAP=",34,"router name here",34,",",34,"router password here",34,13,10)
   pause 20000
   serout TCP_Send,T19200_16,("AT+CIPMODE=0",13,10)
   pause 10000
   serout TCP_Send,T19200_16,("AT+CIPMUX=1",13,10)
   pause 10000
return


sendSplit:
   ; ----------------------------------------------------------
   serout TCP_Send,T19200_16,("AT+CIPSTART=0,",34,"TCP",34,",",34,"host website",34,",","80",13,10)
   pause 10000
   serout TCP_Send,T19200_16,("AT+CIPSEND=0,23",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("POST /add.php HTTP1.1",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("AT+CIPSEND=0,20",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("Host: host website hagain",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("AT+CIPSEND=0,13",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("Accept: */*",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("AT+CIPSEND=0,49",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("Content-Type: application/x-www-form-urlencoded",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("AT+CIPSEND=0,20",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("Content-Length: 17",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("AT+CIPSEND=0,2",13,10)
   pause 1000
   serout TCP_Send,T19200_16,(13,10)
   pause 1000
   serout TCP_Send,T19200_16,("AT+CIPSEND=0,23",13,10)
   pause 1000
   serout TCP_Send,T19200_16,("temp1=",#b0,"&hum1=",#b1,13,10,13,10,13,10)
return
I have used the code by REB100 as a guide, thank you. Since I am working on a battery powered application and due to the high power consumption of the ESP8266 however I would like to send the data logged once or twice a day and in the shortest time possible.

My question is whether there is a transmission protocol where I can send bursts of data, say 100 or 200 at the time, without having to specify the length of the data string for every set of logs(Content-Length: xx)?

Alternatively, is there a best practice to deal with this type of data transmissions?

Many thanks
Riccardo
 

steliosm

Senior Member
You could probably use the "Unvarnished Transmission Mode" of the ESP8266.
According to the documentation from this site:

https://github.com/espressif/esp8266_at/wiki/CIPSEND

Unvarnished Transmission Mode:

Wrap return “>” after execute command. Enters unvarnished transmission, 20ms interval between each packet, maximum 2048 bytes per packet. When single packet containing “+++” is received, it returns to command mode.
So, I guess you connect to your custom TCP server, send your packets, 2048bytes maximum per packet - allow 20ms for the packet to be send before sending any more packets, and you can send your complete data log.
 

rmeldo

Senior Member
Thanks for that, very useful.

The link is quite useful too (although it does not contain the command AT+CIOBAUD. I wonder whether there are more missing.
EDIT: It has AT+IPR though, which claims to change the BAUD rate too. I will try it)

I guess on the server side I would have to use the instruction "Transfer-Encoding: chunked" ?

Thanks
Riccardo
 

tracecom

Senior Member
I have recently started experimenting with ESP modules, and wonder if any of the posters in this thread are making progress.

Thanks.
 

julianE

Senior Member
Thanks tracecom, that's a very nice write up. I'm pretty content with the ESP8266, unlike picaxe it's very disorganized and nowhere as easy to use but if persistent and once a good firmware is loaded it becomes very consistent. I'm using an older release because it has responses that I'm used to. The thing about the module it's reponses change release to release, sometimes the module will respond after a command with a nice terse "OK" and then in a later release it will be a more verbose response. It really improves the reliability if the picaxe is set up to receive messages from the module so as to know if the command worked. In the beginning I just sent commands and hoped it worked by using long pauses between commands. Hemi345 has a very nice example of command/response that was very helpful. Another option is to use Lua, 1968neil wrote a brilliant example of an 8266 as a webserver, very stable. Here is the link to both examples,

http://www.picaxeforum.co.uk/showthread.php?26811-ESP8266-WiFi-serial-module&p=287738#post287738

mrburnette just posted a new development for 8266, BASIC programming. I have tried it and it loads well but I'm not having the best of luck albeit I have not put in that much time.

Truth be told, I learned more about the 8266 module from this site then from sites dedicated to the module itself. I think it works very well with the picaxe and I can post data to thingspeak with good consistency now.

I've said it before, this is the best forum I have seen on the internet, exceedingly brilliant and helpful folk.
 

rmeldo

Senior Member
I have recently started experimenting with ESP modules, and wonder if any of the posters in this thread are making progress.
I've had good results with the ESP8266 so far, with a lot of help from the people on this forum.

A first datalogger project I completed uses Picaxe, an ESP8266 ESP-03 on a small breakout board and the AT command set. It is quite reliable, if not power hungry for a battery operated project, so everything is sent to sleep for as long as possible. I didn't implement the method by Hemi345 for lack of programming memory, but it is on my to do list. I posted my code in a previous post, although it is nothing special.

I am now working on other building blocks for my (yet another) home energy control system, with the focus on getting the datalogging functionalities working first.

This week end gone I worked on the electrics meter and I am quite chuffed with myself. This time I have used only the ESP8266 NodeMCU devkit 1.0 with Lua (sorry Picaxe). This is because I have access to mains power so I can afford to keep the ESP awake or in standby. I had to trawl various sites for code snippets but by last night I had similar core functionalities to the gas datalogger (minus LCD and buttons control logic) in just 76 lines of code! The software version is NodeMCU 0.9.6 build 20150704. With LUA, the ESP when first turned on will connect automatically to the last network it used. When transmitting it will try several times if the connection is slow and times out.

The NodeMCU devkit 1.0 is also brilliant: just plug in the USB and start programming.

At first I tried to use the Arduino IDE instread of Lua, but I could not get the IDE to connect and upload the compiled code to the ESP. Very frustrating. Probably something very simple but the lack of documentation didn't help. Now however I am not that sorry, since reading about Lua and its suitability for IoT applications. I think that the fact that my program is so short saved me from the low programming memory space that others have reported.

The ESP is great because of WiFi and the low price.

For projects that don't need WiFi (and I suspect for longer programs) then it seems to me the Picaxe is a better platform.

I hope it helps
 

tracecom

Senior Member
@rmeldo

Thanks for your post. I am trying to decide what programming language to invest my time in for the ESP. It seems you have settled on Lua. What sources did you use to learn to program in Lua? Did you buy a book? Can you use a PICAXE to communicate with an ESP running Lua? Do you foresee ever being able to program a PICAXE over the web?

Thanks.
 

rmeldo

Senior Member
Hi,

I am hardly an expert in electronics so I am not sure I am qualified to answer well, but I will have a go.
To answer your questions:

What sources did you use to learn to program in Lua? Did you buy a book?

I didn't buy a book. I used the nodeMcu.com site for the examples relative to the various things I needed to do.
http://www.nodemcu.com/docs/ explains the classes and methods available in Lua for ESP8266.
http://www.electrodragon.com/w/ESP8266_NodeMCU_Lua has more snippets and several other links
http://www.lua.org/manual/5.3/ is the reference manual. There is another, more clear reference source, but I cannot find it at the moment.

I have studied a lot of programming languages over the years for work and (sic) pleasure. Object oriented programming is very powerful, and once you understand the constructs you can "feel" your way around, even in languages you haven't used before.

If you have some experience in C, C++, etc. and to some extent PHP, you will recognise several language constructs and adapt for differences.

The error messages in the Lua compiler of the "ESPlorer" program are also quite effective at pointing out what you're doing wrong.

I have seen books advertised and I could have bought one, but I wanted to get on with the programming .... I might read about IoT in the future, more for awareness and general interest, though. There seem to be a lot of new advances happening at the moment.

Can you use a PICAXE to communicate with an ESP running Lua?

I presume you could still communicate with the ESP8266 through serial communication. You would have to have a listening loop in at least the slave system (Picaxe or ESP). Maybe other forum members can elaborate on this answer.


Do you foresee ever being able to program a PICAXE over the web?

This I have asked myself as well. Picaxe sell WiFi modules to program over WiFi, albeit pricey. I am sure someone will try to setup a ESP to do it, but I am not qualified to judge whether it is technically possible.

You can program the ESP over the web though.... horses for courses.

Riccardo
 

lbenson

Senior Member
... A first datalogger project I completed uses Picaxe, an ESP8266 ESP-03 on a small breakout board and the AT command set

...

This time I have used only the ESP8266 NodeMCU devkit 1.0 with Lua (sorry Picaxe).
Can you post your breakout board layout? If it is perchance in Eagle, can you post the board and schematic files if you feel like sharing?

I've used Lua running on a small router device running openWrt or debian many times to communicate with a picaxe. I know it's OT, but have you documented your project somewhere with the Lua code, and if so, can you provide a link?

tracecom--I would agree that Lua is a very powerful lightweight language. I have Beginning Lua by Kurt Jung and Aaron Brown, quite a thick book. You can probably find everything you need on the web, but I don't know of a great online overview source. If you know any C, lua will look very familiar. You can install lua on a PC, and test your programming from a dos command prompt.
 

tracecom

Senior Member
Sure,

I'll put something together.

Tonight I will post the Lua code
I have set up an ESP-12E, and have successfully flashed it with NodeLua version 1.0.20150120. Is there more that I can do to prepare for your code?


ETA: Or am I supposed to have some other firmware on the 8266?
 

rmeldo

Senior Member
Try and run some examples, like blinking an LED and firing an interrupt by pushing a button.... Things like that.

What is your project?

Riccardo
 

tracecom

Senior Member
Riccardo,

Just now I don't have a project other than learning how to use the 8266 with a PICAXE. Maybe just read a temp sensor and log the results?

I am confused between NodeLua and NodeMCU. Is the firmware the same for both?

Charles
 

tracecom

Senior Member
I have looked at it but not much.

What is the firmware you are using in your 8266 and which model are you using?

ETA: I have to go get a car repaired. Be back later.
 
Top