Retrieving one Temperature value after the third valid transmission.

I am trying to get a value of temperature that has been transmitted. and applying this value to z for example. This value is required only once so I can place a marker on an OLed.
Can some one help me with the required code. The correct receipt of the temperature is marked with a high on pin 13 when this flashes 3 times rhen the fourth value should be applied to z so that I can use this value on the OLed. This should happen only once when the board is switched on.

// Receiving Temp. Data and displaying in on an OLed with a bar graph.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <VirtualWire.h>
#define OLED_RESET 4
float temperatureNow;
int count;
int graphpos = 0;

Adafruit_SSD1306 Display(OLED_RESET);

float r = 0;
float a = 0;
int i = 0;

void setup(void) {

Display.drawLine(a,40,a,64, WHITE);// draw white vertical line at ambient temp.

Serial.begin(9600); // Debugging only
Serial.println(“setup”); //Prints “Setup” to the serial monitor
vw_set_rx_pin(12); //Sets pin D12 as the RX Pin
//vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(4000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running

#if (SSD1306_LCDHEIGHT !=64)
#error (“Height incorrect, please fix Adafruit_SSD1306.h!”);
#endif
Display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x64)

Display.begin();

Display.clearDisplay();
DrawTitles();
}

void loop(void) {
graphpos = 0;
String tempHolder = “”;
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking

{
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");

for (int i = 0; i < buflen; i++)
{
char c = (buf*);*

  • tempHolder += c;*

  • }*

  • count++;*

  • //Serial.print(count);*

  • temperatureNow = tempHolder.toInt();*

  • temperatureNow = temperatureNow / 100;*

  • Serial.print(temperatureNow);*

  • Serial.println(" Degrees C");*

  • Serial.println(a);*

  • }*

  • // get Temperature*

  • r = temperatureNow;*

  • a = (r+30);*

  • Display.setTextSize(2);*

  • // note set the background color or the old text will still display*

  • Display.setTextColor(WHITE, BLACK);*

  • Display.setCursor(0, 20);*

  • Display.print(r);*

  • Display.println(" C");*

  • //draw the bar graph*

  • Display.fillRect(a, 50, 128 - a, 10, BLACK);*

  • Display.fillRect(3, 50, a, 10, WHITE);*

  • for (i = 1; i < 13; i++) {*
    _ Display.fillRect(i * 10, 50, 2, 10, BLACK);_

  • }*

  • // now that the display is build, display it…*

  • Display.display();*
    }
    void DrawTitles(void)
    {

  • Display.setTextSize(1);*

  • Display.setTextColor(WHITE);*

  • Display.setCursor(0, 0);*

  • //Display.print(r);*

  • Display.println(“Thermal Search”);*

}

Hi, oe8pck

I can't help you other than to say, you will get a lot more responses if you use code tags. Please read How to use this forum at the top of the home page.

Fof

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

…R

I am still having Problems using this Forum hope this is OK.

I have now added the code as requested. I am trying to get a temperature when the Count reaches 4. This value will then be used in the OLed to mark the posion on the slider. I cannot get the temerature at the 4th Count to a letter z. Perhaps someone can see the Problem. I only Need this value once when the board is switched on.

// Receiving Temp. Data and displaying in on an OLed with a bar graph.


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <VirtualWire.h>
#define OLED_RESET 4
float temperatureNow;
int count = 0;
int graphpos = 0;

Adafruit_SSD1306 Display(OLED_RESET);

float r = 0;
float a = 0;
int i = 0;
int z = 0;

void setup(void) {


 Display.drawLine(a,40,a,64, WHITE);// draw white vertical line at ambient temp.

  Serial.begin(9600);  // Debugging only
  Serial.println("setup"); //Prints "Setup" to the serial monitor
  vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin
  //vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(4000);      // Bits per sec
  vw_rx_start();       // Start the receiver PLL running
  
 

#if (SSD1306_LCDHEIGHT !=64)
#error ("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
  Display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)

  Display.begin();

  Display.clearDisplay();

    if (count==4)temperatureNow == z;
   

  DrawTitles();
 
}

