0

I am looking for a bit of guidance.

I am attempting to convert a Arduino LCD driver to nodejs. LCD:https://www.dfrobot.com/product-1737.html - spec PDF after bottom.

I have researched I2C protocol, byte data, etc. I have also used two different npms (i2c and i2c-bus)

NodeJS

command(ByteValue) {
    i2c1.writeByte(LCD_ADDRESS, 0x80, ByteValue, function(err){
        console.log('[I2C Command] ' + err);
    });        
}

Arduino

inline void DFRobot_LCD::command(uint8_t value){
     uint8_t data[3] = {0x80, value};
     send(data, 2)    
}

void DFRobot_LCD::send(uint8_t *data, uint8_t len)
{
    Wire.beginTransmission(_lcdAddr);        // transmit to device #4
    for(int i=0; i<len; i++) {
        Wire.write(data[i]);
        delay(5);
    }
    Wire.endTransmission();                     // stop transmitting
}

And so I'm a bit confused. I have tried a number of different ways. ByteValue is just a constant byte value(LCD on/Off/etc... its a simple Driver...). I believe the 0x80 is the Comand Code? I'm having a bit of understanding failure.

I have looked at the 1602 LCD nodeJS lib, and it looks more like they build the complete i2c byte with acks and shifts bus and all..( https://github.com/sweetpi/i2c-lcd/blob/master/lib/lcd.js ) I was hoping the nodejs lib did this mostly for me..

Could anyone give a bit of direction and education?

  • I'm having a bit of understanding failure - what failure? you haven't made any mention of what your current code does (or fails to do) – Jaromanda X Mar 3 at 23:55
  • I agree with @JaromandaX , it is unclear what you are asking. – GramThanos Mar 4 at 1:30
  • So... the Arduino code is from the developer is working. The NodeJS should do the exact same thing however it does not. What is my error? As stated, I have tried a number of different ways for nodeJS to send to i2c to control this LCD. I am clearly doing something wrong with sending my bit data to the I2C bus. A few times with playing with how the byte data is sent to I2C (writeWord(), writeByte(), sendByte() from nodeJ i2c lib)... I can get the LCD to respond [i think] - can see a refresh or something. Another complication is that there is multiple i2c devices for this LCD - 4. – Eric Samuel Mar 4 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.