Planning and buying for Datalogger for heating boiler, thermal storage tank.

The MAX31850 board sold by Adafruit (when it's in stock) has the level shifting built in.

When you need level shifting, mosfet-based level shifters are pretty easy to work with. The signals connected to the "A" side come out the "B" side at the higher voltage and vice-versa. The only other things you need are the low voltage (e.g. 3.3V) connected to the "LV" pin and the 5V to the HV pin, and then the ground wires.

Yes MAX31850 from adafruit is level shifted on VIN but not data, so what happens if I send 5V high on DATA? Do I need level shift on data line to communicate?

The problem is the stock or the price in almost all stores.

I'm a little afraid to use the analog solution because of noise witch is plenty in boiler room, Circulation pump *2, fan and auger motor and the electronics in the burner might be noisy.

if I have a float 24.15° C and only want 24° C how do I get rid of the .15 the best way and store it in a Int or byte?

Assign it to your int or byte variable - the fractional part will be dropped. You might want to add 0.5 to the float as you assign it so it will round instead.

I cant get my around tracking the edge on a switch, can someone please explain it for me with some code and comments whats happening in the code?

I have tested this code around 6 hours now and it seems to work fine.

#include <SPI.h>

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

#include <SD.h>

#include <EthernetServer.h>
#include <util.h>
#include <Ethernet.h>
#include <Dns.h>
#include <EthernetUdp.h>
#include <Dhcp.h>
#include <EthernetClient.h>

#include <LiquidCrystal.h>


  The circuit:

 * LCD RS pin to digital pin 27*2*

 * LCD Enable pin to digital pin 28*3*

 * LCD D4 pin to digital pin 32*4*

 * LCD D5 pin to digital pin 31*5*

 * LCD D6 pin to digital pin 30*6*

 * LCD D7 pin to digital pin 29*7*

 * LCD R/W pin to ground

 * 10K resistor:

 * ends to +5V and ground

 * wiper to LCD VO pin (pin 3)

LiquidCrystal lcd(27, 28, 32, 31, 30, 29); // Testing might be switched for serial.

//  Start Number Storage
byte TempBoiler = 0; //DS18B20
byte TempTopTank = 0; //DS18B20
byte TempBottomTank = 0; //DS18B20
byte TempSupplyLine = 0; //DS18B20
byte TempReturnLine = 0; //DS18B20
int TempOutSide = 0; //DS18B20 needs to handle -value
byte TempInSide = 0; //DS18B20
int TempFire = 0; //MAX31850+K thermocouple
int TempSmoke = 0; //MAX31850+K thermocouple
int AugerTurnCount = 0; // Feedauger turns
int FuelLevel = 0; // Level in fuel silo
float test = 0;
int rounds = 0;
// End Number Storage

const int trigger = 22;
const int echo = 23;
float distance;
//FuelLevel End

// AugerTurnCount Start
//const int  TurnSwitch = 53;    // the pin that the switch is attached to
const int  buttonPin = 53;    // the pin that the pushbutton is attached to
const int ledPin = 13;       // the pin that the LED is attached to

// Variables will change:
//int TurnSwitchCounter = 0;   // counter for the number of switch presses
//int TurnSwitchState = 0;         // current state of the switch
//int TurnSwitchLastState = 0;     // previous state of the switch
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

//AugerTurnCount End

//Temperature gathering
#define ONE_WIRE_BUS 10 // Data wire is plugged into pin ? on the Arduino
OneWire oneWire(ONE_WIRE_BUS);// Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire);// Pass our oneWire reference to Dallas Temperature.
// Assign the addresses of your 1-Wire temp sensors. Inspration from
DeviceAddress insideTemp = { 0x28, 0xFF, 0xA0, 0x36, 0x66, 0x14, 0x03, 0x7B };
DeviceAddress outsideTemp = { 0x28, 0xFF, 0x41, 0xB6, 0x66, 0x14, 0x02, 0xEB };
DeviceAddress supplyTemp = { 0x28, 0xFF, 0x51, 0x3E, 0x66, 0x14, 0x03, 0x0C };
DeviceAddress returnTemp = { 0x28, 0xFF, 0xA9, 0x37, 0x66, 0x14, 0x03, 0x07 };
DeviceAddress boilerTemp = { 0x28, 0xFF, 0xF3, 0xA7, 0x66, 0x14, 0x02, 0x90 };
DeviceAddress topTemp = { 0x28, 0xFF, 0x4C, 0x36, 0x66, 0x14, 0x03, 0x80 };
DeviceAddress bottomTemp = { 0x28, 0xFF, 0xFE, 0x38, 0x66, 0x14, 0x03, 0x59 };
//DeviceAddress fireTemp = { 0x28, 0xFF, 0x51, 0x3E, 0x66, 0x14, 0x03, 0x0C }; NEED UPDATE
//DeviceAddress smokeTemp = { 0x28, 0xFF, 0x51, 0x3E, 0x66, 0x14, 0x03, 0x0C }; NEED UPDATE

void setup() {
  lcd.begin(16, 2);
//FuelLevel Start
//FuelLevel End

//Auger turn start  
  //pinMode(TurnSwitch, INPUT); // initialize the switch pin as a input:
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
  // initialize the LED as an output:
  pinMode(ledPin, OUTPUT);
//Auger turn end

// Tempsensors
// Start up the library
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideTemp, 9);
  sensors.setResolution(outsideTemp, 9);
  sensors.setResolution(supplyTemp, 9);
  sensors.setResolution(returnTemp, 9);
  sensors.setResolution(boilerTemp, 9);
  sensors.setResolution(topTemp, 9);
  sensors.setResolution(bottomTemp, 9);
  //sensors.setResolution(fireTemp, 9);
  //sensors.setResolution(smokeTemp, 9);

  // put your setup code here, to run once:

void printTemperature(DeviceAddress deviceAddress)
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    //Serial.print("C: ");
   test = tempC;
    //Serial.print(" F: ");

void loop() {
  // Debugg start 
      Serial.print("number of button pushes:  ");
//      Serial.println(TurnSwitchCounter);
      Serial.print("loops:      ");
    /*  Serial.print("centimeters:       ");
      Serial.print("1 Inside  ");
      Serial.print("2 Outside  ");
      Serial.print("3 Supplyline  ");
      Serial.print("4 Returnline  ");
      Serial.print("5 Boiler  ");
      Serial.print("6 Top Tank  ");
      Serial.print("7 Bottom Tank  ");
  */    //more will come when it arrives.
//Debugg end

Now I need some help to get the data gathering right.
I would like to log changes, if one data post change = log all at that moment excluding feed auger.
And by that I will need a tolerance lets say ±3°C, if it goes ±4°C then log them all.
It would be nice if the tolerance is specific for each data post.
A comma separated file on the sd card would be easy way.
Ideas, hints and tips cause I don’t have a clue what way is the best or possible?
If I got anything wrong please tell me!

Last half of the code in next post due to 9000 limit.

Second half.

Convert_All ();
AugerTurn_Count ();
Temp_In_Out ();
Temp_Sup_Ret ();
Temp_Tank ();
Temp_Boilier ();
Summary ();
Write_SD ();


void LCD_Print (){ // Update LCD.
//lcd.print("                ");
//lcd.print("                ");

void Convert_All (){
 Serial.print("Getting temperatures...\n\r");
 //delay(500); //OneWire messuare, convert, get ready to deliver. Will be 3 wire setup(VCC,DATA,GND).
void Fuel_Level () { //Get distance in silo
// Set the trigger
digitalWrite(trigger, LOW);

// Start measurement
digitalWrite(trigger, HIGH);
digitalWrite(trigger, LOW);

// Acquire data and convert it to meters.
distance = pulseIn(echo,HIGH); // data acquisition.
distance = distance * 26 / 100 / 2 / 1000; // data converstion.
FuelLevel = distance * 100; // convert to centimeters and avoid more float.

void Twitter () { // Send status and alarms on interval and direct.
void Update_Web () { //Send to/Update webserver internal/external?
void Write_SD () { //Write to SD card, use Summary.
void Summary () { //Put it together for statistics.
void Temp_Boilier () { //All in boilier water,fire,smoke.
TempBoiler = test;
void Temp_Tank () { //All in tank top,bottom.
TempTopTank = test;

TempBottomTank = test;
void Temp_Sup_Ret () { //All lines supply,return. Maybe put this in Temp_Tank
TempSupplyLine = test; 

TempReturnLine = test;  

void Temp_In_Out () { //All outside,inside
TempInSide = test;

TempOutSide = test;

void AugerTurn_Count () { //Turn counter auger

  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // wend from off to on:
      Serial.print("number of button pushes:  ");
    else {
      // if the current state is LOW then the button
      // wend from on to off:
  // save the current state as the last state, 
  //for next time through the loop
  lastButtonState = buttonState;

  // turns on the LED every four button pushes by 
  // checking the modulo of the button push counter.
  // the modulo function gives you the remainder of 
  // the division of two numbers:
  if (rounds % 10 == 0) {
    digitalWrite(ledPin, HIGH);
    lcd.print("Pellets - ");

  } else {
   digitalWrite(ledPin, LOW);

 /*     TurnSwitchState = digitalRead(TurnSwitch); // read the switch input pin:

  if (TurnSwitch != TurnSwitchLastState) { // compare the switchState to its previous state
    if (TurnSwitch == HIGH) {  // if the state has changed, increment the counter
      TurnSwitchCounter++;// if the current state is HIGH then the switch wend from off to on:
     // Serial.println("on");
      //Serial.print("number of button pushes:  ");
    else {
      // if the current state is LOW then switch
      // wend from on to off:
  TurnSwitchLastState = TurnSwitchState; // save the current state as the last state,for next time through the loop

  AugerTurnCount = TurnSwitchCounter; // Update for statistics


It would help to look at arrays and structs to organize your data - especially arrays. As you have it though, you could add a function that you call after each call to printTemperature, say CheckTempThreshold, passing it the temperature you just got and the associated threshold.

Initially, that threshold would just be a literal number; in a later version it could come from a variable you read from the SD card.

Thanks! Time for reading session :)

This project is up and running with logging thru Blynk.
Post here if you wish to look at the code (it’s not pretty).