Start a new topic

Temperature alarm system with buttons and variables

Hi,


I have a 5 inch Nextion display and I'm trying to have it connect with my arduino for a project I'm doing. I am new to the Nextion world and I just need some help figuring stuff out. What I'm trying to do is have a start and stop button, to start the main code and stop it, and also have a text box be a variable in my main code. The text box will have a number in it that someone can change to have the alarms go off at a different temperature, for example if the temperature needed to be at 650 for the alarms to go off instead 500 then they can just change that. The HMI works perfectly when I use the debugger thing but I'm struggling with figuring out how to implement it into my main code.

  {
      if (myRA.getAverage() > 26)
      {
        digitalWrite (Alarm, HIGH);   // turn the Alarm on (HIGH is the voltage level)
        delay(1000);             // wait for a second
        digitalWrite(Alarm, LOW);    // turn the Alarm off by making the voltage LOW
        delay(500);                // wait for a second
      }
      else
      {
        digitalWrite(Alarm, LOW);
      }
    }
  }
}

 

  The text component (t0) variable should where that 26 is at the top, I'm just not sure how to code it to have it work the way I want it to. And then the start and stop buttons just have to start the main code and stop it.


Sorry if this is too broad of a question or it's to simple and shouldn't be on here I'm just looking for some help 

(I attached both the code and HMI files so that you can understand what I'm talking about a little better)


Thanks in advance for any help!!!



ino
(3.73 KB)
HMI

Not even going to download

What the heck is line 5 and line 7 ??


It's to have the alarm sound go on and off...

right now it's just attached to a really big buzzer so instead of it being a constant sound it just goes on and off along with a LED light 

That may be your purpose for having them there -- what is it?


It's a delay line... it starts the voltage for a second and then stops it for half a second 

I don't think I'm understanding your question...

It HALTS your MCU to a dead stop for 1000ms and again for 500ms

It is a do absolutely nothing until penalty time is over.


Such should never be used


Next - no mention of what MCU you used

  - Arduino IDE is configured with last used selected board

As such, the MCUs are so different

  - code CAN compile for one board and FAIL on another


No it starts the sound for 1000ms then it stops it for 500ms and then repeats that cycle until it is manually stopped or drops under the set temperature 

Sorry I thought I mentioned that, it is an arduino uno so I'm using the Arduino IED

Next  

 

#include <Adafruit_MAX31856.h>
#include <RunningAverage.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>

// Use software SPI: CS, DI, DO, CLK
Adafruit_MAX31856 max = Adafruit_MAX31856(3, 5, 7, 8);
// use hardware SPI, just pass in the CS pin
//Adafruit_MAX31856 max = Adafruit_MAX31856(10);

...

 

 Such is so far from any code that would come close to Nextion, Sorry.

I don't think I explained this enough I'm sorry. That code is not for the Nextion, it's for my arduino, I put that on there to show what my project is and how it works. What I'm asking is for help to make code to be able to do the things I mentioned earlier That will affect that code

delay() is an MCU all stop command.

- your MCU sits on that line number until time has passed.


Whatever the intended use is, I will tell you, using it like this is wrong


At 115200 baud,

   11520 bytes of data can move in 1 sec (1000ms)

   another 5760 bytes in 1/2 second

   - potential to miss up to 17280 bytes because of delay() usage.

Okay I'll take away the delays

Login or Signup to post a comment