SODA Arudino library
 All Classes Files Functions Variables Macros Pages
Public Member Functions | List of all members
SODA Class Reference

#include <SODA.h>

Public Member Functions

void begin ()
 
void updateTime (int val, int place)
 
int checkTime (int place)
 
void setTime ()
 
void getTime ()
 
void bufferTime ()
 
void serialSetTime ()
 
float getClockTemp ()
 
void setWake (int val, int valType)
 
void turnOff ()
 
void setStandby (unsigned char val)
 
int getStandby ()
 
long adcRead (int ch, int bit, int gain)
 
int smoothAnalogRead (int pin1)
 
void dataLineBegin ()
 
void dataLineAdd (int value)
 
void dataLineAdd (long value)
 
void dataLineAdd (float value)
 
void dataLineEnd ()
 
void dataDownload ()
 
void communicate ()
 
void setID (long ID)
 
long getID ()
 
void printBuffer ()
 
bool usbConnected ()
 
void blinks (int n)
 

Detailed Description

A class to handle basic datalogging functions using Olympia Circuit's SODA HE 1.0 Arduino-compatible board.

Member Function Documentation

long SODA::adcRead ( int  ch,
int  bit,
int  gain 
)

Returns a reading from the MCP3424 18-bit analog-digital converter.

Parameters
chan int argument specifying channel 1, 2, 3, or 4.
bitan int argument specifying the bit encoding 1 = 12, 2=14, 3=16, 4=18 bits.
gainas in argument specifying the level of gain from the programmable gain amplifier 1 = x1, 2 = x2, 3 = x4, 4 = x8. The return value includes any gain so that a signal of 100 nV with gain = 4 will return a reading of 800 nV.
Returns
long ADC value in nanoVolts (1 * 10^-9 volts).
void SODA::begin ( )

Initializes an instance of the SODA class. Should be called in each sketch before any other SODA functions.

void SODA::blinks ( int  n)

Blinks the led connected to pin 13. Used for simple communications such as to show when a process in under way or finished.

Parameters
nan int that sets the number of times to blink. Each blink = 100 ms on, 100 ms off.
void SODA::bufferTime ( )

Loads the timeArray into a formatted character buffer. Format = YYYY-MM-DD HH:MM:SS

See Also
getTime()
int SODA::checkTime ( int  place)

Returns an int value from the timeArray.

Parameters
placean int specifying the place in the time array (0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = second).
See Also
setTime()
updateTime()
void SODA::communicate ( )

Handles communication between the SODA and a computer/tablet through the serial monitor. Commands are sent through a serial connection using the format [XMORE_INFO] where X is a one-character command and MORE_INFO are optional, additional characters used to complete some commands such as setting the clock. current commands are: [D] downloads the logger file on the sd card

[I] return the logger_id

[R] runs through the sketch and normally ouputs a line of current readings to the serial connection.

[t] prints the current clock time to the serial connection

[TYYYY-MM-DD HH:MM:SS] sets the clock time

See Also
dataLineBegin()
dataLineAdd()
dataLineEnd()

set standby so the clock will be reset properly

void SODA::dataDownload ( )

Reads the contents of the data file from the SD card and streams it through the serial connection. The name of the file is set using #define filename definition at the top of SODA.h.

See Also
dataLineBegin()
dataLineAdd()
dataLineEnd()
void SODA::dataLineAdd ( int  value)

Adds an int value to the current data line. A comma is placed before the value. param value an int value

See Also
dataLineBegin()
dataLineEnd()
void SODA::dataLineAdd ( long  value)

Adds a long value to the current data line. A comma is placed before the value.

Parameters
valuean int value
See Also
dataLineBegin()
dataLineEnd()
void SODA::dataLineAdd ( float  value)

Adds a float value to the current data line. A comma is placed before the value.

Parameters
valuean int value
See Also
dataLineBegin()
dataLineEnd()
void SODA::dataLineBegin ( )

Begins a new dataline and writes the loggerid and current time separated by a comma. The clock is read by the functions so there's no need to make a seperate call to getTime(). The function typically begins writing the line to the SD card. If the USB cable is connected it instead writes to the serial monitor. If writing to the SD card, the file is opened and left open until a call to dataLineEnd().

See Also
dataLineAdd()
dataLineEnd()
getID()
getTime()
setID()
void SODA::dataLineEnd ( )

Terminates a data line. Adds a carriage return/line feed to the end of the data line and, if writing to the SD card, then closes the file.

See Also
dataLineBegin()
dataLineAdd()
float SODA::getClockTemp ( )

Returns the value from the internal temperature sensor in the DS3231 real time clock.

Returns
temperature in Celsius as float
long SODA::getID ( )

Returns the logger ID stored in microcontroller's EEPROM.

Returns
ID a long integer.
int SODA::getStandby ( )

Retrieves the standby variable that's used to indicate whether the logger is in logging or communication mode.

Returns
standby as unsigned char
See Also
setStandby
void SODA::getTime ( )

Loads the time from the clock to the timeArray. (0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = second).

See Also
setTime()
void SODA::printBuffer ( )

Prints the contents of the buffer[] array, usually a formatted time stamp.

void SODA::serialSetTime ( )

Set the clock based on input from the Serial connection. Serial data are first saved to the buffer[] array and then loaded to the timeArray before being sent to the clock. Serial data format = 'YYYY-MM-DD HH:MM:SS'.

See Also
setTime()
void SODA::setID ( long  ID)

Writes an logger ID number as a long value to the microcontroller's EEPROM (address 0 to 3).

Parameters
IDa long value to be used as the logger ID
void SODA::setStandby ( unsigned char  val)

Sets the standby variable to indicate whether the logger is in logging or communication mode.

Parameters
valunsigned char
See Also
getStandby
void SODA::setTime ( )

Resets the time in the clock to the values from timeArray.

See Also
checkTime()
getTime()
updateTime()
void SODA::setWake ( int  val,
int  valType 
)

Sets the clock alarm. Used to wake up the logger and begin a new measurement. Example: setWake(10,2); sets the alarm to the next 10 minute interval.

Parameters
valan int time value.
valTypean int indicating the units of time 1= secs, 2 = mins, 3=hours.
See Also
turnOff
int SODA::smoothAnalogRead ( int  pin1)

An improved version of analogRead that reduces noise in the measurement

Parameters
pin1pin number to make reading
Returns
an int value of the average reading (between 0 and 1023).
void SODA::turnOff ( )

Turns of the datalogger board by resetting the clock alarm pin, thereby shuttting off the voltage regulator.

See Also
setWake()
void SODA::updateTime ( int  val,
int  place 
)

Updates the time array. Need to run setTime to send time array to clock.

Parameters
valan int time values.
placean int specifying the place in the time array (0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = second).
See Also
setTime()
getTIme()
bool SODA::usbConnected ( )

Tests to see if the USB is connected. A USB connection causes pin 0 of the microcontroller to read as a digital high.

Returns
boolean values where connected = true, not connected = false.

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