void loop(void) {

  
  graphpos = 0;
  String tempHolder = "";
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
 if (vw_get_message(buf, &buflen)) // Non-blocking
  
  {
    digitalWrite(13, true);  // Flash a light to show received good message
    // Message with a good checksum received, dump it.
    Serial.println("Got: ");

    for (int i = 0; i < buflen; i++)
    {
      char c = (buf[i]);
      
      tempHolder += c;
    }
    count++;
   

   temperatureNow = tempHolder.toInt();
   temperatureNow = temperatureNow / 100;
    Serial.print(temperatureNow);
    Serial.println(" Degrees C");
   // Serial.println(a);
    Serial.println(count);
    Serial.print(z);
    Serial.println (" Grad C");
  }

  

  // get Temperature

  r = temperatureNow;
  a = (r+30);
  
  
  Display.setTextSize(2);
  // note set the background color or the old text will still display
  Display.setTextColor(WHITE, BLACK);
  Display.setCursor(0, 20);
   Display.print(r);
   Display.println(" C");
   
    
   //draw the bar graph
  Display.fillRect(a, 50, 128 - a, 10, BLACK);
  Display.fillRect(3, 50, a, 10, WHITE);

  for (i = 1; i < 13; i++) {
    Display.fillRect(i * 10, 50, 2, 10, BLACK);
    
  }

  // now that the display is build, display it...
  Display.display();


}


  void DrawTitles(void)
{
  
  Display.setTextSize(1);
  Display.setTextColor(WHITE);
  Display.setCursor(0, 0);
  //Display.print(r);
  Display.println("Thermal Search");
 
}

You have a line

if (count==4)temperatureNow == z;

but I don't see where the value of z is updated.

Also, that line seems to be in setup() when it should probably be in loop()

Your code will be much easier to maintain and to debug if you use meaningful variable names rather than single letters.

...R

 Display.drawLine(a,40,a,64, WHITE);// draw white vertical line at ambient temp.

That comment is true only if the ambient temperature is 0.

  vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin

Really? Is that what that code does? I had no idea. 8)

    if (count==4)temperatureNow == z;

If count equals 4, see if temperatureNow equals z. Regardless of whether it does, or does not, do nothing with the information. So, what value IS the information?

Did you mean to use an assignment operator in one place in that statement?

Thank you for the quick replys. The value z should be the temperature when the Count reaches 4. This means I have received per Radio 433 mhz, on pin 12 the fourth temperature measurement. I Need this later to set a vertical bar on my OLed Display showing the ambient temperture. It only Needs to be used once when the board is switched on. The Temerature data stream is then shown on the OLed. I know I should not say this but I am a complete beginner and don't really understand things like assignment Operator etc. I know that the vertical line code is not write because I want to use z instead of a, but this I understand. All I want is to get the ambient temperature using the 4th rx of the temperature via the 433mhz. I am really trying to explain what I Need clearly I hope this time it works.
Many thanks for your Kind help.
Paul

oe8pck:
The value z should be the temperature when the Count reaches 4.

Which line of your code makes that happen?

I suspect you have not read and carefully considered all of the comments that have been made.

...R

I hope this time it works.

Storing the 4th value from the radio, in another variable, is certainly possible. The assignment operator (=) is used, though, not the equality operator (==). It is extremely important to know the difference.

There are two major problems with your last code, though. First, count will NEVER equal 4 in setup. So, that statement belongs in loop(), before or after you increment count.

Second, you assign a new value to temperatureNow on every pass through loop() that has radio data available. Assigning it a value only on the 4th pass through loop() that has radio data available doesn't make sense. Assigning z the value in temperatureNow MIGHT make sense, but I can not see a relationship between temperatureNow and z. If z was called baseTemperature, that would be a different story.

Thanks for your help, now I need time to ponder. :slight_smile: I placed my Count code in the Setup to make it happen just once but now I think I se my mistake because Count never gets over 0 in Setup????

oe8pck:
because Count never gets over 0 in Setup?

Indeed.

...R

Now it works,

The vertical line at ambient temp. too.
Thank you for your help.

