Hello,
I recently posted this same question in the programming guidance forum and realized that it was probably the incorrect sport for the question so I decided to post it here.
I'm a definite rookie with this stuff so please bare with me. I have an arduinio Uno with an ethernet shield connected up to two DS18B20 temperature sensors. I have been able to successfully get the temperature reading from both sensors and can verify it on my serial monitor. I have also successfully uploaded data to my pachube account. My problem is combining both steps together.
If I take the temp reading and assign it to a variable and try to upload it's getting an error somewhere when uploading the data. If I take out the variable and just specify a static value it uploads fine.
Can someone please help me identify where my issue is?
Here is my code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include "ERxPachube.h"
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0xCC, 0xAC, 0xBE, 0xEF, 0xFE, 0x91 }; // make sure this is unique on your network
byte ip[] = { 192, 168, 168, 250 }; // no DHCP so we set our own IP address
#define PACHUBE_API_KEY "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // fill in your API key PACHUBE_API_KEY
#define PACHUBE_FEED_ID xxxx // fill in your feed id
// I could not get parasite power to work, so I used 3 pins...
OneWire oneWireA(3);
OneWire oneWireB(2);
DallasTemperature sensorsA(&oneWireA);
DallasTemperature sensorsB(&oneWireB);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress KeezerTemp = { 0x28, 0x03, 0x0D, 0xB7, 0x03, 0x00, 0x00, 0x58 };
float tempA;
float tempB;
ERxPachubeDataOut dataout(PACHUBE_API_KEY, PACHUBE_FEED_ID);
void PrintDataStream(const ERxPachube& pachube);
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip);
sensorsA.begin();
dataout.addData(0);
dataout.addData(1);
dataout.addData(2);
}
void loop() {
sensorsA.requestTemperatures();
tempA = sensorsA.getTempFByIndex(0);
sensorsB.requestTemperatures();
tempB = sensorsB.getTempFByIndex(0);
Serial.println("+++++++++++++++++++++++++++++++++++++++++++++++++");
dataout.updateData(0,(tempA));
dataout.updateData(1, (tempB));
int status = dataout.updatePachube();
Serial.print("sync status code <OK == 200> => ");
Serial.println(status);
PrintDataStream(dataout);
delay(5000);
}
void PrintDataStream(const ERxPachube& pachube)
{
unsigned int count = pachube.countDatastreams();
Serial.print("data count=> ");
Serial.println(count);
Serial.println("<id>,<value>");
for(unsigned int i = 0; i < count; i++)
{
Serial.print(pachube.getIdByIndex(i));
Serial.print(",");
Serial.print(pachube.getValueByIndex(i));
Serial.println();
}
}
And here is some sample of the output shown from the serial monitor:
+++++++++++++++++++++++++++++++++++++++++++++++++
sync status code <OK == 200> => 1
data count=> 3
<id>,<value>
0,71.712494 _
1,71.599998 _?
2,
+++++++++++++++++++++++++++++++++++++++++++++++++
sync status code <OK == 200> => 1
data count=> 3
<id>,<value>
0,71.712494 _?
1,71.599998 _?
2,
+++++++++++++++++++++++++++++++++++++++++++++++++
sync status code <OK == 200> => 1
data count=> 3
<id>,<value>
0,71.599998 _?
1,71.599998 _?
2,
+++++++++++++++++++++++++++++++++++++++++++++++++
sync status code <OK == 200> => 1
data count=> 3
<id>,<value>
0,71.599998 _?
1,71.599998 _?
2,
+++++++++++++++++++++++++++++++++++++++++++++++++
please advise.
Thanks,
Brad