Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Manager
1,093 Views

Intel Edison with SparkFun Blocks ADC

Hello,

I have to use in my project C language so I refactored this example:

https://github.com/sparkfun/SparkFun_ADC_Block_for_Edison_CPP_Library GitHub - sparkfun/SparkFun_ADC_Block_for_Edison_CPP_Library: C++ library and example for using SparkFun's ADC block for …

Into this code:

# include

# include

# include

# include

# include

# include

# include "mraa.h"

mraa_i2c_context edison_i2c_ADC;

/*ADC On Sparkfun via I2C defines*/

# define CONVERSION 0 // Conversion result register.

# define CONFIG 1 // 16-bit configuration register.

int scaler;

void ads1015_setConfigRegister(uint16_t configValue);

uint16_t ads1015_getConfigRegister();

void ads1015_setRange(int range);

int16_t ads1015_readADC();

int16_t ads1015_getRawResult(uint8_t channel);

float ads1015_getResult(uint8_t channel);

// Channel selection and read start stuff- the high nibble of the 16-bit cfg

// register controls the start of a single conversion, the channel(s) read,

// and whether they're read single ended or differential.

# define CHANNEL_MASK 0x3000 // There are four channels, and single ended reads

// are specified by a two-bit address at bits 13:12

# define SINGLE_ENDED 0x4000 // Set for single-ended

# define START_READ 0x8000 // To start a read, we set the highest bit of the

// highest nibble.

# define CFG_REG_CHL_MASK 0xf000 // Used to clear the high nibble of the cfg reg

// before we start our read request.

# define BUSY_MASK 0x8000 // When the highest bit in the cfg reg is set, the

// conversion is done.

# define CHANNEL_SHIFT 12 // shift the raw channel # by this

# define RANGE_SHIFT 9 <span class="c1" style...

0 Kudos
2 Replies
Highlighted
Community Manager
13 Views

Hi Pawek,

 

 

Thanks for your interest in the Intel® Edison Platform.

 

 

Thank you very much for all the information provided. We've checked that the TMP36 is specified from −40°C to +125°C, and provides a 750 mV output at 25°C. We would suggest you to test your code by steps, for example, first you can check which voltage you are reading, if the values are correct you can use the formula to get temperature and check it. Please look at this Arduino example: https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor, you can get an idea about how to read those values.

 

 

Let us know any update about the case.

 

 

Regards,

 

-Yermi

 

0 Kudos
Highlighted
Community Manager
13 Views

Hi Pawek,

 

 

We would like to know if you have any questions or updates.

 

 

Regards,

 

-Yermi

 

0 Kudos