I have never used an actual arduino board and have only tried the arduino framework on non-arduino hardware a few times.
I am putting together a little test box for an ADS1115 ADC module (or clone of New clone on the block )
Quite stuff inside the box, noisy stuff outside the diecast box, nothing fancy.
I am using a RPI Pico running the arduino framework using platformio
Here is the code I put together using Adafruits arduino library for the ADS1115
// Sample an ADS1115 ADC via i2c with a RPI Pico // PICO GPIO20 - I2C_SDA // PICO GPIO21 - I2C_SCL // PICO GPIO16 - ADS1115_DRDY // // Inspired by Adafruit demo, use as you like. // scottiebabe/sstobbe@2n3904blog.com #include <Wire.h> #include <Adafruit_ADS1X15.h> // GPIO16 ISR void ADSInterrupt(); Adafruit_ADS1115 ads1115; MbedI2C i2c(20,21); // Use GPIO Pins 20,21 on Pico for i2c void setup(void) { Serial.begin(9600); //while (!Serial); delay(1000); Serial.println("Hello!"); Serial.println("Getting single-ended readings from AIN0..3"); Serial.println("ADC Range: +/- 6.144V (1 bit = 187.5uV)"); ads1115.begin(0x48,&i2c); // Enable Pico's onboard LED pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN,1); // Setup ISR on GPIO16 pinMode(16,INPUT_PULLUP); attachInterrupt(16, ADSInterrupt, FALLING ); gpio_pull_up(16); Serial.println("Hello, pt2!"); Serial.println("Configured ADS1115 for single channel continuous conversion."); Serial.println("ADC Range: +/- 256mV (1 bit = 7.8125 uV)"); Serial.println("Fs: 860 Sa/s"); Serial.println("Ain: Ain0-single ended"); //ads1115.setGain(GAIN_TWOTHIRDS); // SET FSR +-6V ads1115.setGain(GAIN_SIXTEEN); // Set FSR +- 256 mV ads1115.setDataRate(RATE_ADS1115_860SPS); //ads1115.startADCReading(ADS1X15_REG_CONFIG_MUX_DIFF_0_1,true); Serial.println("Starting Acquisition! ..."); ads1115.startADCReading(ADS1X15_REG_CONFIG_MUX_SINGLE_0,true); } #define ADS_BUF_LEN (4096) volatile int16_t samples[ADS_BUF_LEN] = {0}; volatile uint32_t tstamps[ADS_BUF_LEN] = {0}; volatile int adsidx = 0; volatile int adsinterrupt = 0; // GPIO16 ISR void ADSInterrupt() { if( adsidx < ADS_BUF_LEN ){ tstamps[adsidx] = time_us_32(); } adsinterrupt = 1; } /* Adafruit Demo Loop void loop(void) { int16_t adc0, adc1, adc2, adc3; adc0 = ads1115.readADC_SingleEnded(0); adc1 = ads1115.readADC_SingleEnded(1); adc2 = ads1115.readADC_SingleEnded(2); adc3 = ads1115.readADC_SingleEnded(3); Serial.print("AIN0: "); Serial.println(adc0); Serial.print("AIN1: "); Serial.println(adc1); Serial.print("AIN2: "); Serial.println(adc2); Serial.print("AIN3: "); Serial.println(adc3); Serial.println(" "); delay(1000); } */ void loop(void){ if(adsinterrupt){ if( adsidx < ADS_BUF_LEN ){ samples[adsidx] = ads1115.getLastConversionResults(); adsidx++; } adsinterrupt = 0; } if(adsidx >= ADS_BUF_LEN){ //Print out the sample buffer to serial console Serial.println("Acquisition Buffer:"); for(int i=0; i<ADS_BUF_LEN; i++){ Serial.print(tstamps[i]); Serial.print(","); Serial.println(ads1115.computeVolts(samples[i]),7); delay(1); } // dummy read to re-arm interrupt ads1115.getLastConversionResults(); adsidx = 0; adsinterrupt = 0; Serial.println("Starting Acquisition! ..."); } }
/