[
// Receiving Temp. Data and displaying in on an OLed with a bar graph.


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <VirtualWire.h>
#define OLED_RESET 4
float temperatureNow;
int count = 0;
int graphpos = 0;
float startTemp = 0;

Adafruit_SSD1306 Display(OLED_RESET);

float r = 0;
float a = 0;
int i = 0;
float z = 0;

void setup(void) {


  Display.drawLine(a, 40, a, 64, WHITE); // draw white vertical line at ambient temp.

  Serial.begin(9600);  // Debugging only
  Serial.println("setup"); //Prints "Setup" to the serial monitor
  vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin
  //vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(4000);      // Bits per sec
  vw_rx_start();       // Start the receiver PLL running



#if (SSD1306_LCDHEIGHT !=64)
#error ("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
  Display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)

  Display.begin();

  Display.clearDisplay();



  DrawTitles();

}

void loop(void) {


  graphpos = 0;
  String tempHolder = "";
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking

  {
    digitalWrite(13, true);  // Flash a light to show received good message
    // Message with a good checksum received, dump it.
    Serial.println("Got: ");

    for (int i = 0; i < buflen; i++)
    {
      char c = (buf[i]);

      tempHolder += c;
    }
    count++;
    if (count == 4) // 4th temperatureNow
    {
      startTemp = a; // starTemp equals temperatureNow + 30
    }


    temperatureNow = tempHolder.toInt();
    temperatureNow = temperatureNow / 100;


    Serial.print(temperatureNow);
    Serial.println(" Degrees C");

    Serial.println(count);
    Serial.print(startTemp);
    Serial.println(a);
    Serial.println (" Grad C");
    Serial.println (z);
  }



  // get Temperature

  r = temperatureNow;
  a = (r + 30);


  Display.setTextSize(2);
  // note set the background color or the old text will still display
  Display.setTextColor(WHITE, BLACK);
  Display.setCursor(0, 20);
  Display.print(r);
  Display.println(" C");
  Display.drawLine(startTemp, 40, startTemp, 64, WHITE); // draw white vertical line at ambient temp.
  Display.drawLine(127, 40,127, 64, WHITE); // draw white vertical line at ambient temp.
/* 
  if (startTemp = (startTemp + 2));
 {
   Display.setTextSize(1);
  Display.setCursor(67, 50);  
  Display.println("Thermal");  
 }
*/
  //draw the bar graph
  Display.fillRect(a, 50, 128 - a, 10, BLACK);
  Display.fillRect(3, 50, a, 10, WHITE);

  for (i = 1; i < 13; i++) {
    Display.fillRect(i * 10, 50, 2, 10, BLACK);


  }

  // now that the display is build, display it...
  Display.display();


}


void DrawTitles(void)
{

  Display.setTextSize(1);
  Display.setTextColor(WHITE);
  Display.setCursor(0, 0);
  //Display.print(r);
  Display.println("Thermal Search");





}


/code]

I have another Problem with this code, do I have to start a new subject? I hope not because it is to do wih the same code. I have got two variables startTemp and therm. I have assigned startTherm to a and want to have the therm value when a or startTemp to be a +2 when the startTemp is over 1. The startTemp goes over 1 but therm remains 0. Why?

// Receiving Temp. Data and displaying in on an OLed with a bar graph.


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <VirtualWire.h>
#define OLED_RESET 4
int piezoPin = 5;
float temperatureNow;
int count = 0;
int graphpos = 0;
float startTemp = 0;
float therm = 0;
Adafruit_SSD1306 Display(OLED_RESET);

float r = 0;
float a = 0;
int i = 0;
float z = 0;

void setup(void)
{
  pinMode(piezoPin, OUTPUT);

  Display.drawLine(a, 40, a, 64, WHITE); // draw white vertical line at ambient temp.

  Serial.begin(9600);  // Debugging only
  Serial.println("setup"); //Prints "Setup" to the serial monitor
  vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin
  //vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(4000);      // Bits per sec
  vw_rx_start();       // Start the receiver PLL running



#if (SSD1306_LCDHEIGHT !=64)
#error ("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
  Display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)

  Display.begin();

  Display.clearDisplay();

  DrawTitles();

}

