ALog  v0.3.2
Open-source Arduino-based data logger library, designed for field science
Public Member Functions | List of all members
ALog Class Reference

Public Member Functions

 ALog ()
 ALog library for the Arduino-based data loggers. More...
 
void initialize (char *_logger_name, char *_datafilename, int _hourInterval, int _minInterval, int _secInterval, bool _ext_int=false, bool _LOG_ALL_SENSORS_ON_BUCKET_TIP=false)
 
void setupLogger ()
 
void sleep ()
 
void goToSleep_if_needed ()
 
void startLogging ()
 
void endLogging ()
 
void startAnalog ()
 
void endAnalog ()
 
void sensorPowerOn ()
 
void sensorPowerOff ()
 
bool get_use_sleep_mode ()
 
void set_LEDpin (int8_t _pin)
 
void set_SDpowerPin (int8_t _pin)
 
void set_RTCpowerPin (int8_t _pin)
 
void set_SensorPowerPin (int8_t _pin)
 
uint16_t get_serial_number ()
 
float get_3V3_measured_voltage ()
 
float get_5V_measured_voltage ()
 
float readPin (uint8_t pin)
 
float readPinOversample (uint8_t pin, uint8_t adc_bits)
 
float analogReadOversample (uint8_t pin, uint8_t adc_bits=10, uint8_t nsamples=1, bool debug=false)
 
float thermistorB (float R0, float B, float Rref, float T0degC, uint8_t thermPin, uint8_t ADC_resolution_nbits=14, bool Rref_on_GND_side=true, bool oversample_debug=false, bool record_results=true)
 
void ultrasonicMB_analog_1cm (uint8_t nping, uint8_t EX, uint8_t sonicPin, bool writeAll)
 
float maxbotixHRXL_WR_Serial (uint8_t Ex, uint8_t npings, bool writeAll, int maxRange, bool RS232=false)
 
void maxbotixHRXL_WR_analog (uint8_t nping=10, uint8_t sonicPin=A0, uint8_t EX=99, bool writeAll=true, uint8_t ADC_resolution_nbits=10)
 
void Decagon5TE (uint8_t excitPin, uint8_t dataPin)
 
void DecagonGS1 (uint8_t pin, float Vref, uint8_t ADC_resolution_nbits=14)
 
void vdivR (uint8_t pin, float Rref, uint8_t ADC_resolution_nbits=10, bool Rref_on_GND_side=true)
 
void linearPotentiometer (uint8_t linpotPin, float Rref, float slope, char *_distance_units, float intercept=0, uint8_t ADC_resolution_nbits=14, bool Rref_on_GND_side=true)
 
void HTM2500LF_humidity_temperature (uint8_t humidPin, uint8_t thermPin, float Rref_therm, uint8_t ADC_resolution_nbits=14)
 
void HM1500LF_humidity_with_external_temperature (uint8_t humidPin, float R0_therm, float B_therm, float Rref_therm, float T0degC_therm, uint8_t thermPin_therm, uint8_t ADC_resolution_nbits=14)
 
void Inclinometer_SCA100T_D02_analog_Tcorr (uint8_t xPin, uint8_t yPin, float Vref, float Vsupply, float R0_therm, float B_therm, float Rref_therm, float T0degC_therm, uint8_t thermPin_therm, uint8_t ADC_resolution_nbits=14)
 
void Anemometer_reed_switch (uint8_t interrupt_pin_number, unsigned long reading_duration_milliseconds, float meters_per_second_per_rotation)
 
void Wind_Vane_Inspeed (uint8_t vanePin)
 
void Pyranometer (uint8_t analogPin, float raw_mV_per_W_per_m2, float gain, float V_ref, uint8_t ADC_resolution_nbits=14)
 
void Barometer_BMP180 ()
 
void _sensor_function_template (uint8_t pin, float param1, float param2, uint8_t ADC_bits=14, bool flag=false)
 
void HackHD (int control_pin, bool want_camera_on)
 
float Honeywell_HSC_analog (int pin, float Vsupply, float Vref, float Pmin, float Pmax, int TransferFunction_number, int units, uint8_t ADC_resolution_nbits=14)
 

Constructor & Destructor Documentation

◆ ALog()

ALog::ALog ( )

ALog library for the Arduino-based data loggers.

