Quantcast
Channel: ThingSpeak IoT Community - Forum: Arduino
Viewing all articles
Browse latest Browse all 172

Smitty on Multiple 1 Wire Bus on Digital Pin ....

$
0
0

How best to achieve this ...

Not getting a successful compile from the below sketch ....

Very much a newb with ThingSpeak and Arduino ... 

/* Arduino Mega 2560 WiFi Weather Station

* July 2016 By John D Smith ZL4CO
* */

 

#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ThingSpeak.h>

byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// assign an IP address for the controller:
IPAddress ip(0.0.0.0);

// Initialize Arduino Ethernet Client
EthernetClient client;

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

// ThingSpeak Settings
unsigned long myChannelNumber = secret;
const char * myWriteAPIKey = "";

// There are currently 2 x Trial DS18B20 "1-Wire" digital Temperature sensors.

// 1 Wire Data wire is plugged into Digital pin 12 on the Arduino
#define ONE_WIRE_BUS 12

// 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 the 1-Wire temp sensors.

DeviceAddress Temp1 = { 0x28, 0xFF, 0x7F, 0x71, 0x2C, 0x04, 0x00, 0x79 };
DeviceAddress Temp2 = { 0x28, 0xEC, 0xAB, 0x1E, 0x00, 0x00, 0x80, 0xA8 };

void setup(void)

{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(Temp1, 10);
sensors.setResolution(Temp2, 10);

ThingSpeak.begin(client);
}

void printTemperature(DeviceAddress deviceAddress)
{

float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}

void loop (void)
{
delay(10000);*/
Serial.print("Getting temperatures...

");
sensors.requestTemperatures();

Serial.print("Temp 1 is: ");
printTemperature(Temp1);
Serial.print("

");
Serial.print("Temp 2 is: ");
printTemperature(Temp2);
Serial.print("

");

Serial.print("

");

delay(200);
}

Cry
//Update the ThingSpeak Channel

float pinVoltage = sensors.(Temp1) ;
ThingSpeak.setField(1,pinVoltage);
pinVoltage = sensors.(Temp2)
ThingSpeak.setField(2,pinVoltage);

// Write the fields that you've set all at once.
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

Serial.print("Temperatures Uploaded to Cloud...

");
delay(80000);

It is in this part here I am not sure how to Access my Temp1 and Temp2 values for ThingSpeak


Viewing all articles
Browse latest Browse all 172

Trending Articles