void loop(void) {


  graphpos = 0;
  String tempHolder = "";
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking

  {
    digitalWrite(13, true);  // Flash a light to show received good message
    // Message with a good checksum received, dump it.
   // Serial.println("Got: ");

    for (int i = 0; i < buflen; i++)
    {
      char c = (buf[i]);

      tempHolder += c;
    }
    count++;
    if (count == 4) // 4th temperatureNow
    {
      startTemp = a; // starTemp equals temperatureNow + 30
    }

    if (a >= (1));
    {
    therm == (a + 2);
    }

    temperatureNow = tempHolder.toInt();
    temperatureNow = temperatureNow / 100;


                     Serial.println(count);
                     Serial.print(temperatureNow);
                     Serial.println(" Degrees C");
                     Serial.print(startTemp);
                     Serial.println (" startTemp");
                     Serial.print(therm);
                     Serial.println(" therm");
                     // Serial.println (" Grad C");
                     // Serial.println (z);
                     Serial.println ();
  }

  r = temperatureNow;
  a = (r + 30);



Display.setTextSize(2);
// note set the background color or the old text will still display
Display.setTextColor(WHITE, BLACK);
Display.setCursor(0, 20);
Display.print(r);
Display.println(" C");
//  startTemp ++ 2 = f
if (count >= (4));
Display.drawLine(startTemp, 40, startTemp, 64, WHITE); // draw white vertical line at ambient temp.
Display.drawLine(127, 40, 127, 64, WHITE); // draw white vertical line at ambient temp.

if (temperatureNow >= (therm)); // Checking thermic conditions
{
  Display.setTextSize(1);
  Display.setCursor(67, 42);
  Display.println("Thermal"); // writing thermal to OLed.
}
//     analogWrite(piezoPin, 255);  //positive square wave // Warning buzzer when a thermal has arrived
//   delayMicroseconds(192);      //192uS

//   analogWrite(piezoPin, 0);     //neutral square wave
//  delayMicroseconds(192);      //192uS



//draw the bar graph
Display.fillRect(a, 50, 128 - a, 10, BLACK);
Display.fillRect(3, 50, a, 10, WHITE);

for (i = 1; i < 13; i++) {
  Display.fillRect(i * 10, 50, 2, 10, BLACK);
}
// now that the display is build, display it...
Display.display();
}

void DrawTitles(void)
{



  Display.setTextSize(1);
  Display.setTextColor(WHITE);
  Display.setCursor(0, 0);
  //Display.print(r);
  Display.println("Thermal Search");

}

[code]

I have got two variables startTemp and therm. I have assigned startTherm to a and want to have the therm value when a or startTemp to be a +2 when the startTemp is over 1. The startTemp goes over 1 but therm remains 0. Why?

Read what you wrote. Does it make sense to you? It does not make sense to me. You mention startTemp, and then from nowhere comes startTherm and a. It should be crystal clear that a is a crappy name for a variable. There is NOTHING in the name a that gives a hint as to what the value that it holds means.

Start by giving ALL of your one letter variable names better names.

      startTemp = a; // starTemp equals temperatureNow + 30

The comment is rubbish. You have NOT assigned a new value to a, so you just set startTemp to 0.

    if (a >= (1));
    {
    therm == (a + 2);
    }

(What) (is) (up) (with) (all) (the) (useless) (parentheses) (?) They add NO value. Get rid of them.

The assignment operator is STILL NOT ==.

Use Tools + Auto Format to correct that mess you call code BEFORE you post it again.

Dear PAULS, is it really necessary to be so agressive. I am a COMPLETE beginner and do not have the oppertunity to attend any School about programming. I will ofcourse heed your constructive advice which helped me resolve the last Problem. Do not get me wrong, I really am grateful for your help and although I do not have your extensive programming knowledge, I would like to enjoy our discussion and not have the feeling you are venting some sort of agression. Should you decide not to help me I understand and thank you for the help you have given me up to now. I will try and Name all the variables clearer way. The letters are also a Problem for me too. startTemp is the value of the TemperatureNow which is send fom the 433mhz TX. therm is the expression for a value that Triggers a message on the OLed. I just cannot get my head aroung the if expressions. Although the following line works, if Count == 4); startTemp = a; but when I use the same for two other variables startTemp and therm. I will now try and revamp the code according to your instructions and post it again.