ALog data logger library: methods to:

  • Initialize the data logger
  • Sleep and wake
  • Interact with the real-time clock (RTC)
  • Write data to the SD card
  • Manage power
  • Interact with a range of sensors

All help documentation here assumes you have created an instance of the "ALog" class.

ALog alog;

Member Function Documentation

◆ _sensor_function_template()

void ALog::_sensor_function_template ( uint8_t  pin,
float  param1,
float  param2,
uint8_t  ADC_bits = 14,
bool  flag = false 
)

Function to help lay out a new sensor interface. This need not be "void": it may return a value as well.

Details about sensor go here

Parameters
pinYou often need to specify interface pins
param1A variable for the sensor or to interpret its value
param2A variable for the sensor or to interpret its value
ADC_bitsYou often need to specify how much the analog-to-digital converter should be oversampled; this can range from 10 (no oversampling) to 16 (maximum possible oversampling before certainty in the oversampling method drops)
flagSomething that helps to set an option

Example (made up):

alog.Example(A2, 1021.3, 15.2, True);

◆ analogReadOversample()

float ALog::analogReadOversample ( uint8_t  pin,
uint8_t  adc_bits = 10,
uint8_t  nsamples = 1,
bool  debug = false 
)

Higher analog resolution through oversampling

This function incorporates oversampling to extend the ADC precision past ten bits by taking more readings and statistically combing them.

Returns a floating point number between 0 and 1023 in order to be intechangable with the Arduino core AnalogRead() function

It is often used within other sensor functinons to increase measurement precision.

Parameters
pinis the analog pin number
adc_bitsis the reading precision in bits (2^adc_bits). The ATMega328 (Arduino Uno and ALog BottleLogger core chip) has a base ADC precision of 10 bits (returns values of 0-1023) A reasonable maximum precision gain is (base_value_bits)+6, so 16 bits is a reasonable maximum precision for the ALog BottleLogger.
nsamplesis the number of times you want to poll the particular sensor and write the output to file.
debugis a flag that, if true, will write all of the values read during the oversampling to "Oversample.txt".

Example:

// 12-bit measurement of Pin 2
// Leaves nsamples at its default value of 1 (single reading of sensor)

Readings that require more bits of precision will take longer.

For analog measurements that do not require more than 10 bits of precision, use alog.readpin(int pin) or the standard Arduino "AnalogRead" function.

Based on eRCaGuy_NewAnalogRead::takeSamples(uint8_t analogPin)

Example:

// Take a single sample at 14-bit resolution and store it as "myReading"
myReading = alog.analogReadOversample(A3, 14, 1);

◆ Anemometer_reed_switch()

void ALog::Anemometer_reed_switch ( uint8_t  interrupt_pin_number,
unsigned long  reading_duration_milliseconds,
float  meters_per_second_per_rotation 
)

Anemometer that flips a reed switch each time it spins.

Parameters
interrupt_pin_numberis the digital pin number corresponding to the appropriate interrupt; it uses the Arduino digitalPinToInterrupt(n_pin) function to properly attach the interrupt. On the ALog BottleLogger, this number will always be 3.
reading_duration_millisecondsHow long will you count revolutions? Shorter durations save power, longer durations increase accuracy; very long durations will produce long-term averages. Typical values are a few seconds.
meters_per_second_per_rotationConversion factor between revolutions and wind speed. For the Inspeed Vortex wind sensor that we have used (http://www.inspeed.com/anemometers/Vortex_Wind_Sensor.asp), this is: 2.5 mph/Hz = 1.1176 (m/s)/Hz

This function depends on the global variable rotation_count.

Example:

// 4-second reading with Inspeed Vortex wind sensor on digital pin 3
// (interrupt 1), returned in meters per second
alog.Anemometer_reed_switch(3, 4000, 1.1176);

◆ Barometer_BMP180()

void ALog::Barometer_BMP180 ( )

Read absolute pressure in mbar.

This function reads the absolute pressure in mbar (hPa). BMP180 sensor incorporates on board temperature correction. Uses I2C protocol.

Example:

◆ Decagon5TE()

void ALog::Decagon5TE ( uint8_t  excitPin,
uint8_t  dataPin 
)

Reads a Decagon Devices 5TE soil moisture probe.

NEEDS TESTING with current ALog version.

Returns Dielectric permittivity [-unitless-], electrical conductivity [dS/m], and temperature [degrees C]. Soil moisture is calculated through postprocessing.

Uses SoftwareSerial, and therefore has the potential to go unstable; however, we have a time limit, so this won't crash the logger: it will just keep the logger from recording good data.

Modified from Steve Hicks' code for an LCD reader by Andy Wickert

Parameters
excitPinactivates the probe and powers it
dataPinreceives incoming serial data at 1200 bps

Example:

alog.Decagon5TE(7, 8);

◆ DecagonGS1()

void ALog::DecagonGS1 ( uint8_t  pin,
float  Vref,
uint8_t  ADC_resolution_nbits = 14 
)

Ruggedized Decagon Devices soil moisture sensor

Parameters
pinAnalog pin number
Vrefis the reference voltage of the ADC; on the ALog, this is a precision 3.3V regulator (unless a special unit without this regulator is ordered; the regulator uses significant power)
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10 bits)

