Already built mine last year. Running same equipment above at feed:
https://cosm.com/feeds/70075
Here is my Arduino code:
// acefaser's beer code
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { YOUR BITE MAC };
byte ip[] = { YOUR IP };
char server[] = "api.cosm.com"; // name address for Cosm API
EthernetClient client;
char strURL[150]; //define strURL
int t1,t2,t3; // variables for temps
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// cosm acct info
#define APIKEY "enter your key here" // replace your Cosm api key here
#define FEEDID 70075 // replace your feed ID
#define USERAGENT "Temp" // user agent is the project name
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// 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 insideThermometer = { 0x28, 0x02, 0x3D, 0xAF, 0x03, 0x00, 0x00, 0xCF };
DeviceAddress outsideThermometer = { 0x28, 0x13, 0x35, 0xAF, 0x03, 0x00, 0x00, 0x9D };
DeviceAddress dogHouseThermometer = { 0x28, 0x07, 0x32, 0xAF, 0x03, 0x00, 0x00, 0x4B };
void setup() {
// start serial port:
Serial.begin(9600);
// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(1Thermometer, 10);
sensors.setResolution(2Thermometer, 10);
sensors.setResolution(3Thermometer, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC ));
}
}
void loop()
{
sensors.requestTemperatures();
if (!client.connected()) {
Serial.begin(9600);
// give the ethernet module time to boot up:
delay(1000);
Ethernet.begin(mac, ip);
}
float tempC1 = sensors.getTempC(1Thermometer);
float tempF1 = (tempC1 * 9.0 / 5.0) + 32.0;
int t1 = tempF1;
Serial.print(tempF1);
Serial.print("\n");
float tempC2 = sensors.getTempC(2Thermometer);
float tempF2 = (tempC2 * 9.0 / 5.0) + 32.0;
int t2 = tempF2;
Serial.print(tempF2);
Serial.print("\n");
float tempC3 = sensors.getTempC(3Thermometer);
float tempF3 = (tempC3 * 9.0 / 5.0) + 32.0;
int t3 = tempF3;
Serial.print(tempF3);
Serial.print("\n");
// string the data together
String dataString = "1,";
dataString += t1;
dataString += "\n2,";
dataString += t2;
dataString += "\n3,";
dataString += t3;
sendData(dataString);
}
// this method makes a HTTP connection to the server:
void sendData(String thisData) {
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.cosm.com");
client.print("X-ApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);
client.print("Content-Length: ");
client.println(thisData.length());
// last pieces of the HTTP PUT request:
client.println("Content-Type: text/csv");
client.println("Connection: close");
client.println();
// here's the actual content of the PUT request:
client.println(thisData);
Serial.println(thisData);
Serial.println("Temps Uploaded Successfully");
delay(30000);
}
else {
// if you couldn't make a connection:
Serial.println("connection failed");
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
}
// end