#include <SODA.h>
Public Member Functions | |
long | adcRead (int ch, int bit, int gain) |
void | begin () |
void | blinks (int n) |
void | bufferTime () |
int | checkTime (int place) |
void | communicate () |
void | dataDownload () |
void | dataLineAdd (int value) |
void | dataLineAdd (long value) |
void | dataLineAdd (float value) |
void | dataLineBegin () |
void | dataLineEnd () |
float | getClockTemp () |
long | getID () |
int | getStandby () |
void | getTime () |
void | printBuffer () |
void | serialSetTime () |
void | setID (long ID) |
void | setStandby (unsigned char val) |
void | setTime () |
void | setWake (int val, int valType) |
int | smoothAnalogRead (int pin1) |
int | tcReadK (int ch) |
void | turnOff () |
void | updateTime (int val, int place) |
bool | usbConnected () |
A class to handle basic datalogging functions using Olympia Circuit's SODA HE 1.0 Arduino-compatible board.
long SODA::adcRead | ( | int | ch, |
int | bit, | ||
int | gain | ||
) |
Returns a reading from the MCP3424 18-bit analog-digital converter.
ch | an int argument specifying channel 1, 2, 3, or 4. |
bit | an int argument specifying the bit encoding 1 = 12, 2=14, 3=16, 4=18 bits. |
gain | as in argument specifying the level of gain from the programmable gain amplifier 1 = x1, 2 = x2, 3 = x4, 4 = x8. The return value is adjusted for gain so that a signal of 100 nV with gain = 4 will return a reading of 100 nV. |
void SODA::begin | ( | ) |
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.
n | an 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
int SODA::checkTime | ( | int | place | ) |
Returns an int value from the timeArray.
place | an int specifying the place in the time array (0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = second). |
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
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.
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
void SODA::dataLineAdd | ( | long | value | ) |
Adds a long value to the current data line. A comma is placed before the value.
value | an int value |
void SODA::dataLineAdd | ( | float | value | ) |
Adds a float value to the current data line. A comma is placed before the value.
value | an int value |
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().
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.
float SODA::getClockTemp | ( | ) |
Returns the value from the internal temperature sensor in the DS3231 real time clock.
long SODA::getID | ( | ) |
Returns the logger ID stored in microcontroller's EEPROM.
int SODA::getStandby | ( | ) |
Retrieves the standby variable that's used to indicate whether the logger is in logging or communication mode.
void SODA::getTime | ( | ) |
Loads the time from the clock to the timeArray. (0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = second).
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'.
void SODA::setID | ( | long | ID | ) |
Writes an logger ID number as a long value to the microcontroller's EEPROM (address 0 to 3).
ID | a 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.
val | unsigned char |
void SODA::setTime | ( | ) |
Resets the time in the clock to the values from timeArray.
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.
val | an int time value. |
valType | an int indicating the units of time 1= secs, 2 = mins, 3=hours. |
int SODA::smoothAnalogRead | ( | int | pin1 | ) |
An improved version of analogRead that reduces noise in the measurement
pin1 | pin number to make reading |
int SODA::tcReadK | ( | int | ch | ) |
Returns a temperature reading from a type K themocouple.
ch | an int argument specifying ADC channel 1,2,3, or 4 |
void SODA::turnOff | ( | ) |
Turns of the datalogger board by resetting the clock alarm pin, thereby shuttting off the voltage regulator.
void SODA::updateTime | ( | int | val, |
int | place | ||
) |
Updates the time array. Need to run setTime to send time array to clock.
val | an int time values. |
place | an int specifying the place in the time array (0 = year, 1 = month, 2 = day, 3 = hour, 4 = minute, 5 = second). |
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.