Example:

// Using a non-precision Rref that is slightly off
alog.DecagonGS1(A1, 3.27, 14);

◆ endAnalog()

void ALog::endAnalog ( )

Turn off power to analog sensors

Actually just turns off 3V3 regulator that could power anything. Keeping this around for backwards compatibility; look to sensorPowerOff() for the preferred version of this.

◆ endLogging()

void ALog::endLogging ( )

Endslogging and returns to sleep

Ends line, turns of SD card, and resets alarm: ready to sleep.

Also runs tipping bucket rain gauge code (function that records time stamp) if one is attached and activated.

IMPORTANT: If the logger is not writing data to the card, and the card is properly inserted, the manually-set delay here may be the problem. We think we have made it long enough, but because it is hard-coded, there could be an unforeseen circumstance in which it is not!

◆ get_3V3_measured_voltage()

float ALog::get_3V3_measured_voltage ( )

Retrieve the ALog's 3.3V regulator's actual measured voltage under load, stored in the EEPROM.

It is stored in bytes 2, 3, 4, and 5 of the EEPROM.

◆ get_5V_measured_voltage()

float ALog::get_5V_measured_voltage ( )

Retrieve the ALog's 5V charge pump's actual measured voltage under load, stored in the EEPROM.

It is stored in bytes 6, 7, 8, and 9 of the EEPROM.

◆ get_serial_number()

uint16_t ALog::get_serial_number ( )

Retrieve the ALog's serial number from EEPROM .

It is stored in bytes 0 and 1 of the EEPROM.

◆ get_use_sleep_mode()

bool ALog::get_use_sleep_mode ( )

Does the logger enter a low-power sleep mode? T/F.

  • True if the logger is going to sleep between pases through the data-reading loop.
  • False if the logger is looping over its logging step (inside void loop() in the *.ino code) continuously without sleeping

◆ goToSleep_if_needed()

void ALog::goToSleep_if_needed ( )

Places logger into sleep mode iff this is being used.

Function is accessible from Arduino sketch; is designed for cases in which an external override may be required.

◆ HackHD()

void ALog::HackHD ( int  control_pin,
bool  want_camera_on 
)

HackHD camera control function

Control the HackHD camera: this function turns the HackHD on or off and records the time stamp from when the HackHD turns on/off in a file called "camera.txt".

Because this function turns the camera on or off, you have to ensure that you write a mechanism to keep it on for some time in your code. This could be checking the time each time you wake and deciding what to do, for example. In short: this function is a lower-level utility that requires the end-user to write the rest of the camera control sequence themselves.

Parameters
control_pinis the pin connected to the HackHD on/off switch; Dropping control_pin to GND for 200 ms turns camera on or off.
want_camera_onis true if you want to turn the camera on, false if you want to turn the camera off.

CAMERA_IS_ON is a global varaible attached to this function that saves the state of the camera; it will be compared to "want_camera_on", such that this function will do nothing if the camera is already on (or off) and you want it on (or off).

Power requirements:

  • 0.2 mA quiescent current draw;
  • 600 mA while recording

Example (not tested):

// Before "setup":
uint32_t t_camera_timeout_start_unixtime;
int timeout_secs = 300;
book camera_on = false;
// ...
// Inside "loop":
// Turn the camera on after some triggering event, and keep it on for as
// long as this condition is met, and for at least 5 minutes afterwards.
//
// >> some code to measure a variable's "distance"
// ...
//
if (distance < 1500){
alog.HackHD(8, true);
camera_on = true; // Maybe I can get a global variable from this library
// or have HackHD function return the camera state?
now = RTC.now();
// Reset the timeout clock
t_camera_timeout_start_unixtime = now.unixtime();
}
else if(camera_on){
now = RTC.now();
// If timed out, turn it off.
if ((t_camera_timeout_start_unixtime - now.unixtime()) > timeout_secs){
alog.HackHD(8, false);
camera_on = false;
}
}

