- Thu Jan 25, 2018 8:36 am
#198049
Hello:
I've purchased eight Temperature Sensor (SEN-11050). The power consumption is not listed on the product page. Could you please provide information for the following three questions?
(1) What is the power consumption for each sensor?
(2) I asume that they are low power consumption. Can they all wired together in order to use the 1-Wire Arduino library? Can they all share the one resistance and the 5V power output on board (Arduino YUN)?
(3) Can you take a look at my code? Any suggestions?
Thanks you so much.
I've purchased eight Temperature Sensor (SEN-11050). The power consumption is not listed on the product page. Could you please provide information for the following three questions?
(1) What is the power consumption for each sensor?
(2) I asume that they are low power consumption. Can they all wired together in order to use the 1-Wire Arduino library? Can they all share the one resistance and the 5V power output on board (Arduino YUN)?
(3) Can you take a look at my code? Any suggestions?
Thanks you so much.
Code: Select all
[/code][code]#include <DallasTemperature.h>
#include <OneWire.h>
#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
OneWire oneWire(6); // pin D6
DallasTemperature sensors(&oneWire);
float temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
// 1 min between grabbing data and logging it. 1000 ms (1 sec) * 60 = 60000 ms (60 sec)
#define LOG_INTERVAL 10000 // mills between entries
#define SYNC_INTERVAL 10000 // mills between calls to flush() - to write data to the card
uint32_t syncTime = 0; // time of last sync()
#define ECHO_TO_SERIAL 1 // echo data to serial port
#define WAIT_TO_START 0 // Wait for serial input in setup()
RTC_PCF8523 RTC; // define the Real Time Clock object
// digital pin 10 for the SD cs line for the data logging shield
const int chipSelect = 10;
// the logging file
File logfile;
void error(char *str)
{
Serial.print("error: ");
Serial.println(str);
while(1);
}
void setup() {
Serial.begin(115200);
sensors.begin();
#if WAIT_TO_START
Serial.println("Type any character to start");
while (!Serial.available());
#endif //WAIT_TO_START
// initialize the SD card - default chip D10 for SD datalogger shield
pinMode(10, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
// error("Card failed, or not present");
}
// create a new file
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++) {
filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if (! SD.exists(filename)) {
// only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
// connect to RTC
Wire.begin();
if (!RTC.begin()) {
logfile.println("RTC failed");
#if ECHO_TO_SERIAL
Serial.println("RTC failed");
#endif //ECHO_TO_SERIAL
}
}
void loop() {
DateTime now;
// delay for the amount of time we want between readings
delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
// fetch the time
now = RTC.now();
logfile.print(now.year(), DEC);
logfile.print("/");
logfile.print(now.month(), DEC);
logfile.print("/");
logfile.print(now.day(), DEC);
logfile.print(" ");
logfile.print(now.hour(), DEC);
logfile.print(":");
logfile.print(now.minute(), DEC);
logfile.print(":");
logfile.print(now.second(), DEC);
#if ECHO_TO_SERIAL
Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);
#endif //ECHO_TO_SERIAL
sensors.requestTemperatures();
temp1 = sensors.getTempCByIndex(0);
temp2 = sensors.getTempCByIndex(1);
temp3 = sensors.getTempCByIndex(2);
temp4 = sensors.getTempCByIndex(3);
temp5 = sensors.getTempCByIndex(4);
temp6 = sensors.getTempCByIndex(5);
temp7 = sensors.getTempCByIndex(6);
temp8 = sensors.getTempCByIndex(7);
logfile.print(", ");
logfile.print(temp1, 1); // top ST, one decimal place
logfile.print(", ");
logfile.print(temp2, 1); // bottom ST, one decimal place
logfile.print(", ");
logfile.print(temp3, 1); //
logfile.print(", ");
logfile.print(temp4, 1); //
logfile.print(", ");
logfile.print(temp5, 1); //
logfile.print(", ");
logfile.print(temp6, 1); //
logfile.print(", ");
logfile.print(temp7, 1); //
logfile.print(", ");
logfile.println(temp8, 1); //
#if ECHO_TO_SERIAL
Serial.print(", ");
Serial.print(temp1, 1); // top ST, one decimal place
Serial.print(", ");
Serial.print(temp2, 1); // bottom ST, one decimal place
Serial.print(", ");
Serial.print(temp3, 1); //
Serial.print(", ");
Serial.print(temp4, 1); //
Serial.print(", ");
Serial.print(temp5, 1); //
Serial.print(", ");
Serial.print(temp6, 1); //
Serial.print(", ");
Serial.print(temp7, 1); //
Serial.print(", ");
Serial.println(temp8, 1); //
#endif //ECHO_TO_SERIAL
// write data to disk
if ((millis() - syncTime) < SYNC_INTERVAL) return;
syncTime = millis();
logfile.flush();
}