Thank you sincerely for your Kind help.

So now I have replaced the letters with variable names. startTemp and graphTemp.
startTemp is the temeratureNow + 30, the statTemp is the value of temeatureNow + 30 at the time the program has read the 4 cycle of temerature reception. Now I want to send a script to the OLed when the temperatureNow has risen by 2 degrees C.
if (temperatureNow > (startTemp-30)); This code only checks whether the temperature has risen at all because when I try the IF with if (temperatureNow = (startTemp-30)+2); I cannot compile the sketch.
Could you please Show me the if line to compare the temperatureNow with startTemp-30+2.
I amreally trying to explain things clearly. Please ask your questions in a simple manner for me.
I will now add he complete code.

[/
// Receiving Temp. Data and displaying in on an OLed with a bar graph.

[code]
// Receiving Temp. Data and displaying in on an OLed with a bar graph.


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <VirtualWire.h>
#define OLED_RESET 4
int piezoPin = 5;
float temperatureNow;
int count = 0;
int graphpos = 0;
float startTemp = 0;
float graphTemp = 0;

Adafruit_SSD1306 Display(OLED_RESET);
int i = 0;


void setup(void) {
  pinMode(piezoPin, OUTPUT);

  Display.drawLine(startTemp, 40, startTemp, 64, WHITE); // draw white vertical line at ambient temp.

  Serial.begin(9600);  // Debugging only
  Serial.println("setup"); //Prints "Setup" to the serial monitor
  vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin
  //vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(4000);      // Bits per sec
  vw_rx_start();       // Start the receiver PLL running



#if (SSD1306_LCDHEIGHT !=64)
#error ("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
  Display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)

  Display.begin();

  Display.clearDisplay();

  DrawTitles();

}

void loop(void) {


  graphpos = 0;
  String tempHolder = "";
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking

  {
    digitalWrite(13, true);  // Flash a light to show received good message
    // Message with a good checksum received, dump it.
    // Serial.println("Got: ");

    for (int i = 0; i < buflen; i++)
    {
      char c = (buf[i]);

      tempHolder += c;
    }

    graphTemp = temperatureNow + 30;
    count++;
    if (count == 4) // 4th temperatureNow
    {
      startTemp = temperatureNow + 30; // startTemp equals temperatureNow + 30
    }

    
 
      /*     analogWrite(piezoPin, 255);  //positive square wave // Warning buzzer when a thermal has arrived
          delayMicroseconds(192);      //192uS

          analogWrite(piezoPin, 0);     //neutral square wave
        delayMicroseconds(192);      //192uS
      */


    temperatureNow = tempHolder.toInt();
    temperatureNow = temperatureNow / 100;

    Serial.println(count);
    Serial.print(temperatureNow);
    Serial.println(" Degrees C temperatureNow");
    Serial.print(startTemp);
    Serial.println(" startTemp");
    Serial.print (startTemp-30);
    Serial.println (" startTemp-30");
    Serial.print(temperatureNow + 30);
    Serial.println (" Grad C temperatureNow + 30");
    Serial.print (graphTemp);
    Serial.println (" graphTemp");
    Serial.println();

  }


  Display.setTextSize(2);
  // note set the background color or the old text will still display
  Display.setTextColor(WHITE, BLACK);
  Display.setCursor(0, 20);
  Display.print(temperatureNow);
  Display.println(" C");

  
  Display.drawLine(startTemp, 40, startTemp, 64, WHITE); // draw white vertical line at ambient temp.
  Display.drawLine(127, 40, 127, 64, WHITE); // draw white vertical line at ambient temp.

  if (temperatureNow >  (startTemp-30)); // Checking thermic conditions
   {
  Display.setTextSize(1);
  Display.setCursor(67, 50);
  Display.println("Thermal"); // writing thermal to OLed.
   }
  //     analogWrite(piezoPin, 255);  //positive square wave // Warning buzzer when a thermal has arrived
  //   delayMicroseconds(192);      //192uS

  //   analogWrite(piezoPin, 0);     //neutral square wave
  //  delayMicroseconds(192);      //192uS



  //draw the bar graph
  Display.fillRect(temperatureNow + 30, 50, 128 - temperatureNow + 30, 10, BLACK);
  Display.fillRect(3, 50, temperatureNow + 30, 10, WHITE);

  for (i = 1; i < 13; i++) {
    Display.fillRect(i * 10, 50, 2, 10, BLACK);
  }
  // now that the display is build, display it...
  Display.display();
}