This example could be used to capture flow during a flash flood. See:

◆ HM1500LF_humidity_with_external_temperature()

void ALog::HM1500LF_humidity_with_external_temperature ( uint8_t  humidPin,
float  R0_therm,
float  B_therm,
float  Rref_therm,
float  T0degC_therm,
uint8_t  thermPin_therm,
uint8_t  ADC_resolution_nbits = 14 
)

HM1500LF Relative humidity sensor with external temperature correction

This function measures the relative humidity of using a HTM1500 relative humidity sensor and an external thermistor. The relative humidity and temperature are measured using an oversampling method. Results are displayed on the serial monitor and saved onto the SD card to four decimal places. Temperature and relative humidity are recorded.

Parameters
humidPinis the analog pin connected to the humidity output voltage of the module.
R0_thermis the resistance of the thermistor at the known temperature.
B_thermis the B- or β- parameter of the thermistor.
Rref_thermis the resistance of the corresponding reference resistor for that analog pin.
T0degC_thermis a thermistor calibration.
thermPin_thermis the analog pin connected to the tempurature output voltage of the module.
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10)

Example:

alog.HM1500LF_humidity_with_external_temperature1,10000,3950,10000,25,1,12);

◆ Honeywell_HSC_analog()

float ALog::Honeywell_HSC_analog ( int  pin,
float  Vsupply,
float  Vref,
float  Pmin,
float  Pmax,
int  TransferFunction_number,
int  units,
uint8_t  ADC_resolution_nbits = 14 
)

Cost-effective pressure sensor from Honeywell

Datasheet: http://sensing.honeywell.com/index.php?ci_id=151133

See also the Honeywell_HSC_analog example.

Parameters
pinAnalog pin number
VsupplySupply voltage to sensor
Vrefis the reference voltage of the ADC; on the ALog, this is a precision 3.3V regulator (unless a special unit without this regulator is ordered; the regulator uses significant power)
PminMinimum pressure in range of sensor
PmaxMaximum pressure in range of sensor
PmaxMaximum pressure in range of sensor
TransferFunction_number1, 2, 3, or 4: which transfer function is used to convert voltage to pressure
  • TransferFunction: 1 = 10% to 90% of Vsupply ("A" in second to last digit of part number)
  • TransferFunction: 2 = 5% to 95% of Vsupply ("A" in second to last digit of part number)
  • TransferFunction: 3 = 5% to 85% of Vsupply ("A" in second to last digit of part number)
  • TransferFunction: 4 = 4% to 94% of Vsupply ("A" in second to last digit of part number)
unitsOutput units
  • Units: 0 = mbar
  • Units: 1 = bar
  • Units: 2 = Pa
  • Units: 3 = KPa
  • Units: 4 = MPa
  • Units: 5 = inH2O
  • Units: 6 = PSI
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10 bits)

Example:

alog.Honeywell_HSC_analog(A1, 5, 3.3, 0, 30, 1, 6);

◆ HTM2500LF_humidity_temperature()

void ALog::HTM2500LF_humidity_temperature ( uint8_t  humidPin,
uint8_t  thermPin,
float  Rref_therm,
uint8_t  ADC_resolution_nbits = 14 
)

HTM2500LF Relative humidity and temperature sensor

This function measures the relative humidity of using a HTM2500 tempurature and relative humidity module. The relative humidity and temperature is measured using a 14 bit oversampling method. Results are displayed on the serial monitor and saved onto the SD card to four decimal places.

Parameters
humidPinis the analog pin connected to the humidity output voltage of the module.
thermPinis the analog pin connected to the tempurature output voltage of the module.
Rref_thermis the value of the reference resistor that you use with the built-in thermistor (reference resistor supplied separately, placed in appropriate slot in header)
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10)

Example:

This function is designed for ratiometric operation – that is, the humidity sensor must be powered by the same voltage regulator that is connected to the the analog reference pin – for the ALog v2.0, this is a high-precision 3V3 regulator.

◆ Inclinometer_SCA100T_D02_analog_Tcorr()

