5 Temp Probe System trouble shooting

Hello all,

I am working on my first project and am stuck getting something to work right and was hoping to get some help.

I put together a system with 5 one wire temp probes, 4 buttons and ac LCD screen. All wiring works just fine, I had the four temperature readings looping and all were working well. When I added the buttons and the programming around them is where I got stuck. I have the following code set up to debounce the four buttons and then change the screen readout to match the button pushed. When hitting the buttons, nothing happens and the screen stays dark. Please have a look at what I did and help me see where I am going wrong.

Thank you in advance for any help you can offer.

Erik

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

const int ONE_WIRE_BUS_PIN = 6;
const int TxPin = 5;
OneWire oneWire(6);
DallasTemperature sensors(&oneWire);
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

DeviceAddress MashH = {
0x28, 0x77, 0x19, 0xCB, 0x04, 0x00, 0x00, 0xBF };
DeviceAddress MashL = {
0x28, 0xF4, 0x4D, 0xCB, 0x04, 0x00, 0x00, 0x86 };
DeviceAddress HLTank = {
0x28, 0x10, 0xBF, 0xCB, 0x04, 0x00, 0x00, 0x56 };
DeviceAddress Boil = {
0x28, 0xF4, 0x4D, 0xCB, 0x04, 0x00, 0x00, 0x86 };
DeviceAddress Ambient = {
0x28, 0x10, 0xBF, 0xCB, 0x04, 0x00, 0x00, 0x56 };

float mashH;
float mashL;
float mashA = (mashH+mashL);
float hltank;
float boil;
float ambtmp;

/-----( Declare Constants )-----/
int mashButton = 8;
int hltButton = 9;
int boilButton = 10;
int ambButton = 11;

boolean currentmashButton = LOW;
boolean currenthltButton = LOW;
boolean currentboilButton = LOW;
boolean currentambButton = LOW;

boolean lastmashButton = LOW;
boolean lasthltButton = LOW;
boolean lastboilButton = LOW;
boolean lastambButton = LOW;

void setup()
{

pinMode(mashButton, INPUT);
pinMode(hltButton, INPUT);
pinMode(boilButton, INPUT);
pinMode(ambButton, INPUT);

pinMode(TxPin, OUTPUT);
digitalWrite(TxPin, HIGH);
mySerial.begin(9600);

mySerial.write(17); // Turn backlight on
delay(100); // Required delay
sensors.begin();
sensors.setResolution(MashL, 10);
sensors.setResolution(MashL, 10);
sensors.setResolution(HLTank, 10);
sensors.setResolution(Boil, 10);
sensors.setResolution(Ambient, 10);

}/–(end setup )—/

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
mySerial.print(“Error getting temperature”);
} else {

mySerial.print(DallasTemperature::toFahrenheit(tempC));
}
}

boolean debounceMash(boolean lastmashButton)
{
boolean currentmashButton = digitalRead(mashButton);
if (lastmashButton != currentmashButton)
{
delay(5);
currentmashButton = digitalRead(mashButton);
}
return currentmashButton;
}

boolean debounceHLT(boolean lasthltButton)
{
boolean currenthltButton = digitalRead(hltButton);
if (lasthltButton != currenthltButton)
{
delay(5);
currenthltButton = digitalRead(hltButton);
}
return currenthltButton;
}

boolean debounceBoil(boolean lastboilButton)
{
boolean currentboilButton = digitalRead(boilButton);
if (lastboilButton != currentboilButton)
{
delay(5);
currentboilButton = digitalRead(boilButton);
}
return currentboilButton;
}

boolean debounceAMB(boolean lastambButton)
{
boolean currentambButton = digitalRead(ambButton);
if (lastambButton != currentambButton)
{
delay(5);
currentambButton = digitalRead(ambButton);
}
return currentambButton;
}

void loop()
{

sensors.requestTemperatures();

mashH = sensors.getTempF(MashH);
if (mashH == -127.00) {
Serial.print(“Error getting temperature”);
}

mashL = sensors.getTempF(MashL);
if (mashL == -127.00) {
Serial.print(“Error getting temperature”);
}

mashA = (mashH+mashL)/2;

currentmashButton = debounceMash(lastmashButton);
if (lastmashButton == LOW && currentmashButton == HIGH )
{
mySerial.write(17); // Turn backlight on
delay(100); // Required delay
mySerial.write(12);
delay(5);
mySerial.print(“Mash Temp: “);
mySerial.write(13);
mySerial.print(mashA);
mySerial.print(” F”);
}

currentambButton = debounceAMB(lastambButton);
if (lastambButton == LOW && currentambButton == HIGH)
{
mySerial.write(17); // Turn backlight on
delay(100); // Required delay
mySerial.write(12);
delay(5);
mySerial.print(“Ambient Temp: “);
mySerial.write(13);
printTemperature(Ambient);
mySerial.print(” F”);
}

currenthltButton = debounceHLT(lasthltButton);
if (lasthltButton == LOW && currenthltButton == HIGH )

{
mySerial.write(17); // Turn backlight on
delay(100); // Required delay
mySerial.write(12);
delay(5);
mySerial.print(“HL Tank: “);
mySerial.write(13);
printTemperature(HLTank);
mySerial.print(” F”);
}

currentboilButton = debounceBoil(lastboilButton);
if ( lastboilButton == LOW && currentboilButton == HIGH )
{
mySerial.write(17); // Turn backlight on
delay(100); // Required delay
mySerial.write(12);
delay(5);
mySerial.print(“Boil Temp: “);
mySerial.write(13);
printTemperature(Boil);
mySerial.print(” F”);

}

lastmashButton = currentmashButton;
lasthltButton = currenthltButton;
lastboilButton = currentboilButton;
lastambButton = currentambButton;
}/* --(end main loop )-- */

