3 Replies Latest reply on Apr 26, 2016 12:39 PM by Intel Corporation

    SparkFun ADC Block - I2C to Analog Grove Sensors

    Iosif

      Hi, i am trying to write a code using Intel Sample for Grove TP401 GAS Sensor and as hardware also the SparkFun ADC Block which works on I2C. I see that SparkFun Block has a 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!

        • 1. Re: SparkFun ADC Block - I2C to Analog Grove Sensors
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          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

          • 2. Re: SparkFun ADC Block - I2C to Analog Grove Sensors
            Iosif

            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!

            • 3. Re: SparkFun ADC Block - I2C to Analog Grove Sensors
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              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