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) ? Steven.
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.
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): [1] |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-... 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.
Links: ------ [1] https://learn.adafruit.com/introducing-trinket/introduction)
On Wednesday 20 December 2017 03:50 AM, Steven Costiou wrote:
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-...
An Arduino would be an overkill. Also, there is no need for bitbanging. MCP3008 is are directly supported by the IIO subsystem and its channel data is demuxed in /sys/bus/iio/devices/iio:device<n> http://www.jumpnowtek.com/rpi/Using-mcp3008-ADCs-with-Raspberry-Pis.html HTH .. Subbu
Yeah i know this exists, but i have none of these and i have plenty of trinkets, and i need to do analog reads. I2c is interesting anyway, some devices need it i believe. Le 2017-12-20 05:20, K K Subbu a écrit :
On Wednesday 20 December 2017 03:50 AM, Steven Costiou wrote:
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-...
An Arduino would be an overkill. Also, there is no need for bitbanging. MCP3008 is are directly supported by the IIO subsystem and its channel data is demuxed in /sys/bus/iio/devices/iio:device<n>
http://www.jumpnowtek.com/rpi/Using-mcp3008-ADCs-with-Raspberry-Pis.html
HTH .. Subbu
Thanks for the link, also ;) Le 2017-12-20 05:20, K K Subbu a écrit :
On Wednesday 20 December 2017 03:50 AM, Steven Costiou wrote:
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-...
An Arduino would be an overkill. Also, there is no need for bitbanging. MCP3008 is are directly supported by the IIO subsystem and its channel data is demuxed in /sys/bus/iio/devices/iio:device<n>
http://www.jumpnowtek.com/rpi/Using-mcp3008-ADCs-with-Raspberry-Pis.html
HTH .. Subbu
I finally bought 2 of those chips, and it works very well. A simple file read from Pharo and i get my analog values (although i don't understand them, but that has nothing to do with the reading). It is very, very fast. Thanks again :) Steven. Le 2017-12-20 05:20, K K Subbu a écrit :
On Wednesday 20 December 2017 03:50 AM, Steven Costiou wrote:
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-...
An Arduino would be an overkill. Also, there is no need for bitbanging. MCP3008 is are directly supported by the IIO subsystem and its channel data is demuxed in /sys/bus/iio/devices/iio:device<n>
http://www.jumpnowtek.com/rpi/Using-mcp3008-ADCs-with-Raspberry-Pis.html
HTH .. Subbu
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.
Hi Steven. I added I2C support <https://github.com/pharo-iot/PharoThings/releases/tag/v0.2.1> to PharoThings and WiringPi. Now you can ask the board instance for I2C connection: i2cConnection := board connectToI2CDevice: 4. And then read/write data using wiringpi functions like: i2cConnection readData. i2cConnection read8BitsAt: 16r32 "register". i2cConnection writeData: 16rAB. i2cConnection write8BitsAt: 16r32 "register" data: 16rA5. Also I added I2CDevice as superclass for simple i2c devices. There is example of accelerometer ADXL345. Look for details. Best regards, Denis 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.
Hi...Have you tried putting a 0.1uF capacitor from the input to GND?How quickly are you reading? Are you averaging or decimating? Also, have you added capacitors for the Aref pin?You may be picking up spurious signals. -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
participants (4)
-
Denis Kudriashov -
K K Subbu -
PeterJohn -
Steven Costiou