void DrawTitles(void)
{

  Display.setTextSize(1);
  Display.setCursor(67, 50);
  Display.println("Thermal"); // writing thermal to OLed.

  Display.setTextSize(1);
  Display.setTextColor(WHITE);
  Display.setCursor(0, 0);
  //Display.print(r);
  Display.println("Thermal Search");

}


[code]
  if (temperatureNow >  (startTemp-30)); // Checking thermic conditions

If statements rarely end with semicolons.

I really do not understand why you add 30 to temperatureNow when storing a value in startTemp, when you just need to subtract 30 from startTemp later. Can you explain that?

adding 30 the temeratureNow for use in the bar graph moves it further otherwise the movement would be too small. All I am trying to achieve is the bar graph the actuel temerature and if the temperature changes after i have determined the 4 th reading the word Thermal is shown on the oled and the bar graph moves.Thank you very much for your help, I do realise it is difficult to help someone who has very Little knowledge on the subject, but believe me the learning curve is going to be steep. :slight_smile:

If the only reason for adding 30 to startTemp is to make it appear differently in a graph then just add the extra when you are drawing the graph. That way you don't have the confusion of subtracting when you want to use the real value. Or create an extra variable called startTempForGraph which has the 30 added to it,

Try one of these

if (temperatureNow ==  (startTemp - 30 + 2)) {

 if (temperatureNow ==  (startTemp - 28)) {

Of course, better still would be

if (temperatureNow ==  (startTemp + 2)) {

...R
Edited to add missing ) - see Reply #22

I am getting the following error message when I am compiling the sketch with your code (if (temperatureNow == (startTemp + 2){) (which makes very good sense by the way.) As you can see I have got a ) before the {.

Paul

Arduino: 1.6.8 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -hardware "C:\Users\Paul\AppData\Local\Arduino15\packages" -tools "C:\Progra....(Deleted because of length).............................................

.....................\Documents\Arduino\libraries\Adafruit_SSD1306-master" "-IC:\Users\Paul\Documents\Arduino\libraries\VirtualWire" "-IC:\Users\Paul\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\libraries\SPI\src" "C:\Users\Paul\AppData\Local\Temp\build514e59269df171004e22fb4229a85d1e.tmp\sketch\bargraph_Oled_paul_V5.ino.cpp" -o "C:\Users\Paul\AppData\Local\Temp\build514e59269df171004e22fb4229a85d1e.tmp\sketch\bargraph_Oled_paul_V5.ino.cpp.o"
C:\Users\Paul\Documents\Arduino\bargraph_Oled_paul_V5\bargraph_Oled_paul_V5.ino: In function 'void loop()':

bargraph_Oled_paul_V5:117: error: expected ')' before '{' token

if (temperatureNow == (startTemp + 2){ // Checking thermic conditions

^

Using library SPI at version 1.0 in folder: C:\Users\Paul\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\libraries\SPI
Using library Wire at version 1.0 in folder: C:\Users\Paul\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\libraries\Wire
Using library Adafruit_GFX_Library at version 1.1.5 in folder: C:\Users\Paul\Documents\Arduino\libraries\Adafruit_GFX_Library
Using library Adafruit_SSD1306-master at version 1.1.2 in folder: C:\Users\Paul\Documents\Arduino\libraries\Adafruit_SSD1306-master
Using library VirtualWire in folder: C:\Users\Paul\Documents\Arduino\libraries\VirtualWire (legacy)
exit status 1
expected ')' before '{' token