Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
1,657 Views

SparkFun ADC Block - I2C to Analog Grove Sensors

Hi, i am trying to write a code using https://software.intel.com/en-us/iot/hardware/sensors/grove-air-quality-sensor Intel Sample for Grove TP401 GAS Sensor and as hardware also the https://learn.sparkfun.com/tutorials/sparkfun-blocks-for-intel-edison---adc-v20 SparkFun ADC Block which works on I2C. I see that SparkFun Block has a https://github.com/sparkfun/SparkFun_ADC_Block_for_Edison_CPP_Library Lib.

Questions:

  1. Do i have to use that Lib in order to use the block/shield?
  2. If yes, can you show me how to change (or tell me what should i do) the sample code to read from the Analog Input (let's say AIN0) from ADC Block?

Any help would be appreciated - sorry for stupid questions, i am a beginner.

 

Thank You!
0 Kudos
3 Replies
Highlighted
Community Manager
2 Views

Hi losif,

 

 

You don't have to use the library to use the ADC block, however, using it will make you the things easier. I recommend you to use the resources that SparkFun offers for the ADC block.

 

 

In the link you posted, there is an example for the ADC block. The example shows how to read data from channels 0 and 1. I recommend you to check it.

 

 

Regards,

 

Diego
0 Kudos
Highlighted
New Contributor I
2 Views

Yes but my Sensor is on AIO not I2C Protocol so the sensor lib has to be write again, in order to use it with the block lib. And also, what should be the equivalent PIN for AIN0 and AIN1 (channels) - if i don't use the lib?

Also if I want to use SparFun Lib, i will have to write the Gas sensor lib again to use I2C Protocol instead of AIO?

Thanks!

0 Kudos
Highlighted
Community Manager
2 Views

Hi Iosif,

 

 

The sensor code has been written based on the Arduino Expansion Board for Edison. Since you are not using it, you don't need that library. You are using the ADC block from SparkFun so I recommend you to use the library they provide.

 

 

Basically, both, the sensor library and the SparkFun library, do the same: read from the analog input. That's the only thing you need.

 

 

The I2C protocol is used to interface the ADC block with the Edison module, however, you don't have to do anything with I2C. The initialization of the I2C protocol is managed by the SparkFun library, you only need to use the methods of getting the analog values, for example adc.getRawResult(0) that reads the raw value from channel 0.

 

 

So this is my suggestion:
  1. Use the ADC block library only, and modify the example code.
  2. Understand what the example code does.
  3. Understand what the sensor code does.
  4. Implement what the sensor code does into the example code of the ADC block.
I hope I have clarified your doubts.

 

 

Regards,

 

Diego
0 Kudos