Thank's for links. I will look 2017-12-19 23:20 GMT+01:00 Steven Costiou <steven.costiou@kloum.io>:
hi,
i've tried i2c and added ffi calls in WiringPiLibrary.
*wiringPiI2cSetup: devId*
^self ffiCall: #(int wiringPiI2CSetup (int devId) )
*readI2C: fd*
^self ffiCall: #(int wiringPiI2CRead (int fd))
Then the following script is able to read a byte from a connected device (i tried with a trinket https://learn.adafruit.com/introducing-trinket/ introduction): <https://learn.adafruit.com/introducing-trinket/introduction)>
|lib addr val|
lib := WiringPiLibrary uniqueInstance.
addr := self wiringPiSetupI2C: 4. *âSetup the i2c to the 0x04 addressâ* val := self readI2C: addr. *âRead a byte from the i2c addressâ*
val inspect
So connecting an Arduino-like device to the raspberry that is configured as an i2c slave, Pharo can ask for analog values. I will try tomorrow with analog sensors, I will share if i manage to build nice examples.
Seems to be even easier using a special chip: https://learn.adafruit.com/ reading-a-analog-in-and-controlling-audio-volume-with- the-raspberry-pi?view=all
but it uses more pins on the board.
Steven.
Le 2017-12-17 19:48, Denis Kudriashov a écrit :
Hi Steven
2017-12-17 12:40 GMT+01:00 Steven Costiou <steven.costiou@kloum.io>:
Hi,
For what i know, raspberry pi boards cannot read analog sensors (which are the most interesting imo), except by connecting to some kind of bridges or to Arduino boards.
In the PharoTHings code i see that there are Arduino classes, and also it is based on wiringpi and wiringpi provides support for i2c which is needed to connect to an Arduino and perform analog reads.
I'm exploring the wiringpi doc to see if there is an example for that, but in the meantime, would someone already have an example of analog reads with PharoThings, with working code (even simple) ?
It is in my todo. I need to build example with temperature sensor. I will continue work on it next year. Now feel free to contribute to the project.
About Arduino: it is not finished. Problem that I use Mac but serial port is not working there (it is required for Firmata)
Steven.