DS18B20 adding correction celsius to result?


#1

I’m measuring the waterflow temps of my heatpump.

But for good reasons I cant measure it inside the cobber tubes, but only from the outside.
My heatpump can show me the momentary temps, and I can see that my sensors are about 7 Celsius too low.

Thats why I would like to add like 7 celsius to the result thats being send to Cayenne, but I cant figure out how to do that (again im not a coding guy).

Anyone have a good idea where, in the code, I should put in something like *7…

// Virtual Pin of the DS18B20 widget.
#define VIRTUAL_PIN1 V1

// Digital pin the DS18B20 is connected to. Do not use digital pins 0 or 1 since those conflict with the use of Serial.
const int tmpPin1 = 7;

OneWire oneWire1(tmpPin1);

DallasTemperature sensors1(&oneWire1);

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "xxxx";

void setup()
{
    Serial.begin(9600);
    Cayenne.begin(token);
    sensors1.begin();
}

void loop()
{
    Cayenne.run();
}

// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN1)
{
    // Send the command to get temperatures.
    sensors1.requestTemperatures();
    // This command writes the temperature in Celsius to the Virtual Pin.
    Cayenne.celsiusWrite(VIRTUAL_PIN1, sensors1.getTempCByIndex(0));
}

#2

Change this line to

Cayenne.celsiusWrite(VIRTUAL_PIN1, sensors1.getTempCByIndex(0) + 7);


#3

Thx alot, wil try tonight


#4

@tvj,

I wanted to formally welcome you to the Cayenne community. Out of curiosity, what is the heat pump for? Water in your house? Some component of a larger project you have in mind?


#5

thx, by the way it worked, adding celsius to the upload vaiable.

Rsigel, here’s a little info of my project:

##home heating and energy monitoring##

About This Project (Work in process)
I have an Air-to-water heat pump, that supplys a water based floorheating system.

At this point I want to monitor different temperatures and the energy consumption, in order to make it more cost effective, and because its fun to monitor.

At the moment I’m using a ardunino with a ethernet shield.

Goal one (almost done)

  • Measure temperature of water flow to the floors.
  • Measure temperature of returning waterflow from the floors.
  • Measure temperature of waterboiler (water for bath etc.)
  • Measure outside temperature (big influence on energy use)

Goal two (in progress)

  • Measure current use from my bi-powermeter, either by a luminosity sensor or by the digital output.

Goal three (when the DHT sensors are working with cayenne)

  • measure temperature, and hopefully humidity in every room (DHT11 sensor)

Goal four - the big finish

  • control the floorheating system themostats based on the readings from the room sensors.

Goal five - extra features
The room sensors could also be part of a burglar alarm, with pir sensors.

What’s Connected

Goal one

  • Arduino uno with a ethernet shield W5100
  • 3x DS18B20 sensors
  • 1x LDR luminosity sensor
    Still needs a outdoor sensor

Goal two
Still needs to get the luminosity sensor to log the current use correct and not just showing when the Current powermeter blinks.
If the sensor doesnt do the work ok I might try to get the signal from the digital output of the Currentmeter.
And I think I need some other graph types than those available in cayenne at the moment.

Goal three
Think I will use those arduino mcu wifi boards and a DHT11 or a DHT22 sensor to get both temperature and humidity.
looking forward to this.

Goal four
Thinking of some sort of controlling 10 relays to trigger the 10 “egg” thermostats that regulate the heated waterstring for every room.


#6

Just to resurrect this thread briefly. I’m very new to Raspberry pi and Cayenne for forgive me.

I too wish to add a correction figure to the temperature displayed and am happy to modify the code as above.

Newbie question: How do I access the code itself? I can open terminal (mac user) and access the command prompt - but not sure how to find and edit the code I need?

Many thanks


#7

Welcome to Cayenne!

This thread is for using an Arduino to send values to Cayenne, but it’s definitely possible to send the correct format using a raspberry Pi too. To answer your question I first have to ask, how did you install Cayenne? the answer will depend on what connection method you are using.


#8

Ooops sorry.

Regarding install. I first installed a while ago. I had Rasbian (debian) in the pi and installed Cayenne onto the pi via the Cayenne mobile iOS app. I have since updated rasbian to Jesse.

Hoe this is what you meant.


#9

Sound like you are using the agent to connect. If so you should be able to click the settings button (cog) in the top right of the widget and then change the unit.


#10

Yes. I can switch between C, F and K


#11

Just to be clear - I’m not wanting to switch temperature scales. I’m aware that my sensor consistently under reads by x degree C. I want to add in a correction factor so the displayed temperature is a true reading.


#12

Sorry, I misunderstood. While using the agent connection method there is no way to easily add in a correction. You can see the source code here, but I have not looked at it at all to give any suggestions.