Somehow I have fumbled across a solution. Even went so far as to go back and start reading the build process, and came across this little statement:
To use tabs with a .h extension, you need to #include it (using "double quotes" not ).
Well, ALL my #include statements had a .h extension, so I made them quotes instead of brackets. I have to admit I don't think that fixed anything but I thought it might bear mentioning just in the interest of full disclosure.
I moved things around a little bit in the data recording process. I moved the SD portion out of the if connected loop, and made it just after the completion of the transmission1 array. I also moved the start ethernet function to AFTER the SD card write. You already have the code from above. Here are the portions I changed:
#include "SPI.h"
#include "Ethernet.h"
#include "Wire.h"
#include "SD.h"
#include "MemoryFree.h"
#include "Adafruit_AM2315.h"
#include "DHT.h"
#include "RTClib.h"
////And my main update loop.....
if (currentTime.unixtime() - lastConnectionTime.unixtime() > updateEmoncmsInterval)
{
for (int i = 0; i < NUM_DHTS; i++)
{
// Read value from DHT Sensor
float h = dhtList[i]->readHumidity();
float t = dhtList[i]->readTemperature();
if (isnan(t) || isnan(h))
{
h=0.0;
t=0.0;
}
dtostrf(h, 6, 1, numhum[i]);
dtostrf(t, 6, 1, numtemp[i]);
trim(numhum[i]);
trim(numtemp[i]);
strcat(transmission1,numtemp[i]);
strcat(transmission1, ",");
strcat(transmission1, numhum[i]);
strcat(transmission1, ",");
Serial.print(i); Serial.print(" ");
Serial.print((char*)numhum[i]); Serial.print(" ");
Serial.println((char*)numtemp[i]);
memset(numhum[i], '\0', 6);
memset(numtemp[i], '\0', 6);
}
float eh = am2315.readHumidity();
float et = am2315.readTemperature();
if (isnan(et) || isnan(eh))
{
memset(exthum, '\0', 6);
memset(exttemp, '\0', 6);
}
else
{
dtostrf(et, 6, 1, exttemp);
dtostrf(eh, 6, 1, exthum);
trim(exthum);
trim(exttemp);
}
Serial.print("Ext Temp: ");
Serial.println(exttemp);
Serial.print("Ext Humidity: ");
Serial.println(exthum);
strcat(transmission1,exttemp);
strcat(transmission1,",");
strcat(transmission1,exthum);
Serial.print(F("At the end of DHT read freeRam ="));
Serial.println(freeRam());
//Update SD card
dataFile = SD.open(filename, FILE_WRITE);
saveSDtime();
dataFile.println(transmission1);
delay(1000);
dataFile.close();
// Update Emoncms
startEthernet();
if(!client.connected())
{
Serial.println(transmission1);
updateEmoncms(transmission1, writeNode);
delay(1000);
client.stop();
Serial.println(F("Sent Transmission"));
}
memset(transmission1, '\0', 300);
}
PaulS- I tried getting rid of my wrong use of the typedef (which I have to admit, I don't think it's wrong and it works), and using just a standard char* array for the storage of my readings, but the controller just sat there and continuously reset itself. Please expand on how you would have made an array such as I use for storing the DHT readings.
Tim