void ALog::Inclinometer_SCA100T_D02_analog_Tcorr ( uint8_t  xPin,
uint8_t  yPin,
float  Vref,
float  Vsupply,
float  R0_therm,
float  B_therm,
float  Rref_therm,
float  T0degC_therm,
uint8_t  thermPin_therm,
uint8_t  ADC_resolution_nbits = 14 
)

Inclinometer, including temperature correction from an external sensor.

  • +/- 90 degree inclinometer, measures +/- 1.0g
  • Needs 4.75–5.25V input (Vsupply)
  • In typical usage, turned on and off by a switching 5V charge pump or boost converter
Parameters
xPinAnalog pin number corresponding to x-oriented tilts
yPinAnalog pin number corresponding to y-oriented tilts
Vrefis the reference voltage of the analog-digital comparator; it is 3.3V on the ALog.
Vsupplyis the input voltage that drives the sensor, and is typically between 3.3 and 5V.
R0_thermis a thermistor calibration.
B_thermis the B- or β- parameter of the thermistor.
Rref_thermis the resistance of the corresponding reference resistor for that analog pin.
T0degC_thermis a thermistor calibration.
thermPin_thermis the analog pin connected to the tempurature output voltage of the module.
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10). It is applied to both the inclinomter and its temperature correction

Example:

alog.Inclinometer_SCA100T_D02_analog_Tcorr(6, 2, 3.285, 5.191, \
10080.4120953, 3298.34232031, 10000, 25, 0);

◆ initialize()

void ALog::initialize ( char *  _logger_name,
char *  _datafilename,
int  _hourInterval,
int  _minInterval,
int  _secInterval,
bool  _ext_int = false,
bool  _LOG_ALL_SENSORS_ON_BUCKET_TIP = false 
)

Pass all variables needed to initialize logging.

Parameters
_logger_nameName associated with this data logger; often helps to relate it to the project or site
_datafilenameName of main data file saved to SD card; often helps to relate it to the project or site; used to be limited to 8.3 file naming convention, but now strictly is not. (I still use 8.3 names for safety's sake!)
_hourIntervalHow many hours to wait before logging again; can range from 0-24.
_minIntervalHow many minutes to wait before logging again; can range from 0-59.
_secIntervalHow many seconds to wait before logging again; can range from 0-59.

If all time-setting functions are 0, then the logger will not sleep, and instead will log continuously. This sets the flag "_use_sleep_mode" to be false.

Parameters
_ext_intExternal interrupt, set to be a tipping-bucket rain gauge, that triggers event-based logging of a timestamp
_LOG_ALL_SENSORS_ON_BUCKET_TIPFlag that tells the logger to read every sensor when the bucket tips (if _ext_int is true) and write their outputs to "datafile" (i.e. the main data file whose name you specify with _filename; this is in addition to writing the timestamp of the rain gauge bucket tip.

ALog Data logger model does not need to be set: it is automatically determined from the MCU type and is used to modify pinout-dependent functions.

Example:

\\ Log every five minutes
alog.initialize('TestLogger01', 'lab_bench_test.alog', 0, 0, 5, 0);

◆ linearPotentiometer()

void ALog::linearPotentiometer ( uint8_t  linpotPin,
float  Rref,
float  slope,
char *  _distance_units,
float  intercept = 0,
uint8_t  ADC_resolution_nbits = 14,
bool  Rref_on_GND_side = true 
)

Linear potentiometer (radio tuner) to measure distance

Distance based on resistance in a sliding potentiometer whose resistance may be described as a linear function

Parameters
linpotPinAnalog pin number
RrefResistance value of reference resistor [ohms]
slopeSlope of the line (distance = (slope)R + R0)
intercept(R0) of the line (distance = (slope)R + R0)
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10 bits)
_distance_unitsis the name of the units of distance that are used in the linear calibration equation, and are therefore the units of this function's output.
Rref_on_GND_sideindicates the configuration of the voltage divider. True if using Alog provided Reference resistor terminals. If false, the reference resitor must be instead connected via the screw terminals. This is set true for external sensors that are built to require a VCC-side reference resistor.

The output units will be whatever you have used to create your linear calibration equation

Example:

// Using a 0-10k ohm radio tuner with units in mm and a perfect intercept;
// maintaining default 14-bit readings with standard-side (ALog header)
// reference resistor set-up
alog.linearPotentiometer(A0, 5000, 0.0008);

◆ maxbotixHRXL_WR_analog()

void ALog::maxbotixHRXL_WR_analog ( uint8_t  nping = 10,
uint8_t  sonicPin = A0,
uint8_t  EX = 99,
bool  writeAll = true,
uint8_t  ADC_resolution_nbits = 10 
)

Newer 1-mm precision MaxBotix rangefinders: analog readings

This function measures the distance between the ultrasonic sensor and an \ acoustically-reflective surface, typically water or snow. Measures distance in milimeters. Results are displayed on the serial monitor and saved onto the SD card.

Parameters
npingis the number of range readings to take (number of pings). The mean range will be calculated and output to the serial monitor and SD card followed by the standard deviation.
sonicPinis the analog input channel hooked up to the maxbotix sensor.
EXis a digital output pin used for an excitation pulse. If maxbotix sensor is continuously powered, a reading will be taken when this pin is flashed high. Set to '99' if excitation pulse is not needed.
writeAllwill write each reading of the sensor (each ping) to the serial monitor and SD card.
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10 bits)

