I would be happy if you give me a advice or show me the sample code.

One year before, I wrote a luminosity sensor application on my RPi model B in Ruby. Thanks to the this library I could make app without deep understanding.


I've got a RPi2 last week and I've tried to update my luminosity application. Unfortunately, pi_piper doesn't support RPi2. I'm thinking about using the WiringPi-Ruby instead of pi_piper but I don't have any idea where to start.

Here is the code and circuit that I made before.

require 'pi_piper'
loop do
  value = 0
  PiPiper::Spi.begin do |spi|
   raw = spi.write [0b01101000,0]
   value = ((raw[0]<<8) + raw[1]) & 0x03FF
  puts value

I used the mcp3002 as a ADC.

enter image description here

1 Answer 1


If it must be in ruby, have you tried? https://github.com/joshnuss/bcm2835

However if you can give C a chance the WiringPi library has it built in see:

I'm using the MCP3008 and it works pretty much the same and if you do some digging around you can find the commandline debugger tools which come in handy :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.