LCD RGB Display Illegal instruction


I’m trying to use the C sdk wrapped with Swift and I keep getting Illegal instruction when ever I try to set the text on the screen.


Hi @jus0610tin,

Can you share more details about the code that you are using and the output that you are getting. Also can you try this example to make sure the LCD Display works.

Are you using the Raspbian for Robots Image or any other image on your Pi?



I’m using the LCD RGB one but the python works fine.

I’m using this code with this wrapper

var screen = GrovePiLCDRGB(color: RGBColor(red: 100, green: 100, blue: 100)) screen.clearDisplay() screen.setText(string: "Hello")


Hi @Shoban,

The error is happening when I call i2c_smbus_write_byte_data(addr,cmd,value);
with 0x62, 0x08, 0xaa


Hi @jus0610tin,

It looks like the code is, probably failing to send the I2C data to the LCD. We haven’t tried it with swift so it is new to us too. Can you tell us where i2c_smbus_write_byte_data(addr,cmd,value) function is defined here and you can look into the implementation of the function to find the problem.



Hi @Shoban Here’s the project

That function is defined here

also as a side note I used this guide to install swift


Hi @jus0610tin,

Thanks for sharing the code. Not very sure of the problem. We’ll give a shot to the code that you have sent, in swift and see if it works for us.



Hi @Shoban

I found the Illegal instruction is an int overflow. There was also another problem with the write_byte_data(char addr, char cmd, char vlaue) method where it needed to call ioctl(fd, I2C_SLAVE, newAddress); The swift code it working now if you guys want to play with it.


Hi @jus0610tin,

Glad to hear, you have it working. Can you tell us if the swift code which you have working, is from this repository. Also if you have any links to get started with swift on Pi, can you share it with us.



Hi @Shoban,

Here’a a quick guide on installation and testing on Raspbian

Yes, I updated the code in that repository. To build and run, run make all and then ./build/grovepitests

Here is a medium article on using swift on the pi


Hi @jus0610tin

Thanks a lot for sharing, we will look into it.