Example:

alog.maxbotixHRXL_WR_analog(10,A2,99,0);

Note that sensor should be mounted away from supporting structure. These are the standard recommendations:

  • For a mast that is 5 meters high (or higher) the sensor should be mounted at least 100cm away from the mast.
  • For a mast that is 2.5 meters high (or lower) the sensor should be at least 75cm away from the mast.

However, in our tests, the sensors with filtering algorithms function perfectly well even when positioned close to the mast, and a short mast increases the rigidity of the installation. This was tested in the lab by placing the MaxBotix sensor flush with table legs and testing distance readings to the floor.

◆ maxbotixHRXL_WR_Serial()

float ALog::maxbotixHRXL_WR_Serial ( uint8_t  Ex,
uint8_t  npings,
bool  writeAll,
int  maxRange,
bool  RS232 = false 
)

Uses the UART interface to record data from a MaxBotix sensor.

NOTE: THIS HAS CUASED LOGGERS TO FREEZE IN THE PAST; WHILE IT IS QUITE LIKELY THAT THE ISSUE IS NOW SOLVED, MORE TESTING IS REQUIRED. (ADW, 26 NOVEMBER 2016) (maybe solved w/ HW Serial?)

Parameters
ExExcitation pin that turns the sensor on; if this is not needed (i.e. you are turning main power off and on instead), then just set this to a value that is not a pin, and ensure that you turn the power to the sensor off and on outside of this function
npingsNumber of pings over which you average; each ping itself includes ten short readings that the sensor internally processes
writeAllwill write each reading of the sensor (each ping) to the serial monitor and SD card.
maxRangeThe range (in mm) at which the logger maxes out; this will be remembered to check for errors and to become a nodata values
RS232this is set true if you use inverse (i.e. RS232-style) logic; it works at standard logger voltages (i.e. it is not true RS232). If false, TTL logic will be used.

Example:

// Digital pin 7 controlling sensor excitation, averaging over 10 pings,
// not recording the results of each ping, and with a maximum range of
// 5000 mm using standard TTL logic
alog.maxbotixHRXL_WR_Serial(7, 10, false, 5000, false);

◆ Pyranometer()

void ALog::Pyranometer ( uint8_t  analogPin,
float  raw_mV_per_W_per_m2,
float  gain,
float  V_ref,
uint8_t  ADC_resolution_nbits = 14 
)

Pyranometer wtih instrumentation amplifier

Pyranomiter is from Kipp and Zonen

nominal raw_output_per_W_per_m2_in_mV = 10./1000.; // 10 mV at 1000 W/m**2

Actual raw output is based on calibration.

Parameters
analogPinis the pin that receives the amplified voltage input
raw_mV_per_W_per_m2is the conversion factor of the pyranometer: number of millivolts per (watt/meter^2). This does not include amplification!
gainis the amplification factor
Vrefis the reference voltage of the ADC; on the ALog, this is a precision 3.3V regulator (unless a special unit without this regulator is ordered; the regulator uses significant power)
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10 bits)

Example:

// Using precision voltage reference and 16-bit resolution (highest
// defensible oversampling resolution)
alog.Pyranometer(A0, 0.0136, 120, 3.300, 16);

◆ readPin()

float ALog::readPin ( uint8_t  pin)

Read the analog value of a pin.

This function returns the analog to digital converter value (0 - 1023). Results are displayed on the serial monitor and saved onto the SD card.

Parameters
pinis the analog pin number to be read.

Example:

alog.readPin(2);

◆ readPinOversample()

float ALog::readPinOversample ( uint8_t  pin,
uint8_t  adc_bits 
)

Read the analog value of a pin, with extra resolution from oversampling

This function incorporates oversampling to extend the ADC precision past ten bits by taking more readings and statistically combing them. Results are displayed on the serial monitor and saved onto the SD card.

Parameters
pinis the analog pin number to be read.
adc_bitsis the reading precision in bits (2^adc_bits). The ATMega328 (Arduino Uno and ALog BottleLogger core chip) has a base ADC precision of 10 bits (returns values of 0-1023) A reasonable maximum precision gain is (base_value_bits)+6, so 16 bits is a reasonable maximum precision for the ALog BottleLogger.

Example:

alog.readPinOversample(2, 12);

Output values will range from 0-1023, but be floating-point.

Readings that require more bits of precision will take longer.

◆ sensorPowerOff()

void ALog::sensorPowerOff ( )

Turn OFF power to 3V3 regulator that connects to screw terminals.

This cuts 3V3 power to external devices.

◆ sensorPowerOn()

void ALog::sensorPowerOn ( )

Turn ON power to 3V3 regulator that connects to screw terminals.

This powers external devices.

◆ set_LEDpin()

void ALog::set_LEDpin ( int8_t  _pin)

Set which pin to use for the main indicator LED.

Run this, if needed, before setupLogger()

◆ set_RTCpowerPin()

void ALog::set_RTCpowerPin ( int8_t  _pin)

Set which pin activates the 3V3 regulator to power the RTC (real-time clock).

  • Set to -1 if not being used
  • Set to the same as SDpowerPin if these are connected (standard for the ALog BottleLogger) Run this, if needed, before setupLogger()

◆ set_SDpowerPin()

void ALog::set_SDpowerPin ( int8_t  _pin)

Set which pin activates the 3V3 regulator to power the SD card.

  • Set to -1 if not being used
  • Set to the same as RTCpowerPin if these are connected (standard for the ALog BottleLogger) Run this, if needed, before setupLogger()

◆ set_SensorPowerPin()

void ALog::set_SensorPowerPin ( int8_t  _pin)

Set which pin activates the 3V3 regulator to power sensors and any other external 3V3 devices that receive power from the ALog's 3V3 regulator.

  • Set to -1 if not being used
  • Otherwise, set to the number of the pin controlling the 3V3 regulator that goes to the sensors and other peripherals. Run this, if needed, before setupLogger()

◆ setupLogger()

void ALog::setupLogger ( )

Readies the ALog to begin measurements

Sets all pins, alarms, clock, SD card, etc: everything needed for the ALog to run properly.

◆ sleep()

void ALog::sleep ( )

Puts the ALog data logger into a low-power sleep mode

Sets the "IS_LOGGING" flag to false, disables the watchdog timer, and puts the logger to sleep.

◆ startAnalog()

void ALog::startAnalog ( )

Turn on power to analog sensors

Actually just turns on 3V3 regulator that could power anything. Keeping this around for backwards compatibility; look to sensorPowerOn() for the preferred version of this.

◆ startLogging()

void ALog::startLogging ( )

Wakes the logger and starts logging

Wakes the logger: sets the watchdog timer (a failsafe in case the logger hangs), checks and clears alarm flags, looks for rain gauge bucket tips (if they occur during the middle of a logging event (ignore) or if they include a command to read all sensors with a tip), and starts to log to "datafile", if it can.

If the logger cannot reach the SD card, it sends out an LED warning message of 20 rapid flashes.

◆ thermistorB()

float ALog::thermistorB ( float  R0,
float  B,
float  Rref,
float  T0degC,
uint8_t  thermPin,
uint8_t  ADC_resolution_nbits = 14,
bool  Rref_on_GND_side = true,
bool  oversample_debug = false,
bool  record_results = true 
)

Read the analog value of a pin, with extra resolution from oversampling

This function measures temperature using a thermistor characterised with the B (or β) parameter equation, which is a simplification of the Steinhart-Hart equation

The function compares the thermistor risistance with the reference resistor using a voltage divider.

