Given how cheap ESP8266's are, and how seemingly difficult doing OTA programming is in practice, and given how fast ESP8266's are and given their much higher datarates, would it make any sense to tack one on and use it purely for programming a moteino? Yeah, OK, forget coincell operation. I can live with that loss. Yeah, OK, so an ESP8266 isn't as power efficient. So what? Have the Moteino briefly turn on the ESP8266 if and only if you want to do an OTA firmware update of said moteino, and then turn the ESP8266 off and forget it even exists. Is it a waste of transistors? Sure, but who cares? Those are cheap transistors. ;) Besides, wouldn't using an ESP8266 be an incredibly FAST way to do the OTA programming? At the very least, it could receive the programming code much faster, and that would eliminate at least some of the lag. I mean, you can use the arduino IDE to program an ESP8266, and so this really should be easy, right? Arduino's programming arduino's: plenty of examples of how to do that. So, notionally, why not treat an ESP8266 like an arduino and just brute force an ESP8266 to receive and perform an OTA programming of a Moteino? It has 80K of user RAM, so it could (potentially) receive the entire Moteino firmware into memory and then dump it into the moteino when it's fully received and validated.
OK, yes, I'm spitballing this, but is there some obvious obstacle I'm overlooking? If so, what is it? Yes, I've seen the youtube video on doing the OTA moteino programming using flash memory, and--to be frank--it looked like a *lot* of steps. So many, in fact, that hooking up the wires as I'm currently doing seems like it would be faster. Isn't there an EASY, stupid simple way to do this? I've got to believe that FAST and EASY OTA programming is on everybody's wish list, and yet how many of us are currently doing it? Maybe I have the wrong perception, but the impression I get is that the number of moteino users currently doing it is very, very few. I've got Moteino's with flash on them, so I guess I could, in theory, be doing it, but, like I've already said, it looks like a *lot* of steps, so it doesn't currently look like a win to me. Maybe I'm totally wrong, and if so, I would be very happy to be wrong if, in reality, it turns out I can actually do OTA programming both EASILY and FAST.
So, let's take a poll. Who's doing it? Is it easy and fast? Who's not doing it, but wish they could do it easy and fast? Please answer by taking the pole here: https://lowpowerlab.com/forum/index.php/topic,1348.msg9305.html#msg9305
Using a esp8266 for firmware updates is completely unnecessary. The speed at which you can update a Moteino is not limited by the radio but by the flash on the 328p which will flash at about 30kb per second and chip speed.
Its possible to design a boot loader that updates a Moteino without external flash in a few seconds. Granted it costs you 4kb in flash but the overall solution is much simpler and more cost effective than adding another mcu. And it does work with coin cells :D
Quote from: joelucid on October 12, 2015, 07:09:16 AM
Using a esp8266 for firmware updates is completely unnecessary. The speed at which you can update a Moteino is not limited by the radio but by the flash on the 328p which will flash at about 30kb per second and chip speed.
Thanks. Good to know. :)
Looks like it's fairly easy for an Uno to program an Uno (https://www.arduino.cc/en/Tutorial/ArduinoISP).
(https://www.arduino.cc/en/uploads/Tutorial/arduinoisp.png)
The sketch comes prebuilt into the Examples of the Arduino IDE. Not quite on-point with what I need, but it's a possible starting point.
The best way to do it is to write a bootloader. That's a special piece of code that gets flashed at the end of the 328p's flash memory replacing optiboot using an ISP like the one you've posted here (Felix likes to point out though that you should really use an official atmel's programmer like the mkii instead - and after frying 2 moteinos with the moteino as ISP approach I agree).
The bootloader then gets invoked when the 328p is reset, can download the app and can use special instructions to self program the flash on the 328p. It can even replace itself that way - so you need the ISP only once. Check out the datasheet it's all explained there.
The challenge then is to make the procedure robust and fast and fit everything in 4K, the largest allowed bootloader. It can be done but it'll take some time.
Found what I needed. Here's a complete recipe for how to transparently and wirelessly program an arduino/moteino using an esp8266:
http://hackaday.com/2015/09/18/transparent-esp8266-wifi-to-serial-bridge/
Enjoy!
Aliexpress has esp8266's for $1.80, delivery included.
I won't want the esp8266 to be running continuously, but only when it's needed. According to one of the datasheets (http://wiki.iteadstudio.com/ESP8266_Serial_WIFI_Module), it "typically" consumes 500na when in "Total Shutdown," which would be OK by me, but the same datasheet only promises it to be something less than 10ua. Notably, the DS also says it can typically draw up to 215ma when doing Wi-Fi, so I obviously can't rely on just a Moteino GPIO pin to power it. :(
So... I'm tentatively thinking I'll power the esp8266 ON as needed for sketch updates using an N-channel mosfet, and then OFF again after the update finishes. Any favorites for an n-channel mosfet that has ultra low current when turned off?
I suspect using the esp8266 as transparent wifi/serial bridge for app installs will be pretty slow. The protocol isn't optimized for high latency environments so you'll get lots of round trips and slow transfer speeds.
But it should work - even if keeping an extra radio around just for installs feels a bit weird.
I would use a P-channel MOSFET instead of an N-channel for the reasons outlined in http://forum.arduino.cc/index.php?topic=285286.0 and http://www.onsemi.com/pub/Collateral/AND9093-D.PDF. The Fairchild FDV304P/FDV304N might be a reasonable choice but I still get the feeling that either the Moteino is going to be redundant or the ESP8266 is going to be redundant.
Quote from: jra on October 14, 2015, 04:23:41 PM
I would use a P-channel MOSFET instead of an N-channel for the reasons outlined in http://forum.arduino.cc/index.php?topic=285286.0 and http://www.onsemi.com/pub/Collateral/AND9093-D.PDF. The Fairchild FDV304P/FDV304N might be a reasonable choice...
Thanks for the steerage and the links! I'll read up on that.
Because the ESP8266 is such a power hog, I don't think the Moteino will be redundant in a battery operated scenario. When coupled with listen-mode, the Moteino becomes super energy efficient. Unless I'm missing something, I don't think the ESP8266 can compete with that. I don't deny though that on its face their union has earmarks of an ugly kludge. Doesn't matter: it's cheap. My objective is just a low-effort, immediate solution until something better comes along.
Besides, I have hopes that the ESP8266 will be an interesting add-on for doing wireless updates to the regular Arduino's that I have scattered about that run from mains rather than batteries. I'd love not having to reconnect them by wire every time I need to make some minor update to a sketch. Now that ESP8266 wi-fi is dirt cheap and (reportedly) works so well, I'd like to put it on everything! You're right, though, that in those cases the arduino's might be redundant, given that the the ESP8266 MCU outclasses most Arduino's, at least in terms of memory, speed, crunch power, and some other dimensions too. However, setting aside that technical truth and looking at the bigger picture, for $1.80 a pop for a simple retrofit, it's just irresistible!
Did you have a particular application in mind? For those Arduinos that you have powered from AC it should be straightforward to replace them with ESP8266's using Ivan's ESP8266 Arduino IDE unless they are connected to some particular sensor/display/device for which support is still lacking. If you are planning on using MQTT there is an OTA update example that could easily be integrated into an existing MQTT environment. You could MAYBE run it on solar/lipo if the duty cycle was low enough. If you want to run using a much smaller battery and/or solar recharging is not an option and/or you need the range/penetration of a sub-GHz radio, I would use the Moteino OTA solution that has already been debugged. I've definitely done more programming on ESP8266's over the past year than I have on AVR's (because they are bigger, faster, cheaper) but I don't run any of them on batteries.
Quote from: jra on October 14, 2015, 09:15:16 PM
... but I don't run any of them on batteries.
LOL!!! Really?
@jra, Seriously, given your experience with the ESP8266, where do you think it 'shines'? Given the cost point and intrinsic WiFi/TCPIP capability, there has to be a sweet spot for this device. Probably most nodes that are AC powered, be my guess.
Tom
UPDATE: Fixed typo
@tomws If your application can function within its limitations which are currently:
1) Voracious appetite for power (~300ma peak vs. 45ma peak for an RFM69W and 130ma peak for an RFM69HW)
2) Lack of I/O (20 pins max including 1 HW UART and 1 ADC) relative to AVR/ARM-based Arduinos
I think the ESP8266 family is currently the cheapest/easiest way to get data from a variety of locations onto your WAN/LAN/Internet. Although the modules are generally available for $3-4, they're not really usable as-is. Most of them have castellated pins on 2mm centers so you need to solder it to some other carrier to make it breadboard friendly. You also need a well regulated 3.3v power source, pull up/down resistors on key pins, etc. The modules that do provide pins on 0.1" centers tend to have very few pins exposed. Not a big problem if you plan on using it as an attached processor but you still need to address the power issue etc. There are a number of boards available as complete solutions (Adafruit Huzzah, NodeMcu, Electrodragon, Omilex) and even more available on oshpark.com or dirtypcbs.com if you want to solder your own. Taking all of this into consideration, I think you should plan on the actual cost of a usable solution to be closer to $10 rather than $3-4. Still inexpensive by Arduino standards unless you count the Pro-Mini/STM32F103 clones.
As an example suppose you want to monitor the temperature and humidity in your basement, 1'st floor and 2'nd floor and make it available via a web page. One solution could be to buy:
Three Moteno R4's with RFM69W's and three Weather Shields (3x$20 + 3x$20 = $120)
Three 5V power supplies (a few bucks each or reuse the ones you may have lying around or use batteries)
One Raspberry Pi (maybe $50-60 including case, PS, WiFi dongle)
After learning how to use the Arduino IDE and maybe just enough Linux to be dangerous, you deploy the Moteinos to the three locations, connect one via serial to the Pi, program them using the code that Felix has already gratefully provided and you can be up and running in fairly short order for less than $200.
An ESP8266 option might be to buy:
Three ESP8266 boards (~3x$10) and three i2c HDC1008 temperature/humidity sensors (~3x$10) = $60
Three 5V power supplies (a few bucks each or reuse the ones you may have lying around)
One Raspberry Pi (maybe $50-60 including case, PS, WiFi dongle)
The code will be a little more work but all of the pieces are already available as examples. You could use a little finesse and set up an MQTT broker on the Pi along with MQTT clients on the ESP8266's or you could go old school/brute force and make the data available on each of the ESP's via http/port 80 and simply scrape it from the Pi if you are already Linux/Unix savvy. If you are hesitant to learn Linux and don't mind putting your data on the cloud, you can even skip the Raspberry Pi entirely by opening up a free account on https://thingspeak.com or https://data.sparkfun.com or https://m2x.att.com and push the data directly from your ESP8266's, also plenty of examples online how to do this.
If you want to add another sensor node using Moteinos (maybe to sense the ambient, freezer and refrigerator temperatures in a garage) I suspect you will need to modify code on both the Moteino receiver (unless you make it generic enough the first time around to listen for senser node ID's that haven't yet been established as well as pass arbitrary structures to the Pi gateway) as well as the Pi. Since the ESP's in this example don't talk to one another, the only change would be on the Pi. Or the cloud if you use one of the services mentioned above. Maybe that's a slight advantage.
When the ESP-01 first came out the model was to communicate with it via AT commands (like a modem) and connect it to your existing Arduino/Pic/whatever to access your WiFi network. When the SDK became available, people started programming it in C/C++ and a variety of custom firmware packages became available including a Lua interpreter. All of these mechanisms still have their advocates/users but I think the two things that really allowed this device to take off were:
1) The availability of modules with enough exposed pins to make them useful as standalone devices
2) The ability to program them using the Arduino environment
The latter allowed folks to leverage most of their Arduino experience and libraries. If you were previously using an Arduino + a WiFi sheid to do some processing and get it on the WAN/LAN, you may be able to replace both with a single ESP with very minor changes to the code. Where the ESP won't help is if you have a lot of analog sensors as there is only a single ADC on the ESP and to be honest I'm not sure how good it is. You also only have a single HW UART. This may not be as big a deal since SoftWare serial is available and bit banging a SW UART with an 80MHz processor is not particularly taxing.
This brings up another point. If you have a sketch that is resource intensive (either RAM or flash or CPU speed), a 1284 AVR processor maxes out at 16K RAM/128KBytes Flash/20MHz CPU. A Teensy 3.x (chosen as an example of a small footprint ARM-based board with Arduino support) has 64K RAM/256KBytes Flash/72MHz CPU. An ESP8266 has 64K Instruction RAM (+96K Data RAM)/512K-4M Flash (all external)/80 MHz CPU. If it doesn't fit on a Moteino Mega, you could maybe run it on an ESP for half the price of a Teensy even if you don't need/use the WiFi. As an example, I compiled the following Blink sketch on a 328P Pro-Mini clone:
void setup() {
Serial.begin(9600);
pinMode(5, OUTPUT);
}
void loop() {
Serial.println("5 on");
digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
Serial.println("5 off");
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Reported resource usage was as follows:
Sketch uses 2,378 bytes (7%) of program storage space. Maximum is 30,720 bytes.
Global variables use 210 bytes (10%) of dynamic memory, leaving 1,838 bytes for local variables. Maximum is 2,048 bytes.
When compiled on an ESP-12e configured with 1M Flash allocated for sketches plus 3M Flash allocated for SPIFFS filesystem the result was as follows:
Sketch uses 203,652 bytes (19%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 33,034 bytes (40%) of dynamic memory, leaving 48,886 bytes for local variables. Maximum is 81,920 bytes.
Yeah, a lot of crud gets pulled in by default for WiFi support but you still have a lot left over. Not sure how you would ever use all of it up in an embedded system byut my experience has been that an excess of resources leads to sloppy coding. There are some new projects out there now in various stages of development including:
1) A Basic interpreter (maybe appeals to the BasicStamp affectionados)
2) A MicroPython interpreter
3) A Lisp interpreter (maybe someone wants to port emacs to the chip)
Like I said, I've probably spent more time programming ESP's over the past year than Moteinos but a lot of that has to do with the Moteinos I have already doing what I want them to. An early limitation was lack of a stable programming environment but I believe that one has been largely overcome to the point that it is just as easy to program an ESP today as it is to program any other Arduino. Bottom line for me is that the sweet spot for this device is any application within WiFi range that doesn't need to run on a battery.
@whitehare
If you are using the Arduino environment you will want to use @lmroy's MQTT port https://github.com/Imroy/pubsubclient. One of the examples is the OTA update via MQTT https://github.com/Imroy/pubsubclient/blob/master/examples/ESP8266-OTA/ESP8266-OTA.ino. If you are using @tuanpmt's standalone MQTT firmware https://github.com/tuanpmt/esp_mqtt there is a fork by @nqd that supports OTA https://github.com/nqd/esp8266-dev/. I've used the Arduino MQTT library but haven't personally tried OTA yet, day job keeps getting in the way.
@jra, WHOA! Just when I was beginning to think you didn't care... ;D
Wow! Great! Uh, it's gonna take me a few minutes to work my way through this. The first thing I'd like to know is HOW did you fit this in the 5K limit this forum has on a post!
EXCELLENT SUMMMARY! Thank you!
The 2mm castellated pins don't pose an issue for me, I've got some XBee pins and sockets laying around so easily adapted. 20 pins sure beats RFDuino's 6 pins of I/O and I've done some usable stuff with that.
Big surprise on the amount of code need to support the stack. I guess this tends to be invisible on some of the Nordic devices, however, so hard to compare. In any case, thanks again. I'm sure many people will benefit from you're taking the time to write this!
Tom
@jra
Thank you for your fantastic post!
Not really knowing where to start, I decided to get the Adafruit ESP8266 (http://www.adafruit.com/product/2471), but I'd be curious as to which of the dozen or so different ESP8266 models a savvy guy such as you likes the best. Supposedly the ESP8266EX is FCC certified. Also, according to the ESP8266EX datasheet, "Deep sleep power <10uA, Power down leakage current < 5uA," so maybe I can skip the MOSFET after all. :)
@tomws Didn't even know about the 5K limit, cut/paste | wc says 8K, maybe it's magic? The 20 pins was for the ESP-12e but I'm not sure all of those are actually usable. Unlike the AVR's, there is no internal flash on the ESP8266 so all flash is external. The ESP-12e exposes the 4 SPI pins used to communicate with flash but there is some controversy as to whether you can use them to communicate with other SPI devices without screwing the pooch, see http://www.esp8266.com/viewtopic.php?f=32&t=4094 for details.
@whitehare The Adafruit Huzzah is a good start, it is actually an ESP-12 mounted on a board with all of the necessities and the IDE (at least the latest github version) has a specific entry for the Huzzah. You will also want a USB-TTL converter that supports DTR and RTS so you can flash the device without having to press the reset/flash switches in the right sequence. My latest purchase (and current favorites) was five ESP-07's and five ESP-12e's from http://stores.ebay.com/tomyuen007/ along with nine https://oshpark.com/shared_projects/9CsYq2PY. The ESP-07 and ESP-12(e) are nearly the same. The only difference is the 07 has a chip antenna that can be disabled by unsoldering a coupling capacitor to enable the U-FL connector for an external antenna; the 12's have PCB antennas. That is so I can put one inside my shed with the antenna outside. The board is by the same German fellow whose link I pointed you to previously, see also https://oshpark.com/profiles/8n1. You may be interested in his (still untested) newer boards that utilize LDO's with enable pins. Advantage to that solution is that you can power down the ESP plus the sensors in case they draw any leakage current. The ESP-12 is FCC certified, don't know if that applies to the 12e as well.
@jra Thanks!
To facilitate rapid hookup of 2mm parts to regular arduino's, I'm using these prototype shields:
http://www.ebay.com/itm/201259671475?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
Based on your feedback I just ordered some extra esp12e's from Ali Express at $1.95 each:
http://www.aliexpress.com/store/product/New-version-ESP-12E-replace-ESP-12-ESP8266-remote-serial-Port-WIFI-wireless-module/731260_32339917567.html
FWIW, in the past I've purchased inexpensive pro mini's from that vendor without issue, and by upgrading to e-packet delivery, they arrived quickly.
As cheap "just in case" insurance, I also ordered some of these adapter boards:
http://www.aliexpress.com/item/Serial-WIFI-ESP8266-module-adapter-plate-Full-IO-port-leads-only-adapter-plate/32273534748.html
However, I haven't used that vendor before, so caveat emptor.
Quote from: WhiteHare on October 17, 2015, 09:26:11 AM
@jra
Thanks!
To facilitate rapid hookup of 2mm parts to regular arduino's, I'm using these prototype shields:
http://www.ebay.com/itm/201259671475?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
That's a useful board! Good find!
Quote
I just ordered some extra esp12e's from Ali Express at $1.95 each:
http://www.aliexpress.com/store/product/New-version-ESP-12E-replace-ESP-12-ESP8266-remote-serial-Port-WIFI-wireless-module/731260_32339917567.html
FWIW, in the past I've purchased inexpensive pro mini's from that vendor without issue, and by upgrading to e-packet delivery, they arrived quickly.
Good info, thanks.
Tom
Quote from: WhiteHare on October 17, 2015, 09:26:11 AM
I also ordered some of these adapter boards:
http://www.aliexpress.com/item/Serial-WIFI-ESP8266-module-adapter-plate-Full-IO-port-leads-only-adapter-plate/32273534748.html
(http://i.ebayimg.com/00/s/ODA5WDkxMA==/z/RPgAAOSwstxVZSTc/$_35.JPG)
As an aside, I just now compared (by eye) the spacing between pin rows on an ESP8266-12E with that of an RFM69W, and it looks virtually the same. Not only that, but they have the same number of pins. So, the above 33 cent (delivered!) adapter plate may well turn out to be the cheapest way to adapt 2mm pitch RFM69W's to a breadboard friendly 2.54mm pitch!
Wish I could find an equally cheap and equally good matching adapter plate for an RFM69
HW! So far the closest I've found for that were some adapter wings.
Quote from: jra on October 16, 2015, 05:39:56 PM
You also need a well regulated 3.3v power source...
@jra Which voltage regulator are you liking the best for use with ESP82866's?
I'm finding that the lowpowerlab's FTDI adapter v.2, when configured to deliver 3.3v, doesn't have enough power to run even a simple blink program on the Huzzah. I measured it as delivering only 3.1v when connected to the adafruit ESP8266. If run through the LDO of the Huzzah, the delivered voltage was too low to run the blink program. If I wired the same unit so as to directly power the Vcc of the Huzzah, then the blink program would run, but be unstable: it kept resetting itself. It might work (though not sure), if I configured it to deliver 5v to the LDO, but I want to leave it as is for when I'm programming 3.3v Pro Mini's.
So I'm presently powering the Huzzah through a USB console cable. That delivers adequate 5v voltage to the Huzzah. However, it's only 4 wires and so it can't do a reset. Because of that I'm presently doing resets manually on the Huzzah, and that does allow me to upload sketches. Again, by the time the ESP-12E's arrive, I want to have a better setup.
Which FTDI adapter do you like best for working with ESP8266's?
WhiteHare, the 3.3V of the FTDI comes from the FT231XS chip's regulated supply that cannot offer more than about 50mA. It was never intended as a power supply, just a jumper option in case 3.3V 50mA is needed for something. The default is the USB 5V that is passed through and can supply 500mA to your target.
50mA in low power electronics is enough to "fly you to the moon".
The ESP devices need several times more than that, so I expect they can fly you to mars with those power requirements. Good luck running on batteries.
Quote from: WhiteHare on October 17, 2015, 04:19:35 PM
Quote from: WhiteHare on October 17, 2015, 09:26:11 AM
I also ordered some of these adapter boards:
http://www.aliexpress.com/item/Serial-WIFI-ESP8266-module-adapter-plate-Full-IO-port-leads-only-adapter-plate/32273534748.html
(http://i.ebayimg.com/00/s/ODA5WDkxMA==/z/RPgAAOSwstxVZSTc/$_35.JPG)
that adapter board doesn't pick up the 12E's pins on the bottom row (SPI and additional GPIO). Maybe you're ok with that, but it did catch my eye.
Quote
As an aside, I just now compared (by eye) the spacing between pin rows on an ESP8266-12E with that of an RFM69W, and it looks virtually the same. Not only that, but they have the same number of pins. So, the above 33 cent (delivered!) adapter plate may well turn out to be the cheapest way to adapt 2mm pitch RFM69W's to a breadboard friendly 2.54mm pitch!
Wish I could find an equally cheap and equally good matching adapter plate for an RFM69HW! So far the closest I've found for that were some adapter wings.
I don't quite understand this. The RFM69W and RFM69HW have the same footprint. Where is the problem? Did you mean RFM69
CW and RFM69H
CW respectively? These are both 16mm row spacing with 2mm pitch, but the RFM69HCW pins interfere with the adapter's VCC & GND planes. The RFM69CW, with its 14 pins can be offset to avoid the planes.
Tom
@whitehare Ditto what Felix said, none of the USB-TTL adapters that I know of supply enough 3.3v current to drive an ESP. Pull from the 5V USB bus and drive a separate regulator. I generally use LM1117's because I already have a ton of them and, not to belabor the point, their relatively high dropout voltage is not an issue if you're not using batteries. For you I would look at something more efficient, maybe a buck converter or even a buck-boost converter. Something like a 3v3 version of https://lowpowerlab.com/shop/buckregulator or https://www.adafruit.com/products/2745 or build your own around ti's 63000 series http://www.ti.com/product/tps63001/description.
As far as USB-TTL adapters I use CP2102's like http://www.ebay.com/itm/Replace-FT232-6Pin-USB-2-0-to-TTL-UART-Module-Serial-Converter-CP2102-STC-/321546809495 because you can easily solder on a pair of headers and get the pins you need. Don't confuse RST (resets the CP2102 itself) with RTS (Request to Send) which is the one you want.
Quote from: Felix on October 17, 2015, 09:37:38 PM
WhiteHare, the 3.3V of the FTDI comes from the FT231XS chip's regulated supply that cannot offer more than about 50mA. It was never intended as a power supply, just a jumper option in case 3.3V 50mA is needed for something. The default is the USB 5V that is passed through and can supply 500mA to your target.
Thank you!
Quote from: Felix on October 17, 2015, 09:37:38 PM
50mA in low power electronics is enough to "fly you to the moon".
The ESP devices need several times more than that, so I expect they can fly you to mars with those power requirements. Good luck running on batteries.
Just to clarify, I envision the trips to mars will be limited to the duration of OTA programming events, and my rocket engines will be more than a coin cell. That said, I do sense it may have a crew payload of only 1 (moi), but maybe it will find other uses too.
Just out if interest: what do you find complicated about Felix ota method?
Quote from: joelucid on October 18, 2015, 01:18:55 PM
Just out if interest: what do you find complicated about Felix ota method?
I'm curious as well. I use Felix's flash and DualOptibootloader method and it works well enough. I just use a different method to load the flash in a bootloader compatible format.
Tom
Quote from: jra on October 18, 2015, 11:04:52 AM
As far as USB-TTL adapters I use CP2102's like http://www.ebay.com/itm/Replace-FT232-6Pin-USB-2-0-to-TTL-UART-Module-Serial-Converter-CP2102-STC-/321546809495 because you can easily solder on a pair of headers and get the pins you need. Don't confuse RST (resets the CP2102 itself) with RTS (Request to Send) which is the one you want.
Thanks! I just ordered one from a domestic shipper, and it should be here by next weekend, if not sooner. :) Among other things, it does include an RTS (see attached photo):
Quote from: jra on October 18, 2015, 11:04:52 AM
@whitehare Ditto what Felix said, none of the USB-TTL adapters that I know of supply enough 3.3v current to drive an ESP. Pull from the 5V USB bus and drive a separate regulator. I generally use LM1117's because I already have a ton of them and, not to belabor the point, their relatively high dropout voltage is not an issue if you're not using batteries. For you I would look at something more efficient, maybe a buck converter or even a buck-boost converter. Something like a 3v3 version of https://lowpowerlab.com/shop/buckregulator or https://www.adafruit.com/products/2745 or build your own around ti's 63000 series http://www.ti.com/product/tps63001/description.
The Huzzah uses the SPX3819 as its voltage regulator: http://www.exar.com/common/content/document.ashx?id=615
Costs 72 cents from digikey. I like that it can be turned on/off with an enable pin. However, I just now did the measurement, and I find that if the only thing I do is set the LDO enable pin to ground, then the Huzzah still draws 500uA at 5v, which obviously isn't good at all! Given this, it's funny that the SPX3819 datasheet would say "When disabled, power consumption drops to nearly zero. "
I couldn't get the current lower than about 416uA by disabling the ESP8266 alone. Strangely enough, if I then subsequently also disabled the LDO, then the current rose to about 500uA again.
The Huzzah spec sheet says there is a 10K pullup from EN to V+/Bat. If you connect it to ground to cut power it sounds like you will still have 5V/10K = 500uA flowing through the pullup.
Looks as though it can run on 3x AA batteries without a regulator from 4.5v down to 3.1v (http://forum.makehackvoid.com/t/esp8266-operating-voltage-range-and-sleep-current/286/58), so I'm going to run with that assumption. I'll wait to do those experiments until the cheap 12E modules arrive, though, as I have only one Huzzah.
Quote from: jra on October 19, 2015, 07:24:22 AM
The Huzzah spec sheet says there is a 10K pullup from EN to V+/Bat. If you connect it to ground to cut power it sounds like you will still have 5V/10K = 500uA flowing through the pullup.
@jra
Poking around I found a class of integrated load switches (e.g. http://www.micrel.com/_PDF/mic94060.pdf) whose datasheets guarantee OFF currents of less than 1ua. Looks as though it could turn on and off an ESP8266 easily and without wasting much power.
I just now came across the MAX890L switch chip, which Maxim claims will "typically" consume just 0.1ua when switched off: http://datasheets.maximintegrated.com/en/ds/MAX890-MAX890L.pdf
Not an ideal zero, but close enough.
Looks as though these types of chips tend to be used in charge controller circuits, energy harvesting, and long-life battery powered applications.
As it turns out, for a total of $2.99, I ordered 50 of these yesterday: https://www.fairchildsemi.com/datasheets/FD/FDC6329L.pdf
which the datasheet says will lose a maximum of 1ua when in its OFF state. Not as fancy, but at 6 cents each I can't complain. It resembles jra's design in the sense that it incorporates both a p-channel and n-channel mosfet into a single integrated circuit.
I hadn't realized the ESP-13 was out already, but it is, and it appears to be the one with superior RF.
(http://s3.electrodragon.com/wp-content/uploads/2015/04/ESP-13-ESP8266-Wifi-Board-02.jpg)
An ESP-13 has a 4 MegaByte Flash, whereas the ESP-12 has a 1 MegaByte Flash. Most of the other models have 512K of Flash. Hence, the ESP-13 is preferable for "future growth," as some firmwares are becoming quite large. For example, Version 2 Beta of ESP-LINK requires an ESP8266 with an minimum of 1 MegaByte Flash. Also, with 8x the flash of earlier models, I expect the ESP-13 will manifest more sophisticated server software, MQTT, web interface, etc.
In a thread on a different Forum, ESP-Link's author has written " In the long run a 4MB flash will be required." So, I've cancelled my ESP-12E order and have ordered ESP-13's instead. It has the same pins exposed as an ESP-12, plus two extra ground pins. ESP-13's cost about $2.15 each on Aliexpress, so only a small uptick from the ESP-12E price.
Current status:
I have ESP-LINK installed on the Huzzuh now. It now connects automatically with my wifi network as soon as it powers on. I can connect to the Huzzuh through a browser to reconfigure its wifi if I ever want to, but fortunately it does remember its settings if powered off. I can see the serial output from a Moteino in the browser window if I choose. I can also reboot the Moteino if I want to by clicking on a browser button.
The last step needed to achieve OTA programming of the Moteino by the ESP8266 is to redirect the output of AVR-Dude to port 23 of the Huzzuh's IP address instead of to a serial com port. The command to do it is of the following form:
avrdude -p m328p -c arduino -b 115200 -P net:192.168.1.123:23 -U:yourHexFile.hex
That's all well and good in theory, but it leaves me up a creek without a paddle: I normally interact with avrdude only indirectly through the Arduino Windows IDE, not through a command line. So, although the fundamental mechanism is now in place, at the moment I'm not really sure how to make this patch so that it all works transparently from within Arduino Windows IDE. I guess I'll have to dig into that next.
Brainstorming a bit, there are at least six ways to possibly solve the last step of the solution:
0. Somehow (?) have windows redirect serial communications to an IP:port instead. There appears to be paid software that will do this.
1. Do #0, but in Linux, where the OS supports it directly. So, switch to using Linux Arduino IDE.
2. Maybe there's a way to redirect codebender to the desired port 23.
3. Connect an ESP8266 to the serial port, and use that to virtualize the com port communications over wifi with the target ESP8266.
4. Use special hardware dongles to virtualize serial communications. For instance, for some home automation applications, i use some Global Cache dongles to virtualize RS-232 serial into ethernet IP, and they work flawlessly.
5. Hack the Arduino IDE makefile to point at the IP+port# rather than to a serial com port.
Obviously, I'd rather not use dongles, so I'll likely use a software solution of some kind. I'm leaning toward solution #5, but at the moment it's still a WAG as to whether it will work easily or only with great effort.
In any event, one of the above should work.
I'll see this through to the end. However, lately I'm the only one here advancing the topic, and that's no surprise, because judging from the pushback it appears almost everyone else is generally happy and content with the status quo. For that reason, this will likely be my last post on this thread, as I'll be switching to other venues where there is already positive momentum, and more DIT, toward completing the last step.
My thanks to jra for his posts.
Since most of this thread is really more about the ESP8266 than Moteinos, I agree you will probably get more traction on http://www.esp8266.com
Quote from: jra on October 22, 2015, 10:20:57 AM
Since most of this thread is really more about the ESP8266 than Moteinos, I agree you will probably get more traction on http://www.esp8266.com
::) Thank you ...
Although personally I'm not really getting excited about this possibility either, I still think it would be interesting to see it till the end, since it's about programming a Moteino using a new approach.
OTOH, an easy way would be to define a new programmer tool in the IDE config, see examples here: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/programmers.txt
It's a matter or writing a suitable batch/schell script and calling the appropriate tools. Since avrdude seems to support TCP-based probramming, it might be even simpler.