Community
cancel
Showing results for 
Search instead for 
Did you mean: 
thass1
New Contributor I
2,454 Views

Node server and SPI

Jump to solution

Hi.

I need some guidance regarding the system I am working on. I am using this https://www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-rasp... e-health shield with Intel Galileo and I programmed the board with Arduino IDE to get the sensors data successfully. I also have a node TCP server running at the board. I want to catch the sensors readings which Arduino sketch is getting and then send it through TCP sockets to the connected devices. My idea is that I can get the values from Galileo internal SPI or directly from the pins through which the sensors are connected. My problem is I don't know which pins to look for and whether it is possible to listen to SPI meanwhile Arduino sketch is running. Could you please guide me towards the right direction. I have read the Galileo datasheet and E-health shield library but haven't got any idea. Is node's galileo-io is helpful for that purpose?

Best Regards,

1 Solution
Carlos_M_Intel
Employee
183 Views

Hi taha82,

In /sys/bus/iio/devices/iio:device0 you have access to the 6 analog inputs on the board, these files are the access to the ADC

in_voltageX_raw shows the value of the ADC

in_voltageX_scale shows the scale required to translate the raw readings from the ADC to mV

For example if you have a sensor in the pins A0 and A1, you can read them with the commands:

cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw

cat /sys/bus/iio/devices/iio:device0/in_voltage1_raw

 

Let's say that you obtain as result the values, 340 and 2405 respectively

Now, you have to obtain the scale for this pins:

cat /sys/bus/iio/devices/iio:device0/in_voltage0_scale

cat /sys/bus/iio/devices/iio:device0/in_voltage1_scale

You should get as result 1.220703125, applying these values:

For A0:

Scale * RawReading = 1.220703125 * 340 = 415.039mV

For A1:

Scale * RawReading = 1.220703125 * 2405 = 2935.791mV

You can use the MRAA library to read values from the ADC. In order to have the latest MRAA version you have to run the following commands:

echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586 http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf

opkg update

opkg install mraa

You can find more information about MRAA in (Check the analog references):

http://iotdk.intel.com/docs/master/mraa/ http://iotdk.intel.com/docs/master/mraa/

https://github.com/intel-iot-devkit/mraa GitHub - intel-iot-devkit/mraa: Low Level Skeleton Library for IO Communication on GNU/Linux platforms

With MRAA you can use the pins 0,1,2,3,4 and 5; these are the physical pins on the board and you don't need to do anything else to route or map the pins to the code, just initializing the library and functions, check some examples in here: https://github.com/intel-iot-devkit/mraa/tree/master/examples mraa/examples at master · intel-iot-devkit/mraa · GitHub

From http://www.intel.com/content/dam/support/us/en/documents/galileo/sb/galileo_schematic.pdf http://www.intel.com/content/dam/support/us/en/documents/galileo/sb/galileo_schematic.pdf:

On Page 18, The ADC (http://www.analog.com/media/en/technical-documentation/data-sheets/AD7298.pdf AD7298) has an output to the Quark, this output is generated with SPI. Once the Quark receives the information, it is processed according to the different tasks that the board is running regarding those pins.

The access to this bus from Terminal console is /sys/bus/spi/devices/spi0.0

Let me know if this helps.

Regards,

Charlie

View solution in original post

7 Replies
Carlos_M_Intel
Employee
183 Views

Hi taha82

You can access the lectures of the ADC by reading the files in /sys/bus/iio/devices/iio:device0/

In this folder you have access to the raw lectures and the scale needed for converting the values in Volts.

I hope this helps.

Regards,

Charlie

thass1
New Contributor I
183 Views

Thanks for your reply CMata_Intel. I will check that out. Could you elaborate it further? There are four different sensors connected with the board. Will all theses sensors reading comes through that bus? Is mara library is enough to Access that bus? and Is there any link where I can study the bus structure of Galileo? The problem with the novice embedded programmers like me is that, we don't understand the internal working of the board architecture and what kind of bus is used in Galileo to connect with the sensors and how it does it. I have searched the internet but didn't found any useful links. I Know it's a beginners question but if you know any resources or link where I can read about it further, that will be very helpful for me or any other beginner interested in studying it more.

Carlos_M_Intel
Employee
184 Views

Hi taha82,

In /sys/bus/iio/devices/iio:device0 you have access to the 6 analog inputs on the board, these files are the access to the ADC

in_voltageX_raw shows the value of the ADC

in_voltageX_scale shows the scale required to translate the raw readings from the ADC to mV

For example if you have a sensor in the pins A0 and A1, you can read them with the commands:

cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw

cat /sys/bus/iio/devices/iio:device0/in_voltage1_raw

 

Let's say that you obtain as result the values, 340 and 2405 respectively

Now, you have to obtain the scale for this pins:

cat /sys/bus/iio/devices/iio:device0/in_voltage0_scale

cat /sys/bus/iio/devices/iio:device0/in_voltage1_scale

You should get as result 1.220703125, applying these values:

For A0:

Scale * RawReading = 1.220703125 * 340 = 415.039mV

For A1:

Scale * RawReading = 1.220703125 * 2405 = 2935.791mV

You can use the MRAA library to read values from the ADC. In order to have the latest MRAA version you have to run the following commands:

echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586 http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf

opkg update

opkg install mraa

You can find more information about MRAA in (Check the analog references):

http://iotdk.intel.com/docs/master/mraa/ http://iotdk.intel.com/docs/master/mraa/

https://github.com/intel-iot-devkit/mraa GitHub - intel-iot-devkit/mraa: Low Level Skeleton Library for IO Communication on GNU/Linux platforms

With MRAA you can use the pins 0,1,2,3,4 and 5; these are the physical pins on the board and you don't need to do anything else to route or map the pins to the code, just initializing the library and functions, check some examples in here: https://github.com/intel-iot-devkit/mraa/tree/master/examples mraa/examples at master · intel-iot-devkit/mraa · GitHub

From http://www.intel.com/content/dam/support/us/en/documents/galileo/sb/galileo_schematic.pdf http://www.intel.com/content/dam/support/us/en/documents/galileo/sb/galileo_schematic.pdf:

On Page 18, The ADC (http://www.analog.com/media/en/technical-documentation/data-sheets/AD7298.pdf AD7298) has an output to the Quark, this output is generated with SPI. Once the Quark receives the information, it is processed according to the different tasks that the board is running regarding those pins.

The access to this bus from Terminal console is /sys/bus/spi/devices/spi0.0

Let me know if this helps.

Regards,

Charlie

View solution in original post

thass1
New Contributor I
183 Views

Wow CMata_Intel. That cleared many things and it will certainly be helpful for me or anyone trying to do the similar. Thanks for your reply and taking out time to write this.

thass1
New Contributor I
183 Views

I also found this useful article

https://software.intel.com/en-us/blogs/2015/05/05/efficient-data-sharing-using-interrupts-on-intel-e... IoT - Data sharing between programming environments on Intel® Edison | Intel® Developer Zone

Carlos_M_Intel
Employee
183 Views

Hi taha82,

I'm glad to know that my post has been helpful. I checked the document you posted and indeed is very useful. If you want to use another programming language or you have more questions in the future don't hesitate to open a thread with the question, we will be glad to help you.

Regards.

Charlie

Reply