Pages: 1 2 3 [4] 5 6   Go Down
Author Topic: [SOLVED]Logging multiple temp sensors questions(step by step)  (Read 5483 times)
0 Members and 1 Guest are viewing this topic.
Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We've tried about everything else, so try switching the two function calls. Call getPage() first, then logFile().
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 171
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Already tried...in that case all the log action is failed...I don't believe this smiley-confuse should we need to modify pinmodes or input/output?
« Last Edit: December 04, 2012, 01:48:56 am by vespapierre » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 171
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anybody havy any idea about this issue? smiley-confuse
Tim thanks a lot or you!
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI: I do not believe it is the SD and w5100 causing the problem. I use these two together all the time, and they work good together at the same time. I use them for a FTP passive client to transfer files to and from my FTP/Apache server.

Maybe try removing all but one of the other devices, and see where it starts working again.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 171
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have lost my faith a bit...Tim you mean I should change other devices to output and put it to high?
Can you send me yiur code just to check? Maybe i should change my concept and send csv instead of sending file...
I don't beleive nobody has tried a same project... smiley-confuse
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are in new territory getting that many devices working on the same Arduino. Maybe it is the power supply? Try disconnecting the other hardware and see if the code still works. It won't save/send the correct readings, but may help determine the cause of the SD fail. It uses memory and power when active.

edit: You are using:
SD
w5100
RTC
3 temperature sensors.

I've never tried that many devices before.
« Last Edit: December 04, 2012, 07:59:02 am by SurferTim » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 171
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

they are on the same shield smiley-sad I cannot disconnect them...maybe is it possible in the code?
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

All on the same shield? That is unusual.

Try using just the SD, w5100 and RTC part of the code. Use dummy values for the temperature sensors. Does that work?

Without having all the equipment here, it is hard to troubleshoot.

Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have lost my faith a bit..Maybe i should change my concept and send csv instead of sending file...


I think that would be a really good idea. I would not have thought it possible to send a file, and I can't see the point of it, even if it is.

It is not that likely that there is a hardware problem. It is most likely the code - and, perhaps even more likely, the approach to the job.

The SD and ethernet work fine together with standard code. Indeed, I am using anEtherTen, which has SD and Ethernet built in. I have to admit that did a lot for my confidence. My clock, sensors and bluetooth are on a shield on top. My only problem has been with the LCD keypad shield. It clashed with the SD and I was obliged to run a jumper across the lower shield.

You should not loose faith. There are others doing similar work

Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 171
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have tried many solutions...but not working...what should I change? where to go?? smiley-confuse
at first: with a different concept uploading wa the first, and then came sd logging...sh*t...
second concept: different sensor reading->sd logging-> sending to the web...sh*t... smiley-sad

I think SD log is fine. But, if not working with the getpage() function, than what? send like char? before sending to the web put to output and high the sd ? aah...how to send csv to thingspeak for example?
Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have tried many solutions...but not working...what should I change? where to go?? smiley-confuse

We have been down this road before. The work we are doing is more or less the same, isn't it? What you should change is the code. Feel free to use mine. The reason why I say this is that my code works and yours doesn't. It gives cosm what it wants - datastreams.

Quote
at first: with a different concept uploading wa the first, and then came sd logging...sh*t...
second concept: different sensor reading->sd logging-> sending to the web...sh*t... smiley-sad

We've been here before too. I think you are missing the concept of cosm. Cosm does the data logging, not you. Your job is to feed cosm , and you don't need the SD or the clock to do that. By all means log the data yourself for backup purposes but that is a different job.

Quote
I think SD log is fine. But, if not working with the getpage() function, than what? send like char? before sending to the web put to output and high the sd ? aah...how to send csv to thingspeak for example?

You know more about thingspeak than I do, but I understand that the essential purpose is the same as cosm - real-time graph display from a data feed, and that feed is also used to produce a time-stamped csv datalog. And, in the light of that, sending a log from the SD is not fine, it's a dumb idea, and might not be allowed.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 171
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to have sd logging in case going offline...all I have to find where and how to put that sd codes...Sd involved in the concept...
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tested how much free memory you have (or, more likely, don't have)?

The SD library uses 512+ bytes of SRAM. That's 1/4 of the SRAM on a 328-based Arduino.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 171
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Paul,

still not...how can I do that? I would be hard to loose all the free memory of a Mega 2560.
Logged

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to have sd logging in case going offline..

That's fine,  I am doing the same thing, but that's not the same as sending the SD file to cosm.

Quote
.all I have to find where and how to put that sd codes...Sd involved in the concept...

The code below is about 36k. I am currently in the throes of moving to Mega 2560. While I'm sure this can be written more elegantly, it probably won't save enough to squeeze into a Uno.

Code:
/*
/*From cosm library example and lifts from a lot of others
 particularly from Stanley in Kuala Lumpur.
 Use your own DS18B20 addresses, keys etc.
 
 */
#include <LiquidCrystal.h>
#include <SD.h>
#include <string.h>
#include "RTClib.h"

RTC_DS1307 RTC;
File myFile;
char filename[] = "00000000.CSV";
#include "Wire.h"
#define DS1307_ADDRESS 0x68

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Cosm.h>

byte InThermo[8] =  {
  0x28, 0x69, 0xC2, 0xB0, 0x03, 0x00, 0x00, 0X9F};
byte OutThermo[8] = {
  0x28, 0x7A, 0x8B, 0xC0, 0x03, 0x00, 0x00, 0x2F};
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

char cosmKey[] = "l6ab.....................................0Zz0g";

int sensorPin = 3;
int  second, minute, hour, weekDay, monthDay, month, year;
float InTemp, OutTemp;

// Define the strings for our datastream IDs
char sensorId0[] = "InThermo";
char sensorId1[] = "OutThermo";
//char sensorId2{} = "DrainThermo"

const int bufferSize = 100;
char bufferValue[bufferSize]; // enough space to store the string we're going to send

CosmDatastream datastreams[] = {
  CosmDatastream(sensorId0, strlen(sensorId0), DATASTREAM_FLOAT),
  CosmDatastream(sensorId1, strlen(sensorId1), DATASTREAM_FLOAT),
  //    CosmDatastream(sensorId2, strlen(sensorId2), DATASTREAM_FLOAT),
};

// Finally, wrap the datastreams into a feed
CosmFeed feed(83153, datastreams, 2 /*put your number here */);

EthernetClient client;
CosmClient cosmclient(client);

LiquidCrystal lcd(8,9,16,5,6,7);

void setup() {

  Wire.begin();
  Serial.begin(9600);
  delay(300);//Wait for newly restarted system to stabilize
  Serial.print("Temperature measurement");
  Serial.print("Initializing SD card...");

  pinMode(10, OUTPUT);

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }

  Serial.println("initialization done.");

  sensors.setResolution(InThermo, 12);
  sensors.setResolution(OutThermo, 12);

  Serial.println("Starting multiple datastream upload to Cosm...");
  Serial.println();

  while (Ethernet.begin(mac) != 1)
  {
    Serial.println("Error getting IP address via DHCP, trying again...");
    delay(10000);
  }
}

void loop() {

  GetClock();
  PrintDate;

  sensors.requestTemperatures();
  Serial.println("Read sensor value ");

  InTemp = (sensorValue(InThermo));
  OutTemp = (sensorValue(OutThermo));  
  // float Drain = (sensorValue(DrainThermo));  

  datastreams[0].setFloat(InTemp);
  datastreams[1].setFloat(OutTemp);

  Serial.println(datastreams[0]);
  Serial.println(datastreams[1]);
  /*
  datastreams[2].setFloat(DrainTemp);
   Serial.println(datastreams[2].getFloat(DrainTemp));
   */
  // LCD stuff will go here

  if (second == 0 || second == 10 || second == 20 || second == 30 || second == 40 || second == 50)
  {
    myFile = SD.open("data.csv", FILE_WRITE);//<<<<<<<<<<<<< OPEN
    WriteSD;
    int ret=0;
    delay(200);// Delay... must not be too short.
    Serial.println("Uploading it to Cosm");
    ret = cosmclient.put(feed, cosmKey);    // SEND FEED TO COSM
    Serial.print("cosmclient.put returned "); // tell us about it
    Serial.println(ret);                      // pray to God it says 200
    myFile.println();
    myFile.close();//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CLOSE
  }
    delay(200);// Delay... must not be too short.
    Serial.println();
    delay(800);
}

//sensorValue function
float sensorValue (byte deviceAddress[])
{
  float tempC = sensors.getTempC (deviceAddress);
  return tempC;
}


byte bcdToDec(byte val)  {
  // Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

void GetClock(){
  // Reset the register pointer
  Wire.beginTransmission(DS1307_ADDRESS);
  byte zero = 0x00;
  Wire.write(zero);
  Wire.endTransmission();
  Wire.requestFrom(DS1307_ADDRESS, 7);

  second = bcdToDec(Wire.read());
  minute = bcdToDec(Wire.read());
  hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
  weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
  monthDay = bcdToDec(Wire.read());
  month = bcdToDec(Wire.read());
  year = bcdToDec(Wire.read());
}

void PrintDate () {
  Serial.print(monthDay);
  Serial.print("/");
  Serial.print(month);
  Serial.print("/");
  Serial.print(year);
  Serial.print("     ");
  Serial.print(hour);
  Serial.print(":");
  Serial.print(minute);
  Serial.print(":");

  if (second < 10)
  {
    Serial.print("0");
  };

  Serial.print(second);
  Serial.print("         ");
}

void WriteSD () {

  myFile.print(monthDay);
  myFile.print("/");
  myFile.print(month);
  myFile.print("/");
  myFile.print(year);
  myFile.print(",  ");
  myFile.print(hour);
  myFile.print(":");
  myFile.print(minute);
  myFile.print(":");
  myFile.print(second);
  myFile.print(",         ");

  myFile.print(InTemp);
  myFile.print(",    ");
  myFile.print(OutTemp);
  myFile.print(",    ");
}
« Last Edit: December 04, 2012, 10:24:48 am by NickPyner » Logged

Pages: 1 2 3 [4] 5 6   Go Up
Jump to: