Post by agz2007 on Nov 10, 2022 4:21:06 GMT
Hello,
I am attempting to create a water sampler designed to collect 35mL of liquid every 15 minutes. Additionally, the SIM 7000 is sketched to send SMS to a phone number under a few conditions,
condition A.) If total volume collected is greater than a threshold (300mL), OR a normally closed float switch in the collection jar goes open, the SIM module will send an SMS message saying "FULL"! along with the current read out of totalMililitres (volume)
condition B.) if DS18b20 sensor detects temperature below 32 degrees Fahrenheit in collection jar, SIM module sends SMS message saying "FREEZING!" along with current readout of DS18B20 in serial monitor.
condition C.) if battery voltage, converted into percentage, drops below 20%, SIM module will send SMS message saying "BATTERY LOW!", along with current battery percent in serial monitor.
All of these functions were working perfectly and exactly how I wanted them.. However, I'm trying to post volume, battery life, and temperature to a dashboard on freeboard.io.
I took the IOT_EXAMPLE sketch from the Adafruit FONA library and adapted it to where is posts temperature, battery life, and volume to dweet.io, from where freeboard then pulls the data. The major problem I have stumbled upon is that the sampling rate in the IOT_example sketch (10 seconds) is too frequent, and it also holds up the rest of the sketch so if battery life decreases, volume increase, or temperature fluctuates between those 10 seconds, it wont post to the serial monitor or the dashboard. I changed the sampling rate to 15 minutes, as the sampler is set to collect liquid every 15 minutes, but if it collects during those 15 minutes it wont post to the serial monitor because it is stuck with the sampling rate basically anything that happens after "22:54:44.799 -> Waiting for 900 seconds" wont show on serial monitor. I want data to post every 15 minutes, but I do not wish for the serial monitor to wait for 15 minutes to collect data. I have included my sketch, please advise
I am attempting to create a water sampler designed to collect 35mL of liquid every 15 minutes. Additionally, the SIM 7000 is sketched to send SMS to a phone number under a few conditions,
condition A.) If total volume collected is greater than a threshold (300mL), OR a normally closed float switch in the collection jar goes open, the SIM module will send an SMS message saying "FULL"! along with the current read out of totalMililitres (volume)
condition B.) if DS18b20 sensor detects temperature below 32 degrees Fahrenheit in collection jar, SIM module sends SMS message saying "FREEZING!" along with current readout of DS18B20 in serial monitor.
condition C.) if battery voltage, converted into percentage, drops below 20%, SIM module will send SMS message saying "BATTERY LOW!", along with current battery percent in serial monitor.
All of these functions were working perfectly and exactly how I wanted them.. However, I'm trying to post volume, battery life, and temperature to a dashboard on freeboard.io.
I took the IOT_EXAMPLE sketch from the Adafruit FONA library and adapted it to where is posts temperature, battery life, and volume to dweet.io, from where freeboard then pulls the data. The major problem I have stumbled upon is that the sampling rate in the IOT_example sketch (10 seconds) is too frequent, and it also holds up the rest of the sketch so if battery life decreases, volume increase, or temperature fluctuates between those 10 seconds, it wont post to the serial monitor or the dashboard. I changed the sampling rate to 15 minutes, as the sampler is set to collect liquid every 15 minutes, but if it collects during those 15 minutes it wont post to the serial monitor because it is stuck with the sampling rate basically anything that happens after "22:54:44.799 -> Waiting for 900 seconds" wont show on serial monitor. I want data to post every 15 minutes, but I do not wish for the serial monitor to wait for 15 minutes to collect data. I have included my sketch, please advise
// For SIM7000 cellular shield
#include "Adafruit_FONA.h" // https://github.com/botletics/SIM7000-LTE-Shield/tree/master/Code
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
// For SIM7000 shield
#define FONA_PWRKEY 6
#define FONA_RST 7
#define FONA_TX 10 // Microcontroller RX
#define FONA_RX 11 // Microcontroller TX
#define SIMCOM_7000
#define PROTOCOL_HTTP_GET // Generic
#define LED 13
// Using SoftwareSerial
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA_LTE fona = Adafruit_FONA_LTE();
#define samplingRate 900 // The time in between posts, in seconds
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
char imei[16] = {0}; // Use this for device ID
char replybuffer[255]; // Large buffer for replies
uint8_t type;
uint8_t counter = 0;
bool bat = false;
bool opened = false;
bool cold = false;
char volBuff[12];
char tempBuff[12];
char batBuff[12];
char URL[300]; // Make sure this is long enough for your request URL
char body[200]; // Only need this is you're doing an HTTP POST request
//const int FLOWSWITCH = 2; // Use pin 2 to wake up the Uno/Mega
const int buttonPin = 3;
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
//int buttonState4 = 0; // current state of the button
//int lastButtonState4 = 0; // previous state of the button
const char * phone_number = "+18000000006"; // Include country code, only numbe
const char * text_message1 = " mL FULL!"; // Change to suit your needs
const char * text_messageV = volBuff;
const char * text_message3 = " % BATTERY LOW!";
const char * text_messageB = batBuff;
const char * text_message2 = "*F FREEZING!"; // Change to suit your needs
const char * text_messageF = tempBuff;
int flowPin = 2; //This is the input pin on the Arduino
double flowRate; //This is the value we intend to calculate.
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
volatile int count; //This integer needs to be set as volatile to ensure it updates correctly during the interrupt process.
float tempC;
float tempF;
float tLimit = 45.0;
float bLimit = 20;
#define readPin A0
const unsigned long BatR1R2[] = {5100, 3000}; // resistor values
const unsigned long RefVolt = 4940; // voltage divider output at A0
const unsigned long BatRsVal = 1024;
const unsigned long Ratio = ((BatR1R2[0] + BatR1R2 [1]) * RefVolt) / BatR1R2[1];
const unsigned long BatVoltMax = 13300; // fully charged LifePO4 battery
const unsigned long BatVoltMin = 10500; //approximate fully discharged voltage
const unsigned int NrSamples = 1000; // not sure what this does
float counts = 0;
void setup() {
Serial.begin(115200);
// while (!Serial) delay(1); // Wait for serial, for debug
Serial.println(F("*** Burgalert 7000 ***"));
pinMode(flowPin, INPUT); //Sets the pin as an input
attachInterrupt(0, Flow, RISING); //Configures interrupt 0 (pin 2 on the Arduino Uno) to run the function "Flow"
flowRate = 0.0;
totalMilliLitres = 0;
//pinMode(BUTTON, INPUT); // For the interrupt wake-up to work
#ifdef LED
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
#endif
pinMode(FONA_RST, OUTPUT);
digitalWrite(FONA_RST, HIGH); // Default state
pinMode(FONA_PWRKEY, OUTPUT);
pinMode(buttonPin, INPUT);
powerOn(true); // Power on the module
moduleSetup(); // Establish first-time serial comm and print IMEI
fona.setFunctionality(1); // AT+CFUN=1
fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
// Perform first-time GPS/GPRS setup if the shield is going to remain on,
// otherwise these won't be enabled in loop() and it won't work!
#ifndef turnOffShield
#if !defined(SIMCOM_3G) && !defined(SIMCOM_7500) && !defined(SIMCOM_7600)
// Disable GPRS just to make sure it was actually off so that we can turn it on
if (!fona.enableGPRS(false)) Serial.println(F("Failed to disable GPRS!"));
// Turn on GPRS
while (!fona.enableGPRS(true)) {
Serial.println(F("Failed to enable GPRS, retrying..."));
delay(2000); // Retry every 2s
}
Serial.println(F("Enabled GPRS!"));
#endif
#endif
Serial.print("Locating devices...");
sensors.begin();
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");
// report parasite power requirements
// Serial.print("Parasite power is: ");
// if (sensors.isParasitePowerMode()) Serial.println("ON");
// else Serial.println("OFF");
if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
//if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
// show the addresses we found on the bus
Serial.print("Device 0 Address: ");
printAddress(insideThermometer);
Serial.println();
// set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
sensors.setResolution(insideThermometer, 9);
Serial.print("Device 0 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer), DEC);
Serial.println();
}
void loop()
{
delay(5);
unsigned int adcValue = averageRead( readPin);
analogReference(DEFAULT);
unsigned int BatVoltage = adcValue * Ratio / BatRsVal;
Serial.print("Batery voltage [mV]: ");
Serial.println(BatVoltage);
byte percent = 100 * (BatVoltage - BatVoltMin) / (BatVoltMax - BatVoltMin);
Serial.print("Battery level [%]: ");
Serial.println(percent);
if (BatVoltage < BatVoltMin)
percent = 0;
else
percent;
dtostrf(percent, 1, 2, batBuff);
delay(100);
Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
printTemperature(insideThermometer); // Use a simple function to print out the data
tempC = sensors.getTempCByIndex(0);
tempF = (tempC * 1.8) + 32;
dtostrf(tempF, 1, 2, tempBuff);
count = 0; // Reset the counter so we start counting from 0 again
delay (100); //Wait 1 second
// noInterrupts(); //Disable the interrupts on the Arduino
// Only send SMS if the switch was closed
//Start the math
flowRate = (count * 2.25); //Take counted pulses in the last second and multiply by 2.25mL
flowRate = flowRate * 60; //Convert seconds to minutes, giving you mL / Minute
flowRate = flowRate / 1000; //Convert mL to Liters, giving you Liters / Minute
totalMilliLitres += flowRate;
buttonState = digitalRead(buttonPin);
Serial.println(flowRate); //Print the variable flowRate to Serial
Serial.println(totalMilliLitres);
dtostrf(totalMilliLitres, 1, 2, volBuff);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If the shield was already on, no need to re-enable
#if defined(turnOffShield) && !defined(SIMCOM_3G) && !defined(SIMCOM_7500) && !defined(SIMCOM_7600)
// Disable GPRS just to make sure it was actually off so that we can turn it on
if (!fona.enableGPRS(false)) Serial.println(F("Failed to disable GPRS!"));
// Turn on GPRS
while (!fona.enableGPRS(true)) {
Serial.println(F("Failed to enable GPRS, retrying..."));
delay(2000); // Retry every 2s
}
Serial.println(F("Enabled GPRS!"));
#endif
// Post something like temperature and battery level to the web API
// Construct URL and post the data to the web API
// Format the floating point numbers
// Also construct a combined, comma-separated location array
// (many platforms require this for dashboards, like Adafruit IO):
//sprintf(locBuff, "%s,%s,%s,%s", speedBuff, latBuff, longBuff, altBuff); // This could look like "10,33.123456,-85.123456,120.5"
// Construct the appropriate URL's and body, depending on request type
// In this example we use the IMEI as device ID
#ifdef PROTOCOL_HTTP_GET
// GET request
counter = 0; // This counts the number of failed attempts tries
#if defined(SIMCOM_3G) || defined(SIMCOM_7500) || defined(SIMCOM_7600)
// You can adjust the contents of the request if you don't need certain things like speed, altitude, etc.
sprintf(URL, "GET /dweet/for/%s?temp=%s&bat=%s&vol=%s HTTP/1.1\r\nHost: dweet.io\r\n\r\n",
imei, tempBuff, batBuff, volBuff);
// Try a total of three times if the post was unsuccessful (try additional 2 times)
while (counter < 3 && !fona.postData("www.dweet.io", 443, "HTTPS", URL)) { // Server, port, connection type, URL
Serial.println(F("Failed to complete HTTP/HTTPS request..."));
counter++; // Increment counter
delay(1000);
}
#else
sprintf(URL, "http://dweet.io/dweet/for/%s?temp=%s&bat=%s&vol=%s", imei, tempBuff, batBuff, volBuff);
while (counter < 3 && !fona.postData("GET", URL)) {
Serial.println(F("Failed to post data, retrying..."));
counter++; // Increment counter
delay(1000);
}
#endif
#elif defined(PROTOCOL_HTTP_POST)
// You can also do a POST request instead
counter = 0; // This counts the number of failed attempts tries
#if defined(SIMCOM_3G) || defined(SIMCOM_7500) || defined(SIMCOM_7600)
sprintf(body, "{\"lat\":%s,\"long\":%s}\r\n", latBuff, longBuff); // Terminate with CR+NL
sprintf(URL, "POST /dweet/for/%s HTTP/1.1\r\nHost: dweet.io\r\nContent-Length: %i\r\n\r\n", imei, strlen(body));
while (counter < 3 && !fona.postData("www.dweet.io", 443, "HTTPS", URL, body)) { // Server, port, connection type, URL
Serial.println(F("Failed to complete HTTP/HTTPS request..."));
counter++; // Increment counter
delay(1000);
}
#else
sprintf(URL, "http://dweet.io/dweet/for/%s", imei);
sprintf(body, "{\"lat\":%s,\"long\":%s}", latBuff, longBuff);
// Let's try a POST request to thingsboard.io
// Please note this can me memory-intensive for the Arduino Uno
// and may not work. You might have to split it up into a couple requests
// and send part of the data in one request, and the rest in the other, etc.
// Perhaps an easier solution is to swap out the Uno with an Arduino Mega.
/*
const char * token = "qFeFpQIC9C69GDFLWdAv"; // From thingsboard.io device
sprintf(URL, "http://demo.thingsboard.io/api/v1/%s/telemetry", token);
sprintf(body, "{\"lat\":%s,\"long\":%s,\"speed\":%s,\"head\":%s,\"alt\":%s,\"temp\":%s,\"batt\":%s}", latBuff, longBuff,
speedBuff, headBuff, altBuff, tempBuff, battBuff);
// sprintf(body, "{\"lat\":%s,\"long\":%s}", latBuff, longBuff); // If all you want is lat/long
*/
while (counter < 3 && !fona.postData("POST", URL, body)) {
Serial.println(F("Failed to complete HTTP POST..."));
counter++;
delay(1000);
}
#endif
#endif
//Only run the code below if you want to turn off the shield after posting data
#ifdef turnOffShield
// Disable GPRS
// Note that you might not want to check if this was successful, but just run it
// since the next command is to turn off the module anyway
if (!fona.enableGPRS(false)) Serial.println(F("Failed to disable GPRS!"));
// Turn off GPS
if (!fona.enableGPS(false)) Serial.println(F("Failed to turn off GPS!"));
// Power off the module. Note that you could instead put it in minimum functionality mode
// instead of completely turning it off. Experiment different ways depending on your application!
// You should see the "PWR" LED turn off after this command
// if (!fona.powerDown()) Serial.println(F("Failed to power down FONA!")); // No retries
counter = 0;
while (counter < 3 && !fona.powerDown()) { // Try shutting down
Serial.println(F("Failed to power down FONA!"));
counter++; // Increment counter
delay(1000);
}
#endif
// Alternative to the AT command method above:
// If your FONA has a PWRKEY pin connected to your MCU, you can pulse PWRKEY
// LOW for a little bit, then pull it back HIGH, like this:
// digitalWrite(PWRKEY, LOW);
// delay(600); // Minimum of 64ms to turn on and 500ms to turn off for FONA 3G. Check spec sheet for other types
// delay(1300); // Minimum of 1.2s for SIM7000
// digitalWrite(PWRKEY, HIGH);
// Shut down the MCU to save power
#ifndef samplingRate
Serial.println(F("Shutting down..."));
delay(5); // This is just to read the response of the last AT command before shutting down
MCU_powerDown(); // You could also write your own function to make it sleep for a certain duration instead
#else
// The following lines are for if you want to periodically post data (like GPS tracker)
Serial.print(F("Waiting for ")); Serial.print(samplingRate); Serial.println(F(" seconds\r\n"));
delay(samplingRate * 1000UL); // Delay
// Only run the initialization again if the module was powered off
// since it resets back to 115200 baud instead of 4800.
#ifdef turnOffShield
fona.powerOn(FONA_PWRKEY); // Powers on the module if it was off previously
moduleSetup();
#endif
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (buttonState == HIGH && lastButtonState == LOW || totalMilliLitres > 300 && totalMilliLitres - flowRate <= 300) {
opened = false;
lastButtonState = buttonState;
FullSMS ();
}
if (tempF < tLimit && cold == false) {
ColdSMS ();
cold = true;
}
else if (tempF > tLimit + 2.0 && cold == true) {
cold = false;
}
if (percent < bLimit && bat == false) {
batSMS ();
bat = true;
}
}
unsigned int averageRead( byte pin)
{
unsigned long total = 0;
for ( int i = 0; i < NrSamples; i++)
{
total += analogRead( pin);
}
total += NrSamples / 2; // add half a bit
return ( total / NrSamples);
}
// Power on/off the module
void powerOn(bool state) {
if (state) {
Serial.println(F("Turning on SIM7000..."));
digitalWrite(FONA_PWRKEY, LOW);
delay(100); // Turn on module
digitalWrite(FONA_PWRKEY, HIGH);
delay(4500); // Give enough time for the module to boot up before communicating with it
}
else {
Serial.println(F("Turning off SIM7000..."));
fona.powerDown(); // Turn off module
}
}
void moduleSetup() {
// SIM7000 takes about 3s to turn on and SIM7500 takes about 15s
// Press Arduino reset button if the module is still turning on and the board doesn't find it.
// When the module is on it should communicate right after pressing reset
// Software serial:
fonaSS.begin(115200); // Default SIM7000 shield baud rate
Serial.println(F("Configuring to 9600 baud"));
fonaSS.println("AT+IPR=9600"); // Set baud rate
delay(100); // Short pause to let the command run
fonaSS.begin(9600);
if (! fona.begin(fonaSS)) {
Serial.println(F("Couldn't find FONA"));
while (1); // Don't proceed if it couldn't find the device
}
// Hardware serial:
/*
fonaSerial->begin(115200); // Default SIM7000 baud rate
if (! fona.begin(*fonaSerial)) {
DEBUG_PRINTLN(F("Couldn't find SIM7000"));
}
*/
// The commented block of code below is an alternative that will find the module at 115200
// Then switch it to 9600 without having to wait for the module to turn on and manually
// press the reset button in order to establish communication. However, once the baud is set
// this method will be much slower.
/*
fonaSerial->begin(115200); // Default LTE shield baud rate
fona.begin(*fonaSerial); // Don't use if statement because an OK reply could be sent incorrectly at 115200 baud
Serial.println(F("Configuring to 9600 baud"));
fona.setBaudrate(9600); // Set to 9600 baud
fonaSerial->begin(9600);
if (!fona.begin(*fonaSerial)) {
Serial.println(F("Couldn't find modem"));
while(1); // Don't proceed if it couldn't find the device
}
*/
type = fona.type();
Serial.println(F("FONA is OK"));
Serial.print(F("Found "));
switch (type) {
case SIM800L:
Serial.println(F("SIM800L")); break;
case SIM800H:
Serial.println(F("SIM800H")); break;
case SIM808_V1:
Serial.println(F("SIM808 (v1)")); break;
case SIM808_V2:
Serial.println(F("SIM808 (v2)")); break;
case SIM5320A:
Serial.println(F("SIM5320A (American)")); break;
case SIM5320E:
Serial.println(F("SIM5320E (European)")); break;
case SIM7000:
Serial.println(F("SIM7000")); break;
case SIM7070:
Serial.println(F("SIM7070")); break;
case SIM7500:
Serial.println(F("SIM7500")); break;
case SIM7600:
Serial.println(F("SIM7600")); break;
default:
Serial.println(F("")); break;
}
// Print module IMEI number.
uint8_t imeiLen = fona.getIMEI(imei);
if (imeiLen > 0) {
Serial.print("Module IMEI: "); Serial.println(imei);
}
}
bool netStatus() {
int n = fona.getNetworkStatus();
Serial.print(F("Network status ")); Serial.print(n); Serial.print(F(": "));
if (n == 0) Serial.println(F("Not registered"));
if (n == 1) Serial.println(F("Registered (home)"));
if (n == 2) Serial.println(F("Not registered (searching)"));
if (n == 3) Serial.println(F("Denied"));
if (n == 4) Serial.println(F("Unknown"));
if (n == 5) Serial.println(F("Registered roaming"));
if (!(n == 1 || n == 5)) return false;
else return true;
}
void Flow()
{
count++; //Every time this function is called, increment "count" by 1
}
void FullSMS () {
char message3[20];
strcpy(message3, volBuff);
strcat(message3, text_message1);
pinMode(FONA_RST, OUTPUT);
digitalWrite(FONA_RST, HIGH); // Default state
pinMode(FONA_PWRKEY, OUTPUT);
pinMode(buttonPin, INPUT);
powerOn(true); // Power on the module
moduleSetup(); // Establish first-time serial comm and print IMEI
fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
while (!netStatus()) {
Serial.println(F("Failed to connect to cell network, retrying..."));
delay(2000); // Retry every 2s
}
Serial.println(F("Connected to cell network!"));
// Send a text to your phone!
if (!fona.sendSMS(phone_number, message3)) {
Serial.println(F("Failed to send text!"));
}
else {
Serial.println(F("Sent text alert!"));
}
}
void ColdSMS () {
char message[20];
strcpy(message, tempBuff);
strcat(message, text_message2);
pinMode(FONA_RST, OUTPUT);
digitalWrite(FONA_RST, HIGH); // Default state
pinMode(FONA_PWRKEY, OUTPUT);
powerOn(true); // Power on the module
moduleSetup(); // Establish first-time serial comm and print IMEI
fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
while (!netStatus()) {
Serial.println(F("Failed to connect to cell network, retrying..."));
delay(2000); // Retry every 2s
}
Serial.println(F("Connected to cell network!"));
// Send a text to your phone!
if (!fona.sendSMS(phone_number, message)) {
Serial.println(F("Failed to send text!"));
}
else {
Serial.println(F("Sent text alert!"));
}
}
void batSMS () {
char message2[20];
strcpy(message2, batBuff);
strcat(message2, text_message3);
pinMode(FONA_RST, OUTPUT);
digitalWrite(FONA_RST, HIGH); // Default state
pinMode(FONA_PWRKEY, OUTPUT);
powerOn(true); // Power on the module
moduleSetup(); // Establish first-time serial comm and print IMEI
fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
while (!netStatus()) {
Serial.println(F("Failed to connect to cell network, retrying..."));
delay(2000); // Retry every 2s
}
Serial.println(F("Connected to cell network!"));
// Send a text to your phone!
if (!fona.sendSMS(phone_number, message2)) {
Serial.println(F("Failed to send text!"));
}
else {
Serial.println(F("Sent text alert!"));
}
}
void printTemperature(DeviceAddress deviceAddress)
{
// method 1 - slower
//Serial.print("Temp C: ");
//Serial.print(sensors.getTempC(deviceAddress));
//Serial.print(" Temp F: ");
//Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit
// method 2 - faster
float tempC = sensors.getTempC(deviceAddress);
if (tempC == DEVICE_DISCONNECTED_C)
{
Serial.println("Error: Could not read temperature data");
return;
}
Serial.print("Temp C: ");
Serial.print(tempC);
Serial.print(" Temp F: ");
Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}
// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
if (deviceAddress < 16) Serial.print("0");
Serial.print(deviceAddress, HEX);
}
}
// Turn off the MCU completely. Can only wake up from RESET button
// However, this can be altered to wake up via a pin change interrupt
//void MCU_powerDown() {
// set_sleep_mode(SLEEP_MODE_PWR_DOWN);
// ADCSRA = 0; // Turn off ADC
// power_all_disable (); // Power off ADC, Timer 0 and 1, serial interface
// sleep_enable();
// sleep_cpu();
//}