Start a new topic

RAPI and Node-Serialport (nodejs)

Hello,

 

I would like to control the 40A Deluxe Level1&2 using a rpi and Node.js, instead of the firmware provided with the wi-fi board.

 

To do so, instead of the wifi board, I connected a rpi3 ([using GPIO](https://drive.google.com/file/d/1URprVQ8iivestALZOXYfia3cvjC15voh/view?usp=sharing), not USB) which I would like to use to send RAPI commands using the node.js library [Node-Serialport](https://www.npmjs.com/package/serialport#serialport-).

 

I managed to successfully control the OpenEVSE from the rpi using the command line tools provided by the library (`serialport-term`)

 

![Capture|523x90](upload://z97KEiHAIl6W78VFzYlavjJLmdR.PNG)

 

However I can't achieve the same using a simple script like this:

 

    var SerialPort = require('serialport');

    var port = new SerialPort('/dev/ttyS0', {

      baudRate: 115200

    }, function(err) {

      if (err) {

        return console.log('Error: ', err.message);

      }

      console.log("Port is open: ", port.isOpen)

    });

 

    port.on("open", function () {

      console.log("open");

      port.on("data", function(data) {

        console.log("data received: " + data);

      });

      port.write("$SC 8", function(err, res) {

        if (err) {

          return console.log('Error on write: ', err.message);

        }

        console.log('message written');

      });

    });

 

The output is the following:

![Capture1|327x69](upload://hwxVLu2eqIlCi7j228M8vHZ8VDu.PNG)

 

but the charger doesn't react. Do you know what I'm doing wrong? Any help would be very much appreciated.

 

Thanks in advance,

 

Simo


Hi Simo,


Are the GPIO pins on the RPI3 5v tolerent? 



I also include the debugging output when I run the script:


serialport:binding:auto-detect loading LinuxBinding +0ms serialport:main opening path: /dev/ttyS0 +0ms serialport:bindings open +0ms serialport:poller Creating poller +0ms serialport:main opened path: /dev/ttyS0 +9ms open serialport:main _write 6 bytes of data +6ms serialport:bindings write 6 bytes +14ms Port is open: true serialport:unixWrite Starting write 6 bytes offset 0 bytesToWrite 6 +0ms serialport:main _read reading +7ms serialport:bindings read +7ms serialport:unixRead Starting read +0ms serialport:unixWrite write returned null 6 +8ms serialport:unixWrite wrote 6 bytes +1ms serialport:unixWrite Finished writing 6 bytes +0ms serialport:main binding.write write finished +6ms message written serialport:unixRead waiting for readable because of code: EAGAIN +5ms serialport:poller Polling for "readable" +22ms

Hello Chris,


From a quick google search, it looks like they are not https://raspberrypi.stackexchange.com/questions/38973/are-the-spi-pins-5v-tolerant

Login or Signup to post a comment