View Full Version : rpi i2c

September 29th, 2015, 11:35 PM
quick question does g6 support the rpi builtin i2c controller I am in the process of redesigning my HAM and Server monitoring system using i2c sensors and was hoping to run it through girder instead of python.

specifically the sda and scl pins as i want to be able to access the i2c adc and port expabder using girder if i can provide other info i can provide let me know


September 30th, 2015, 07:25 AM
Unfortunately currently it uses the filesystem access method. Would the wiringPi library give you what you need? If so I'll create a wrapper for that.

September 30th, 2015, 10:14 AM
If I read the stuff on wiringpi it may work I have not used the wiringpi package before.

September 30th, 2015, 02:43 PM
I've released an add-on to Girder RPI to use the wiringPi library. Please reference the library by clicking on headings below. Implemented so far:

Setup (http://wiringpi.com/reference/setup/)

int setup (void) ;
int setupGpio (void) ;
int setupPhys (void) ;
int setupSys (void) ;

Core (http://wiringpi.com/reference/core-functions/)

void pinMode (int pin, int mode) ;
void pullUpDnControl (int pin, int pud) ;
void digitalWrite (int pin, int value) ;
void pwmWrite (int pin, int value) ;
int digitalRead (int pin) ;

Raspberry Pi Specifics (http://wiringpi.com/reference/raspberry-pi-specifics/)

void digitalWriteByte (int value) ;
void pwmSetMode (int mode) ;
void pwmSetRange (unsigned int range) ;
void pwmSetClock (int divisor) ;
int piBoardRev (void) ;
int wpiPinToGpio (int wPiPin) ;
int physPinToGpio (int physPin) ;

SPI Library

int SPISetup (int channel, int speed) ;
int SPIDataRW (int channel, unsigned char *data, int len) ;

I2C Library (http://wiringpi.com/reference/i2c-library/)

int I2CSetup (int devId) ;
int I2CRead (int fd) ;
int I2CWrite (int fd, int data) ;
int I2CWriteReg8 (int fd, int reg, int data) ;
int I2CWriteReg16 (int fd, int reg, int data) ;
int I2CReadReg8 (int fd, int reg) ;
int I2CReadReg16 (int fd, int reg) ;

This code lives in the girder-libluawiringpi deb.

sudo apt-get update
sudo apt-get install girder-libluawiringpi wiringpi

Example Code

if not luaWiringPi then

local w = luaWiringPi


w.pinMode(1, w.OUTPUT)
w.digitalWrite(1, w.HIGH)

print("i2C setup", w.I2CSetup(1))

October 3rd, 2015, 02:43 PM
Thanks I will test it out asson as the parts arrive. out of curiosity how will girder handle events from the wrapper such as GPIO events ?


October 3rd, 2015, 03:01 PM
Currently these are not yet implemented. I will add them in the next release. Unfortunately the library while it allows to register a callback doesn't allow for a user_data parameter. (this makes things harder on the user of the library).