Try to search your question here, if you can't find : Ask Any Question Now ?

deploy nodejs modbus-rtu using the modbus-serial library to HEROKU

HomeCategory: stackoverflowdeploy nodejs modbus-rtu using the modbus-serial library to HEROKU
john asked 3 weeks ago

Recently, i want to deploy nodejs to heroku using modbus-serial library and, the idea here is i want to retrieve temperature real time from pt100 using serial RS-485,
locally, the code run well having no problem, but went i deploy to heroku, it seems like heroku didnt recognize the usb port “/dev/ttyUSB0”,here what i got,
UnhandledPromiseRejectionWarning: Error: Error: No such file or directory, cannot open /dev/ttyUSB0,
its because heroku doesnt know what it is, or do i have to set the environment variable for the usb port,

here my code,

 const ModbusRTU = require("modbus-serial")
    const client = new ModbusRTU()

    const app = require('http').createServer(server)
    app.listen(process.env.PORT || 5000)

    const io = require("")(app)

        client.connectRTUBuffered("/dev/ttyUSB0", { baudRate: 115200 }).then(() => {
      setInterval(() => {
        client.writeFC3(1,0,2,(err,data) => {
          if(err)console.log("error ",err)
          console.log("datas ",data)
          io.emit("datas_holding_register_rtu",{ datas : data["data"] })

        socket.on('disconnect', () => console.log('Client disconnected'))

any idea what happening here ? thank you


1 Answers
Best Answer
Matthias answered 3 weeks ago
Your Answer

16 + 9 =

Popular Tags

WP Facebook Auto Publish Powered By :