float mashA = (mashH+mashL);

Since mashH and mashL are 0, and the default value for a global float is 0, what is the purpose of this?

All wiring works just fine

Proof seems to be non-existent. As does any form of schematic.

 pinMode(mashButton, INPUT);
  pinMode(hltButton, INPUT);
  pinMode(boilButton, INPUT);
  pinMode(ambButton, INPUT);

No internal pullup resistors are being enabled, so you have external resistors, right? (I hate guessing games.)

 void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    mySerial.print("Error getting temperature");
  } else {

    mySerial.print(DallasTemperature::toFahrenheit(tempC));
  }
}

Here's that crappy function again that does NOT do what it's name suggests.

boolean debounceMash(boolean lastmashButton)
{
  boolean currentmashButton = digitalRead(mashButton);
  if (lastmashButton != currentmashButton)
  {
    delay(5);
    currentmashButton = digitalRead(mashButton);
  }
  return currentmashButton;
}

You do not need 5 of these functions. A little thought, and there would be ONE!

mashH = sensors.getTempF(MashH);

If you worked for me, I'd be kicking your butt all over the place for this. If you really can't figure out the difference between a temperature and a sensor address, programming is not for you. Use names that reflect what the variable is for. Names that differ only in case are a recipe for disaster. They certainly cause me to stop reading, and send you back to the editor.

Thank You Very Much for your wonderfully condescending answer to someone posting their first programming question. I had no idea that this forum could be as helpful as you have made it out to be. I am trying to learn all this by frankensteining sketches together and figuring out how they work as I go. I didnt realize that non-traditional meathods were bane to open source learning.

Have a great forum.

forsaken541: Thank You Very Much for your wonderfully condescending answer to someone posting their first programming question. I had no idea that this forum could be as helpful as you have made it out to be. I am trying to learn all this by frankensteining sketches together and figuring out how they work as I go. I didnt realize that non-traditional meathods were bane to open source learning.

Have a great forum.

Geez, this forum needs a thin-skin rating system so whiny newbies don't get their feelings hurt by honest answers.

If you dont want to help dont reply, My skin is nice and thick and there are zero tears coming down my face, Im not interested in you making yourself look smart here, I thought your role here was to be helpful, not just say

this is crap, crap, crap, blah blah blah.

Help if your going to help otherwise go moderate the DMV forum boards.

DeviceAddress MashH = {
  0x28, 0x77, 0x19, 0xCB, 0x04, 0x00, 0x00, 0xBF };
float mashH;

Having variable names that differ only in capitalisation is a really bad idea. Please give them suitably distinct names such as MashHAddress and MashHTemperature (or whatever it is that the float is going to be used for).

Please look at the state change detection example sketch to see how to detect when an input has changed state. This will enable you to detect when the button has been pressed and released.

You could continue to tackle this problem using separate variables for each sensor and reach button, but you will find it much easier to tackle it using arrays. The idea would be that you store your switch pin numbers in an array, and store the previous state of each switch input in an array, and have a variable which holds the array index value of the last switch that you pressed - which would also be the array index value of the sensor address. Also put your device addresses in an array, also indexed by the same value.

Then you only need one piece of code to read and debounce the switch inputs, and one piece of code to read and display the currently-selected temperature.

Thank you Peter. I see exactly what you are saying. It was getting a little hard to remember which one was which.

And PaulS- I apologize if I was rude back to you. I was frustrated that I couldnt figure it our and had to ask a question.

forsaken541: Thank You Very Much for your wonderfully condescending answer to someone posting their first programming question. I had no idea that this forum could be as helpful as you have made it out to be.

You could help us too by reading the "stickies" at the start of the forum sections. I'll provide links to save you looking for them:

Read this before posting a programming question

How to use this forum

PaulS helps hundreds of people a day. When yet another post starts by someone who has clearly not taken the time to read the sticky, no doubt it puts his teeth on edge.

Please use code tags when posting code.

It says so in both stickies and makes helping people easier. Instead we waste time every day typing sentences like this.