loading
3Instructables7,012Views5CommentsJoined December 29th, 2015

Tell us about yourself!

Complete Your Profile

Achievements

  • Mendelbrot followed 1o_o71 month ago
      • Lawn Sprinkler Spray Control
      • Custom Shaped Planter Box Out of Old Tounge-in-grove Boards
      • AVR Assembler Tutorial 11
  • 16-bit I2C Temperature Monitor Using Arduino

    Alright, so if I interpreted your problem correctly, you want to collect ADC values from a ADS1115 at regular intervals triggered by an event (program call, button press etc.). So to do this, I set up on a breadboard an ATMEGA328P (but I'll assume you are using an Arduino UNO) and an ADS1115 as seen in the picture below (I can provide a schematic if you'd like). The Arduino communicates with the ADS1115 via the I2C interface so we must make the connections between the SCK and SDA pin on both chips; these are labeled on both PCBs. Then, we provide power ground to the ADS1115 from the Arduino along with pulling the address pin (addr) on the ADS1115 to ground to give it the default address 0x48. Then, I put the wiper of a potentiometer to pin A0 on the ADS1115 and a momentary push button o...see more »Alright, so if I interpreted your problem correctly, you want to collect ADC values from a ADS1115 at regular intervals triggered by an event (program call, button press etc.). So to do this, I set up on a breadboard an ATMEGA328P (but I'll assume you are using an Arduino UNO) and an ADS1115 as seen in the picture below (I can provide a schematic if you'd like). The Arduino communicates with the ADS1115 via the I2C interface so we must make the connections between the SCK and SDA pin on both chips; these are labeled on both PCBs. Then, we provide power ground to the ADS1115 from the Arduino along with pulling the address pin (addr) on the ADS1115 to ground to give it the default address 0x48. Then, I put the wiper of a potentiometer to pin A0 on the ADS1115 and a momentary push button on DigitalPin 9 on the Arduino. Then go ahead and upload the sketch below to your Arduino and open the Serial Monitor. If all goes well, when you press the button, the Ardiuno will print out the current ADC value on ADS1115 pin A0 five times, once every second, then stop and wait for you to press the button again. Hopefully this helps point you in the direction you want to go, and let me know if you have any questions about the code/functionality/extensions of this setup! Here is the sketch:#include <Wire.h>#include <math.h>#include <Adafruit_ADS1015.h>Adafruit_ADS1115 ads(0x48); int buttonPin = 9; // Declare which pin the start button is attached to int buttonState = 0; // Initial state of buttonint condition; // Current state of button int timer = 0; // Initial value for the timerint interval = 1000; // How often you want the ADC sample (in millis)int stopCount = 5; // How many counts you want (stopCount = interval in seconds * # of counts)void setup(void) { // ADS1015 ADS1115 // ------- ------- ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default) // ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV // ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV // ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV // ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV // ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV ADS1015_REG_CONFIG_DR_2400SPS; ads.begin(); // Establish connection with ADS1115 Serial.begin(9600); pinMode(buttonPin, INPUT); }void loop() { condition = start(); // Runs function to check if start button was pressed if (condition == HIGH) { // Checks to see if start button was pressed. If so: for (timer = 0; timer < stopCount; timer++) { // Start timer // ****Ch. 0**** float ADC0 = getADC(0, 0); // Use getADC function to... get the ADC value Serial.println("Ch. 0: "); Serial.println(ADC0); Serial.println(); delay(interval); } } delay(50);}// ******Get ADC from ADS1115******float getADC(int board, int channel) { uint16_t val; val = ads.readADC_SingleEnded(channel); // **This is the raw ADC value you are looking for return val;}// ******Start ADC Collection******int start() { buttonState = digitalRead(buttonPin); int oldButtonState = 0; int state; if (buttonState != oldButtonState) { oldButtonState = buttonState; if (buttonState == HIGH) { state = !state; } } if(!state){ condition = 0; }else { condition = 1; } return condition;}

    View Instructable »
  • 16-bit I2C Temperature Monitor Using Arduino

    Also, you may be able to place the function: ADS1015_REG_CONFIG_DR_128SPS;(switch out 128 for your desired SPS) in the setup() portion of your sketch.

    View Instructable »
  • 16-bit I2C Temperature Monitor Using Arduino

    Much appreciated! I think this may be a down and dirty way to adjust the sampling rate, though I haven't tested it. If you navigate to your Libraries -> Adafruit_ADS1X15 and check out the .h and .cpp files, you can see in the .h file all of the options for sampling rate and then in the .cpp file, you can adjust the values accordingly. In the attached photos I highlighted the areas of interest. An important thing to note and something I eventually want to get to the bottom of is that those sampling rates listed are not the same as the sampling rates stated in the ADS1115 data sheet, however this library works quite well. In any event, let me know if this helps!

    View Instructable »
    • ZIF Attiny "Arduino As ISP" Programmer With External Clock
      1,189 views
      34 favorites
      0 comments
  • Arduino Car Ignition System... the Carduino!

    Much appreciated my friend! Yes, building my own "Arduino's" or atleast a stand alone ATMega328 that is tailored to a project has been on my to-do list for quite some time; so has etching my own PCB's. Sure, I will have a schematic and a video demonstrating it in use up in about a week! The keypad/Arduino actually starts the car, that is, first you turn the key to the "run" position and then you type in the code and the Arduino activates a relay which connects the wires that activate the solenoid on the starter motor thus, starting the engine.

    Much appreciated my friend! Yes, building my own "Arduino's" or atleast a stand alone ATMega328 that is tailored to a project has been on my to-do list for quite some time; so has etching my own PCB's. Sure, I will have a schematic and a video demonstrating it in use up in about a week! The keypad/Arduino actually starts the car, that is, first you turn the key to the "run" position and then you type in the code and the Arduino activates a relay which connects the wires that activate the solenoid on the starter motor thus, starting the engine.

    View Instructable »
  • Mendelbrot commented on JureINV's instructable Arduino Thermometer + LCD I2C2 months ago
    Arduino Thermometer + LCD I2C

    More than likely it is a 10kOhm NTC type thermistor. NTC stands for "Negative Temperature Coefficient" meaning as the temperature of the thermistor increases, the resistance of the decreases. Also, 10kOhm is the resistance of the thermistor at 25 deg. Celcius. This type of thermistor is the most common.

    View Instructable »