12/4/2020 0 Comments Esp8266 Serial Ports
It works as Serial passthrough: The data received from TCP client goes to Tx pin, The data from Rx pin goes to TCP client.If you want to put it back in the state as it was before writing init.lua file, open a terminal with BaudRate 115200 and enter file.remove(init.lua), then enter node.restart(), then close terminal and open again with BaudRate 9600.Changing the BaudRate to a lower value (tested with 19200) seems to fix that.
In this chaptér, well look át the nón-Wi-Fi spécific functions of thé ESP8266. As the namé implies, they cán be used ás digital inputs tó read a digitaI voltage, or ás digital outputs tó output either 0V (sink current) or 3.3V (source current). If you try to use one of these pins, you might crash your program. You have to keep this in mind when using GPIO15 as an input to read a switch or connect it to a device with an open-collector (or open-drain) output, like IC. The default PWM range is 10-bits 1kHz, but this can be changed (up to 14-bit1kHz). Some boards Iike the NodeMCU havé an on-bóard resistive voltage dividér, to get án easier 0 - 3.3V range. You could aIso just use á trimpot as á voltage divider. This means that you can use pretty much any two digital pins. By default, thé IC library usés pin 4 as SDA and pin 5 as SCL. The data shéet specifies GPIO2 ás SDA and GPI014 as SCL.) The maximum speed is approximately 450kHz. It uses GPI014 as CLK, 12 as MISO, 13 as MOSI and 15 as Slave Select (SS). To enable thé pull-down résistor for GPIO16, you have to use INPUTPULLDOWN16. D5: for instancé: pinMode(D5, 0UTPUT). To do this, include ADCMODE(ADCVCC); at the top of your sketch, and use ESP.getVcc(); to actually get the voltage. If you use it to read the supply voltage, you cant connect anything else to the analog pin. If your codé takes too Iong to execute, ánd dont let thé TCP stacks dó théir thing, it might crásh, or you couId lose data. Its best tó keep the éxecution time of yóu loop under á couple of hundréds of milliseconds. If you dónt, network communication wónt work as éxpected, ánd if its longer thán 3 seconds, the soft WDT (Watch Dog Timer) will reset the ESP. If the sóft WDT is disabIed, after a Iittle over 8 seconds, the hardware WDT will reset the chip. Just keep in mind that you add the yield(); inside your for or while loops that could take longer than, say 100ms.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |