Pharo things analog reads ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Pharo things analog reads ?

Steven Costiou-2

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.

Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

Denis Kudriashov
Hi Steven

2017-12-17 12:40 GMT+01:00 Steven Costiou <[hidden email]>:

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.


Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

Steven Costiou-2

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):

|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 <[hidden email]>:

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.

Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

K K Subbu
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-with-the-raspberry-pi?view=all

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

Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

Steven Costiou-2

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-with-the-raspberry-pi?view=all

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

 

Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

Denis Kudriashov
In reply to this post by Steven Costiou-2
Thank's for links. I will look

2017-12-19 23:20 GMT+01:00 Steven Costiou <[hidden email]>:

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):


 

|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 <[hidden email]>:

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.


Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

Steven Costiou-2
In reply to this post by K K 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-with-the-raspberry-pi?view=all

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

 

Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

Steven Costiou-2
In reply to this post by K K 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-with-the-raspberry-pi?view=all

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

 

Reply | Threaded
Open this post in threaded view
|

Re: Pharo things analog reads ?

Pharo Smalltalk Users mailing list
In reply to this post by Steven Costiou-2
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