// Global variables
char buf[64]; // buffer for incoming data
double temp=0,
humidity=0,
pressure=0,
windspeed=0,
lipoVoltage=0,
lipoCurrent=0,
solarVoltage=0,
solarCurrent=0,
loadVoltage=0,
loadCurrent=0;
void setup()
{
Serial1.begin(115200);
Spark.variable("temp", &temp, DOUBLE);
Spark.variable("humidity", &humidity, DOUBLE);
Spark.variable("pressure", &pressure, DOUBLE);
Spark.variable("windspeed", &windspeed, DOUBLE);
Spark.variable("lipoVoltage", &lipoVoltage, DOUBLE);
Spark.variable("lipoCurrent", &lipoCurrent, DOUBLE);
Spark.variable("solarVoltage", &solarVoltage, DOUBLE);
Spark.variable("solarCurrent", &solarCurrent, DOUBLE);
Spark.variable("loadVoltage", &loadVoltage, DOUBLE);
Spark.variable("loadCurrent", &loadCurrent, DOUBLE);
}
void loop()
{
int x, avail;
char *token;
const char sep[2] = ",";
if ((avail = Serial1.available()) >= 20) // wait until we get a full buffer
{
for (x=0; x < avail; x++)
buf[x] = Serial1.read();
buf[x] = '\0'; // string must be null terminated
token = strtok(buf, sep); // pick off first token = packet type
if (token != NULL)
{
if (strncmp(token, "WND", 3) == 0) // windspeed packet
{
token = strtok(NULL, sep);
if (token != NULL)
windspeed = (float) atof(token); // extract windspeed
Serial1.print("wind");
}
else if (strncmp(token, "THP", 3) == 0) // temperature, humidity, pressure packet
{
token = strtok(NULL, sep);
if (token != NULL)
temp = (float) atof(token); // extract temperature
token = strtok(NULL, sep);
if (token != NULL)
humidity = (float) atof(token); // extract humidity
token = strtok(NULL, sep);
if (token != NULL)
pressure = (float) atof(token); // extract pressure
}
else if (strncmp(token, "ELC", 3) == 0) // electrical packet
{
token = strtok(NULL, sep);
if (token != NULL)
lipoVoltage = (float) atof(token); // extract lipoVoltage
token = strtok(NULL, sep);
if (token != NULL)
lipoCurrent = (float) atof(token); // extract lipoCurrent
token = strtok(NULL, sep);
if (token != NULL)
solarVoltage = (float) atof(token); // extract solarVoltage
token = strtok(NULL, sep);
if (token != NULL)
solarCurrent = (float) atof(token); // extract solarCurrent
token = strtok(NULL, sep);
if (token != NULL)
loadVoltage = (float) atof(token); // extract loadVoltage
token = strtok(NULL, sep);
if (token != NULL)
loadCurrent = (float) atof(token); // extract loadCurrent
}
}
}
}
I painted it with several coats of off-white and by placing a commercial temp sensor next to it I found that in direct sun of 90+ degrees it reduces the reported temp around 15-20 degrees. The BME280 is hanging inside around the 3rd bowl from the top. There is enough room for air to blow throw but hopefully keep out the rain. The top is solid and the rest of the bowls have a 2" cutout down the middle. Three 1/4" threaded rods and 1/4" tubing for spacers complete the unit.This weekend I saw a weatherstation where someone had enclosed his THP sensor in a cedar box with louvers in the side and an RV Solar powered vent in the sloped top. The owner claimed that he had good accuracy measuring the outside ambient temperature without 'environmental' issues (like blizzards). The vent looked similar to this one: http://www.etrailer.com/Enclosed-Trailer-Parts/Ultra-Fab-Products/UF53-945001.html but was around 4" diameter, for a sewer pipe, I believe.
At some point down the road when I'm finished adding onto the system I will probably get more serious about long-term data storage and start uploading to the cloud into some type of database.
Converted yesterday to ATC on the indoor and outdoor units. As Felix mentioned there were few changes required. I had been using just send() with no ACK but the change was trivial. I set my threshold to -85 and watched the RSSI drop from -27 to -85 in about 6 transmissions.
Hopefully in the next few days I'll have a chance to take some measurements and see how much current/battery life I'm saving.
The best s/w feature for me is I can do OTA by keeping the radio alive for 2 seconds after the last set of three packet deliveries are made. It usually takes one or two tries to time the OTA but it works quite well.Interesting, So you don't use the Listen mode to wake for OTA?
No problems. The combination of the 4400 mAh battery and the 6"x6" solar panel kept the battery fully charged.What part of the country are you? How many sunny days a year or, more important, how many sustained cloudy days?
CREATE TABLE `sensorDataTemp` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`houseId` int(11) DEFAULT '-999',
`sensorId` int(11) DEFAULT '-999',
`temperature` float DEFAULT '-999',
`humidity` float DEFAULT '-999',
`soilHumidity` int(11) DEFAULT '-999',
`light` int(11) DEFAULT '-999',
`pressure` float DEFAULT '-999',
`windSpeed` float DEFAULT '-999',
`windDirection` int(11) DEFAULT '-1',
`windSpeedAvg` float DEFAULT '-999',
`windDirectionAvg` int(11) DEFAULT '-1',
`rainForPeriod` float DEFAULT '-999',
`windGustForPeriod` float DEFAULT '-999',
`batteryLevel` float DEFAULT '0',
`timestamp` int(11) DEFAULT '0',
`timestampServer` int(11) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;