This is a Software Serial implementation that only stops the processor when it sees the edges of serial data.
On a slightly different topic, if you need to connect a very large number of serial ports to an ESP8266 device and you don’t want to use Software Serial to read them all (which usually doesn’t work if you have more than a couple of inputs) you might like to take a look at my “edge triggered serial port” code here. Rob’s Amazing Interrupt Driven Serial Port So I much prefer a physical port which sends each byte of data without the involvement of the processor. I don’t want the lights on my Connected Little Box device to flicker when it prints something. That might be OK for you, but not for Rob. If you use SoftwareSerial you will find that your program is effectively stopped while it sends and reads data. I thought when I first saw these that they might do cunning things with timers and interrupts that meant that they had no impact on performance, but this is not the case. The only problem with a software serial port is that it usually requires the sole attention of the processor when it s being used. This is called “bit bashing” because the code “bashes” the data out. A software serial port is a piece of code that twiddles a data output as if it was being driven by serial port hardware. What about SoftwareSerial?Īt this point you might be asking “Why doesn’t Rob just create a software serial port and have done with it?”. Your program can try to read from this port, but it won’t see any data. Serial1.begin(19200) // open the port at 19200 baud You can open and use it in the same way as the other port: For numbering reasons (computer people like to start counting at zero) the second printer port is numbered Serial1. The TX signal for this port is connected to D2 on the ESP8266 and which is wired to pin D4 On the WEMOS D1 Mini, as shown in the diagram above. That’s fine for me at the moment as I only want to send data to a printer. The other “half serial port” on the ESP8266 is a port that can only transmit data. We can use this port to connect to other things but this makes it hard to interact with our device.
This is port usually connected to via USB to the host computer and used to send programs into the device and to have conversations with our running programs. One has both TX and RX connections, so that it can both send out data and listen for incoming data.
Thanks for the help, it actually put me on the way to the solution. Then, its possible to unplug the ESP8266 and plug it into another project, it keeps the baud rate. The ESP8266 processor chip has one and a half serial ports. To do this, put the ESP8266 directly on the serial lines of the Arduino and send the command (AT+CIOBAUD19200) from the serial monitor.