Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266 Initial Connection Issue: Reset Required for Message Sending #2768

Open
gmm932 opened this issue Apr 1, 2024 · 1 comment
Open

Comments

@gmm932
Copy link

gmm932 commented Apr 1, 2024

When I first connect the ESP8266 to the computer, I run my demo and cannot write messages, but if I press the ESP8266 RST reset button once and run the demo again, I can send messages. I don't know why, and Arduino tools don't have this problem.

this is my demo.

const { SerialPort } = require('serialport')

const portName = 'COM3'; 
const baudRate = 115200; 
const port = new SerialPort({ path: portName, baudRate: baudRate })

setInterval(function () {
    port.write('D1_300_500_1\n', function(err) {
        if (err) {
            return console.log('Error on write: ', err.message)
        }
        console.log('message written')

        // port.close(function (err) {
        //     console.log(err)
        // })
    })
},1000)


let receivedData = '';
port.on('data', (data) => {
    receivedData += data.toString();
    if (receivedData.includes('\n')) {
        const cleanedData = receivedData.replace(/[\r\n]/g, "");
        receivedData = '';
        console.log(cleanedData)
    }
});
// Open errors will be emitted as an error event
port.on('error', function(err) {
    console.log('Error: ', err.message)
})

I tried to use @serialport/parser-ready but it didn't work.

Originally posted by @gmm932 in #2767

@gmm932 gmm932 changed the title When I first connect the ESP8266 to the computer, I run my demo and cannot write messages, but if I press the ESP8266 RST reset button once and run the demo again, I can send messages. I don't know why, and Arduino tools don't have this problem. ESP8266 Initial Connection Issue: Reset Required for Message Sending Apr 1, 2024
@MillerRen
Copy link

Please enable DTR flow control if you develop esp8266 with Arduino framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants