Hi @peekay123 … i’m having some problems when using the sparkintervaltimer with theAdafruit ADS1X15 library. the code i’m trying to use is the following, so each 1.25ms the function ReadADC() is called in order to take a converted sample from the external ADC. However, after flasing the code to my photon device, the status led flashes red … but when i call the function ReadMic() everything is OK. In addition, i used the software timer from photon firmware with ReadADC() function, and everything is OK. could you please tell me where the problem can be?. i would like to use sparkintervaltimer lib, because on the final sketch, the sampling period will be 125uSec … is there any alternative lib to sparkintervaltimer i could test?.
thanks a lot!
// This #include statement was automatically added by the Particle IDE.
#include <SparkIntervalTimer.h>
#include "Adafruit_ADS1X15.h"
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
//Adafruit_ADS1015 ads; /* Use thi for the 12-bit version */
// CONNECT PHOTON TO ADS1115 BOARD AS FOLLOWS:
//
// PHOTON PIN -> ADS11x5 PIN
// ---------- -----------
// 3.3V -> VDD
// GND -> GND
// D0 -> SDA (I2C DATA)
// D1 -> SCL (I2C CLOCK)
// D2 -> ALERT
#define AUDIO_TIMING_VAL 1250
#define BVSM_AUDIO_INPUT A1
IntervalTimer readMicTimer;
void setup(void)
{
Serial.begin(9600);
ads.begin();
ads.setGain(GAIN_ONE); // 1x gain ± 4.096V 1 bit = 2mV 0.125mV
readMicTimer.begin(readADC, AUDIO_TIMING_VAL, uSec); //<---------------------------------------
}
void loop(void)
{
}
void readMic(void) {
uint16_t value12 = analogRead(BVSM_AUDIO_INPUT);
Serial.println(value12);
}
void readADC(void) {
short adc0 = ads.readADC_SingleEnded(0);
Serial.println(adc0);
}