Arduino Uno + nextion - Wersja do druku +- Arduino Polska Forum (https://forum.arduinopolska.pl) +-- Dział: Start (https://forum.arduinopolska.pl/dzial-start) +--- Dział: Przywitanie (https://forum.arduinopolska.pl/dzial-przywitanie) +--- Wątek: Arduino Uno + nextion (/watek-arduino-uno-nextion) |
Arduino Uno + nextion - krzys55 - 10-03-2021 Witam wszystkich, Zaczynam swoją drogę z Arduino i robię projekt, który nastręcza mi mały problem. Otóż mój projekt to regulator temperatury z interfejsem HMI. Według założeń chciałbym zadawać czas, temperaturę oraz histerezę z hmi i dostawać wartości zwrotne jak pozostały czas cyklu oraz aktualną temeraturę w obiekcie nagrzewanym. Czasu jeszcze nie uwzględniłem w moim kodzie ale mam problem z wymiana danych miedzy arduino a Nextion. Czy ktoś mógłby zweryfikować moj kod programu i podać mi wskazówki co zrobiłem źle? #define Wentylator 7 #define Grzalka 8 int Zalacz_cykl; int TemZadana; int Histereza; #include <Nextion.h> #include "max6675.h" int thermoCLK = 4; int thermoCS = 5; int thermoDO = 6; MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); NexDSButton bt0 = NexDSButton(0, 8, "bt0"); // Załącz regulator NexNumber tz = NexNumber(1, 5, "tz"); // Temperatura zadana w piekarniku NexNumber tw = NexNumber(0, 7, "tw"); // Temperatura w piekarniku NexNumber th = NexNumber(1, 7, "th"); // Histereza temperatury NexTouch *nex_listen_list[] = { &bt0, // Dual state button added &tz, &th, NULL // String terminated }; // End of touch event list void bt0PushCallback(void *ptr) // Press event for dual state button bt0 { uint32_t number5 = 0; // Create variable to store value we are going to get bt0.getValue(&number5); // Read value of dual state button to know the state (0 or 1) if (number5 == 1) { // If dual state button is equal to 1 (meaning is ON)... digitalWrite(13, HIGH); // Turn ON internal LED Zalacz_cykl = 1; } else { // Since the dual state button is OFF... digitalWrite(13, LOW); // Turn OFF internal LED Zalacz_cykl = 0; } } void tzPushCallback(void *ptr) // Press event for dual state button bt0 { uint32_t number4 = 0; // Create variable to store value we are going to get tz.getValue(&number4); // Read variable (inside the display) called vah and stored on variable number4 int TemZadana = number4; } void thPushCallback(void *ptr) // Press event for dual state button bt0 { uint32_t number3 = 0; // Create variable to store value we are going to get th.getValue(&number3); // Read variable (inside the display) called vah and stored on variable number4 int Histereza = number3; } void setup() // Start of setup { Serial.begin(9600); bt0.attachPush(bt0PushCallback); // Dual state button bt0 press tz.attachPush(tzPushCallback); th.attachPush(thPushCallback); pinMode(13, OUTPUT); } void loop() { delay(1000); int Temp = thermocouple.readCelsius(); // Serial.print("tw.val="); // This is sent to the nextion display to set what object name (before the dot) and what atribute (after the dot) are you going to change. Serial.print(Temp); // This is the value you want to send to that object and atribute mentioned before. Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display. Serial.write(0xff); Serial.write(0xff); if(Zalacz_cykl){ if((TemZadana-Histereza)>Temp) { digitalWrite(Wentylator,HIGH); digitalWrite(Grzalka,HIGH); } else{ digitalWrite(Wentylator,HIGH); digitalWrite(Grzalka,LOW); } } nexLoop(nex_listen_list); } RE: Arduino Uno + nextion - Jarewa0606 - 10-03-2021 pokaż projekt nextion RE: Arduino Uno + nextion - krzys55 - 10-03-2021 (10-03-2021, 20:55)Jarewa0606 napisał(a): pokaż projekt nextion RE: Arduino Uno + nextion - krzys55 - 10-03-2021 (10-03-2021, 20:55)Jarewa0606 napisał(a): pokaż projekt nextionW załaczniku projekt RE: Arduino Uno + nextion - Jarewa0606 - 11-03-2021 Coś nie widać a bez tego to ciężko coś powiedzieć. Bo na uno niby wszystko ok ale nie wiem czy adresowanie dobre... RE: Arduino Uno + nextion - krzys55 - 11-03-2021 (11-03-2021, 10:51)Jarewa0606 napisał(a): Coś nie widać a bez tego to ciężko coś powiedzieć. Bo na uno niby wszystko ok ale nie wiem czy adresowanie dobre... RE: Arduino Uno + nextion - krzys55 - 11-03-2021 (11-03-2021, 10:51)Jarewa0606 napisał(a): Coś nie widać a bez tego to ciężko coś powiedzieć. Bo na uno niby wszystko ok ale nie wiem czy adresowanie dobre...https://drive.google.com/file/d/1Kx9SCrH18WrjeNtWNVB-87w7iVrT6m4d/view?usp=sharing RE: Arduino Uno + nextion - Jarewa0606 - 11-03-2021 masz pomylone ID powinno być NexDSButton bt0 = NexDSButton(0, 3, "bt0"); // Załącz regulator NexNumber tz = NexNumber(1, 4, "tz"); // Temperatura zadana w piekarniku NexNumber tw = NexNumber(0, 7, "tw"); // Temperatura w piekarniku NexNumber th = NexNumber(1, 5, "th"); // Histereza temperatury RE: Arduino Uno + nextion - NiziolJ - 13-04-2021 Na pewno brakuje w setpie nexInit() |