Home › Forums › Mayfly Data Logger › DFRobot SEN0244 on Grove Analog AUX
- This topic has 3 replies, 2 voices, and was last updated 2020-10-08 at 12:10 PM by Shannon Hicks.
-
AuthorPosts
-
-
2020-10-05 at 9:10 PM #14630
Hi everyone,
I have been given a pretty elaborate Mayfly station from the University, and I’m trying to attach a couple of sensors that aren’t in the modular sensors library. One of those sensors is a simple DFRobot TDS SEN0244 https://www.dfrobot.com/product-1662.html. This comes with some code, that I have tested using an Arduino UNO, and the analog pins on the Mayfly. However, the way the technician set up the wiring is so that the grove pin is shared with another sensor, and slots into the second AUX Analog connection marked with ‘AA2’ ‘AA3’ ‘V’ ‘Gnd’.
Can someone tell me if you can share these connections, i.e. have AA2 coming from one sensor, and AA3 coming from another sensor, and share the VCC and Gnd? I understand that our technician wanted to be as efficient as possible with the wiring, but It has never occurred to me to share one of these connectors.
Assuming that is okay, I have the SEN0244 connected to pin AA3. However, I can’t seem to read the analog value via analogRead(A3). I have used these grove connectors before when reading LDRs, and they worked fine, but it seems I am doing something wrong this time. I have also tried using the Adafruit_ADS1015.h library to get raw voltages, but that isn’t working either. Could someone please have a quick look over my code to see if there is something obvious I am missing?
Thank you very much for your help.
Regards,
James
123456789101112131415161718192021222324252627282930313233343536#include <Arduino.h> // The base Arduino library#include <EnableInterrupt.h> // for external and pin change interrupts#include <LoggerBase.h> // The modular sensors library#include <Adafruit_ADS1015.h>Adafruit_ADS1115 ads; /* Use this for the Mayfly because of the onboard 16-bit ADS1115 */const int TDSpin = A3;const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power (-1 if not applicable)// the setup function runs once when you press reset or power the boardvoid setup() {// initialize digital pin 8 as an output.pinMode(sensorPowerPin, OUTPUT);// initialize a serial portSerial.begin(9600);ads.begin();}// the loop function runs over and over again forevervoid loop() {digitalWrite(sensorPowerPin, HIGH); // turn on voltage to sensorsdelay(5000);Serial.print(F(" Calculating TDS Sensor Voltage... "));int TDSStatus = ads.readADC_SingleEnded(A3);float voltage = TDSStatus * 0.1875;Serial.print(F(" TDS Voltage is ... "));Serial.println(voltage);digitalWrite(sensorPowerPin, LOW);delay(5000);} -
2020-10-06 at 11:51 AM #14632
Because the ADS1115 is a separate chip, you don’t have to declare the ADS1115 input pin numbers as A0, A1, etc. You just call them 0, 1, 2, or 3.
In your code, you can remove line 8 since you’re declaring an INT that you aren’t actually using anywhere. Or you could keep the line and just change ‘A3’ to ‘3’
Then in line 26, you can either change ‘A3’ to ‘TDSpin’ or simply ‘3’.
Assigning the pin number to the INT in line 8 is probably the best practice, and then use “TDSpin” everywhere else so that you can quickly change the number in line 8 to accommodate a sensor input on a different pin.
It’s fine if you have two different sensor inputs on adjacent Analog Aux pins on the Mayfly Grove port. Just make sure that both sensors are also each directly connected to the ground and Vcc pins.
-
2020-10-08 at 2:01 AM #14651
Thank you @shicks.
That set me on the right track. I think I can figure the rest out from here.
Just to make sure my understanding is correct, the ADS1115 is included in the Mayfly because it provides more voltage resolution than on standard analog pins, i.e. it allows for finer divisions than 0-1023 bits?
Thanks for your help.
James
-
2020-10-08 at 12:10 PM #14652
That’s correct, the main reason the ADS1115 is on the Mayfly is to give you much better resolution on analog measurements (16-bits versus the ATmega1284’s 10-bit ADC). It can also handle a much faster sampling rate and can take differential measurements. The standard ATmega analog inputs are still available for you to use, they’re just only accessible through the 2×10 header socket. The ADS1115 pins are available in two places: the 2×10 header socket and the 2 Grove sockets. Since they’re electrically the same pins, you can’t use more than one of those locations at a time. In your case, the Grove sockets are most convenient, but for anyone using a protoshield or building their own interface board for the Mayfly, then using the headers is more convenient.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.