ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By l3xluthor
#12288 Hi All,

I have done some modifications to the httpd project and is running pretty good, Im using the 9.3 SDK version, lets say at code level the ESP-01 is doing what is commanded to do, but Im getting the next behavior when theres a power outage, first of all let me tell you how the connections are:

GND -> GND
GPIO2 -> to a resistor\LED or to a transistor 2N2222A or to a relay
GPIO0 -> not connected
URXD -> to USB to serial TX pin or not connected
UTXD -> to USB to serial RX pin or not connected
CH_PD, RST and VCC -> 3.3 vdc

OK, when GPIO2 is attached to a resistor\LED and the power outage is simulated theres no problem, the ESP01 restart without issues and I can see that during the restart the LED is turned on\off very quick.

Then when I try the same but GPIO2 connected to the transistor or directly to a relay(SLA-05VDC-SL-C) the ESP01 enter in a weird status where both leds in the ESP01 the red and blue are turned on and if Im debbuging with putty I can see a very quick output of the next characters (sometimes more sometimes less)"lblrlp¦n¦" as if they were in a infinite loop and they just stop when I disconnect the ESP01 from the power.

So, I dont know what could be causing it, with my poor electronics knowledge I dont know if Im missing any electronic circuit or device between GPIO2 and the transistor\relay or theres something I have to reconfigure on httpd ioInit(), any advise will be much appreciated.
User avatar
By MK1888
#12291 Don't connect any microcontroller pin directly to a relay coil! Coils are inductive! They have disastrous back-EMF when shutoff. You need both a transistor and a diode for protection.

You should have no problems driving the base of the transistor with GPIO2. But you should use a base resistor to limit current.

GPIO2 switches the transistor. The transistor switches the relay. And a diode is placed across the relay coil terminals in the opposite direction of regular current flow. If you switched the transistor without a base resistor it may be destroyed, unless you only switched it with the ESP pin.

Read this: http://electronicsclub.info/transistorcircuits.htm
User avatar
By prozac
#12301
banitama wrote:Hi,
I want to create a project based on esphttpd.
I need to store a configuration parameter that persist when the ESP8266 is power cycled.
Since esphttpd only provide RO filesystem, I was thinking of embedding another filesystem (spiffs, for example) to store configuration data.
What do you folks think? Have anyone meet similar need to me (storing persistent configuration)?

Depends on how much data you need to store, but the ESP has a small amount of userdata storage already available.
Just define your configuration struct and write/read it from flash using the spi_read/write/erase api functions.