I want my weatherstation to be connected wirelessly to internet to fetch weather data, time info, symbols etc. One of the cheapest option these days is to use a ESP8266. Originally I planned to use it only as a serial wifi device for Arduino. Moving small abouts of (structured) data such as forecast, time etc. from ESP8266 to Arduino is easy. But what about images? It seems to be easy to download images using ESP8266, such as Daniel Eichhorn have done in his ESP8266 Weather Station Color. But how to transfer images from 8622 to the Arduino? Common external flash or SDcard ? Serial ? I really don’t know. So, what if I can use the ESP8266 for everything and just ditch the Arduino? After all, the ESP8266 is a capable processor.
With just minor previous experience with 8266/NodeMCU, I started out boldly by trying to compile James Bowmans Gameduino2 gd2 library I used in Arduino with 7″ 800×480 capacitive touch display and Gameduino2 library for NodeMCU using the Arduino IDE. That turned out to be relatively easy. I (currently) only want the graphics parts of the library so I reduced it by excluding code for SDcard, audio etc. I ended up with code that compiled without major modifications. However, when trying to connect all the hardware pieces together I ran into a lot of stability problems. At first I though there was a problem with the library running on an ESP8266. It runs perfectly on an Arduino (only difference is the chip select pin). Reading more about it I found that a lot of people have stability problems with the ESP8266 in general. Others have their systems stable for weeks. Why is that ? A lot of the answers seem to target the power supply which causes resets. 4 ways to eliminate 8266 resets gives some (potential) answers. Here is what I found and how I (for now) try to solve it:
I found the 8266 to be extremely picky on the power supply. Especially in combination with the VM810C board and 7″ LCD display. This caused a lot of resets, freezes, etc.I had problems running everything from one power supply. But even with two separate supplies I had problems. Especially using USB. I’m pretty sure that the power supplies can deliver enough power. I have to admit that breadboard connections and long wires in the quick prototype are not optimal. I might also have a problem with ground current. None of this was not a problem, however, when using the Arduino Uno instead of NodeMCU.
In order to reduce problems caused by poor power supplies, I (initially) powered the whole thing with battery (USB power banks). Then things became stable! I’ll try to experiment with adding capacitor(s) and clean up USB noise such as described in http://andybrown.me.uk/2015/07/24/usb-filtering/.
A lot of schematics, boards, etc. uses 800mA LM1117 3.3 to convert from USB(5v) to 3.3V. It is specified for Vi down to 4.75. Is that low enough? Could it be that a 1A LM3940 which goes down to 4.5Vi is a better choise? A comparision can be found here. Is it relevant ?
Update(Jan.20): A lot of my problems was caused by USB port. Now, instead of powering the ESP8266 from USB, I’ve connected the NodeMCU Vin/GND pins directly to the 5V/GND of the VM810 dev board. The VM810 dev board is connected to a USB power supply. Total power consumption is apprx. 500mA. This seem to fix a lot of problems. I can still connect the USB from NodeMCU to the computer for download and/or monitoring. I think this should be safe because there is a diode between the USB power and Vin according to the NodeMCU schematics. Why didn’t I do that in the first place…
Update(Feb.3): Still have problems with instabilities. I’ve tried to power the whole thing by MB102 breadboard, using one “channel” for the NodeMCU and one for the VM810. Still not optimal. The oscilloscope shows a lot of noise on the power lines. Next step is to systematically try capacitors such as described here and/or inductors to see if I can get controll of the noise… Best result is still by using batteries… I’m pretty sure it’s not the software… If anyone have suggestions, let me know…
Resets, 8266 Watchdog
As described in https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/using-the-arduino-addon : “The ESP8266 runs a lot of utility functions in the background – keeping WiFi connected, managing the TCP/IP stack, and performing other duties. Blocking these functions from running can cause the ESP8266 to crash and reset itself. To avoid these mysterious resets, avoid long, blocking loops in your sketch.”
Thus I’ve added yield() commands several places that I suspect might take time to process, such as in delay(). Note that several of those might not be required. Many of the crashes I experiences could have been caused by the power supply problems mentioned above. Unfortunately I struggled with multiple problems at the same time.
Pull up / pull downs ???
There are several references to using pullups for RES/CH_PD/GPIOI2/GPIO0 and pulldown on GPIO15, such as in http://www.forward.com.au/pfod/ESP8266/GPIOpins/index.html. Not sure if this is relevant for the NodeMCU. Have to investigate further. I have only connected the SPI pins.
Using a breadboard to connect all the pieces together adds another potential problems. Just minor connection problems can result in reset. My advise is to try to use something else. That said, this doesn’t seem to be the main cause of failures in my setup.
The combination of all the above resulted in a lot of frustration. I finally got everything up’n running. And it seems to be stable. However, I run the damn thing on batteries! Well actually I’m able to run it stable with one USB power supply for VM810C and one separate battery (USB power bank) for NodeMCU. Now I can start removing some yield(), replace battery with other power supplies and see what the main root cause is. I might also add more of the Gameduino2 library if needed.
If you want to test my project yourself, were is what I use (refer also to Arduino with 7″ 800×480 capacitive touch display and Gameduino2 library):
- FTDI VM810C development board (FT810), available i.e. at Farnell.
- NodeMcu. Seems to be several different versionsof NodeMcu and derivatives. I used the “official V2”. I might later take a look at the ESP-12e alone, but with improved power supply filtering.
- 7″ display, ER-TFT070-4 available at BuyDisplay.
Software is available on github. Compile it using Arduino IDE (I use 1.8.1) with support for ESP8266. There are a lot of how-tos on internet on how to do that.
Connect the ISP bus between NodeMCU and the VM810C. Power the NodeMCU and VM810C properly. (Update Jan.20): I ended up connecting +5V/GDN pins from VM810C to Vin/GND on the NodeMCU. The 5V wire is not shown on the picture above.
I’ll update this blog entry when/if I learn more. I’ll also add capacitive touch panel.
In the meantime, good luck!