It returns a float of the temperature in degrees celsius. Results are displayed on the serial monitor and saved onto the SD card to four decimal places.

Parameters
R0is the resistance of the thermistor at the known temperature
T0degC.[Ω]
Bis the β parameter of the thermistor. [K]
Rrefis the resistance of the corresponding reference resistor for \ the analog pin set by ThermPin (below). [Ω]
T0degCis the temperature at which R0 was calibrated. [°C]
thermPinis the analog pin number to be read. [-]
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10 bits) [bits]
Rref_on_GND_sideindicates the configuration of the voltage divider. True if using Alog provided Reference resistor terminals. If false, the reference resitor must be instead connected via the screw terminals. This is set true for external sensors that are built to require a VCC-side reference resistor.
oversample_debugis true if you want a separate file, "Oversample.txt", to record every individual reading used in the oversampling.
record_resultsis true if you want to save results to the SD card and print to the serial monitor.

Examples:

// Cantherm from Digikey
// 10 kOhm @ 25degC, 3950 K b-value, 30 kOhm reference resistor, on
// analog Pin 1, 14-bit precision
alog.thermistorB(10000, 3950, 30000, 25, 2, 14);
// EPCOS, DigiKey # 495-2153-ND
// 10 kOhm @ 25degC, 3988 K b-value, 13.32 kOhm reference resistor, on
// analog Pin 1, 12-bit precision
alog.thermistorB(10000, 3988, 13320, 25, 1, 12);

◆ ultrasonicMB_analog_1cm()

void ALog::ultrasonicMB_analog_1cm ( uint8_t  nping,
uint8_t  EX,
uint8_t  sonicPin,
bool  writeAll 
)

Old 1-cm resolution Maxbotix ultrasonic rangefinders: analog measurements

This function measures the distance between the ultrasonic sensor and an acustically reflective surface, typically water or snow. Measures distance in centimeters. Results are displayed on the serial monitor and saved onto the SD card.

This is for the older MaxBotix sensors, whose maximum precision is in centimeters.

Parameters
npingis the number of range readings to take (number of pings). The mean range will be calculated and output to the serial monitor and SD card followed by the standard deviation.
EXis a digital output pin used for an excitation pulse. If maxbotix sensor is continuously powered a reading will be taken when this pin is flashed high. Set to '99' if excitation pulse is not needed.
sonicPinis the analog input channel hooked up to the maxbotix sensor.
writeAllwill write each reading of the sensor (each ping) to the serial monitor and SD card.

Example:

alog.ultrasonicMB_analog_1cm(10, 99, 2, 0);

Note that sensor should be mounted away from supporting structure. For a mast that is 5 meters high (or higher) the sensor should be mounted at least 100cm away from the mast. For a mast that is 2.5 meters high (or lower) the sensor should be at least 75cm away from the mast.

◆ vdivR()

void ALog::vdivR ( uint8_t  pin,
float  Rref,
uint8_t  ADC_resolution_nbits = 10,
bool  Rref_on_GND_side = true 
)

Resistance from a simple voltage divider

Parameters
pinAnalog pin number
RrefResistance value of reference resistor [ohms]
ADC_resolution_nbits(10-16 for the ALog BottleLogger) is the number of bits of ADC resolution used (oversampling for >10 bits)
Rref_on_GND_sideindicates the configuration of the voltage divider. True if using Alog provided Reference resistor terminals. If false, the reference resitor must be instead connected via the screw terminals. This is set true for external sensors that are built to require a VCC-side reference resistor.

Example:

// Use standard reference resistor headers: let last parameter be false
// (default)
alog.vdivR(A2, 10000, 12);

◆ Wind_Vane_Inspeed()

void ALog::Wind_Vane_Inspeed ( uint8_t  vanePin)

Wind vane: resistance changes with angle to wind.

Parameters
vanePinis the analog pin that reads the wind vane resistance

This function is specialized for the Inspeed eVane2. Here, a resistance of 0 equates to wind from the north, and resistence increases in a clockwise direction.

Connect one wire to power supply, one wire to analog pin, one wire to GND

From documentation:

  • 5 - 95% of power supply input voltage = 0 to 360 degrees of rotation.
  • Uses Hall Effect Sensor
  • Don't forget to use set screw to zero wind sensor before starting!

Example:

// After setting up and zeroing the eVane to North, you wire it to
// analog pin 7 on the ALog

The documentation for this class was generated from the following files: