Hello, guys. I'm using DS18B20 sensors to monitorize a freezer, but I'm having some issues. My temperatures are getting lower instead of getting high (becoming less negative) when I cut off the energy. Could you look at my code to check with everything is ok? Or should I suppose this is a library bug?
#include <OneWire.h>
#include <DallasTemperature.h>
#include "EmonLib.h"
EnergyMonitor emon1;
#define ONE_WIRE_BUS 10 // Conectar o pino central dos sensores ao pino 10 do Arduino
OneWire oneWire(ONE_WIRE_BUS);
// Setup a oneWire instance to communicate with any OneWire devices
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
DeviceAddress one_Thermometer = { 0x28, 0xFF, 0xAC, 0x17, 0x41, 0x04, 0x00, 0x45 };
DeviceAddress two_Thermometer = {0x28, 0xFF, 0x12, 0x1A, 0x43, 0x04, 0x00, 0x7A };
DeviceAddress three_Thermometer = { 0x28, 0xFF, 0x31, 0x18, 0x43, 0x04, 0x00, 0xCB };
int rede = 110.0;
//Pino analógico do arduino ligado ao sensor SCT
int pino_sct = 1;
int row=0;
int LABEL=1;
void setup(void)
{
// start serial port
Serial.begin(9600);
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(one_Thermometer, 10);
sensors.setResolution(two_Thermometer, 10);
sensors.setResolution(three_Thermometer, 10);
emon1.current(pino_sct, 29);
Serial.println("CLEARDATA");
Serial.println("LABEL, TIME, Sensor_1 (F), Sensor_2 (F), Sensor_3 (F),Current (A), Power (W)");
delay(1000);//Aguarda 1 seg antes de acessar as informações dos sensores
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Erro ao ler temperatura !");
}
else
{
Serial.print(tempC);
}
}
void loop(void)
{
row++;
double Irms = emon1.calcIrms(1480); //Calcula a corrente
sensors.requestTemperatures(); // requisita leituras dos sensores
Serial.print("DATA,TIME,");
printTemperature(one_Thermometer);
Serial.print(","); // pula pra próxima coluna
printTemperature(two_Thermometer);
Serial.print(","); // pula pra próxima coluna
printTemperature(three_Thermometer);
Serial.print(","); //pula pra próxima coluna
Serial.print(Irms); // Irms;
Serial.print(",");
Serial.print(Irms*rede);
Serial.print(",");
Serial.println(row);
if (row>15000)
{ row=0;
Serial.println("row, SET, 2");
}
delay(1000); // tempo de medidas
}