BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Thermostat blynk-nextion in progress

1st part: nextion display, standalone mode

Video_2019-12-12_1833312019-12-12_193830

P1B P1R P2B P2R P3B P3R Scheduler

fan_green fan_green1 fan_green2 Fan_red Fan / Pump

giphy2 giphy4 Blink Led

flamme Boiler

fleche_dn fleche_up Temp setting

cold sun Season

wifi signal Wifi signal

power-button-black power-button-black2 Display on/off

alerte cadena Alert / lock

btn_parametre Setup and boiler control

4 Likes

BT18 Display on/off , touch press event

if(va2.val==255)
{
  va2.val=0
  dim=va2.val // backlight off
}
page 3 // goto page 3

page 3 touch press event

dim=255 // backlight on
page 0 // return to first page

How to animate Fan ?
I’ve created One timer tm0 and one Variable va0
this is timer event :

bt12.pic=va0.val //bt12 is fan
va0.val=va0.val+1
if(va0.val>38) //36 to 38 are the png fan pic, corresponding to the 3 fan pics positions to make it turn.
{
  va0.val=36
}

Last graphic release :thinking:

064241

signal strength
signal0 signal1 signal2 signal

Next step, the sketch :shushing_face:

5 Likes

Hi Alexis

Can we have more details about your Nextion Display?

I found many models & sizes

Thanks

1 Like

another layout I found (idea)

Yes, I saw it.
The mine is home made :shushing_face:

did you get your nextion display @Ze_Pico ?
I 'm working on nextion HTTP upload at the moment !

Hey @Blynk_Coeur did you get nextion HTTP upload working? Do you have a video or sources for me to look at?

Hey @daveblynk !

This is my code to upload nextion through HTTP
I used ESP8266 and I can upload at 57600, I tried 115200 but unfortunately it was unsuccessful .
I think it is due to the limit of ESP8266’s virtual serial port.
May be ESP32 is better because there are three serial ports on it.

const char* fwUrlBase = "http://192.168.0.100:8000/name_of_nextion_file.tft"; // python server needed
const char* ssid = "SSID"; /// put your AP SSID here
const char* password = "PASS"; /// put your AP PASSWORD

/// HTTP OTA dependencies ///
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include <WiFiClient.h>
WiFiClient client;

#define NxBaud  57600
#define SrlBaud 115200

#include <ESPNexUpload.h>
bool updated          = false;
int count = 0;

void setup() {
  Serial.begin(SrlBaud);
  Serial.println("Booting...");

  // initialize ESPNexUpload
  ESPNexUpload nextion(NxBaud);

  WiFi.begin(ssid, password);
  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("Connecting to Wifi AP...");
    for ( int i = 0; i < 300; i++) {                  ///       try to connect to WiFi for max 30s
      if (WiFi.status() == WL_CONNECTED) {
        Serial.printf("it is connected after %d seconds", (i / 10));
        break;
      }
           delay(100);
    }
  }
  if (WiFi.status() == WL_CONNECTED) {
    //if you get here you have connected to the WiFi
    Serial.println("\nconnected...yesss! :)");
    checkForUpdates() ;
  } else {
    Serial.println("TimeOut! Not Connected even after 10 Seconds trying...\n *** Something wrong happened. It did not connected... *** ");
  }
}

void loop() {
  //ArduinoOTA.handle();
}

void checkForUpdates() {
  Serial.println("http start ... ");

  HTTPClient httpClient;
  httpClient.begin( client, fwUrlBase );
  int httpCode = httpClient.GET();
  int contentLength = httpClient.getSize();

  Serial.print("httpCode ");
  Serial.println (httpCode);
  Serial.print("contentLength ");
  Serial.println (contentLength);

  if ( httpCode == 200 ) {
    // Update the nextion display
    Serial.println("File received. Update Nextion...");
    bool result;

    // initialize ESPNexUpload
    ESPNexUpload nextion(57600);
    //ESPNexUpload nextion(74880);

    // Progress upload.....
    nextion.setUpdateProgressCallback([]() {
      count++;
      Serial.print(count / 10);
      Serial.println(" %");
    });

    // setup serial connection, send update command and send the expected update size
    result = nextion.prepareUpload(contentLength);

    if (!result) {
      Serial.println("Error: " + nextion.statusMessage);
    } else {
      Serial.print(F("Start upload. File size is: "));
      Serial.print(contentLength);
      Serial.println(F(" bytes"));

      // Upload the received byte Stream to the nextion
      result = nextion.upload(*httpClient.getStreamPtr());

      if (result) {
        updated = true;
        Serial.println("\nSuccesfully updated Nextion!");

      } else {
        Serial.println("\nError updating Nextion: " + nextion.statusMessage);
      }

      // end: wait(delay) for the nextion to finish the update process, send nextion reset command and end the serial connection to the nextion
      nextion.end();
    }
  } else {
    // else print http error
    Serial.println(String("HTTP error: ") + httpClient.errorToString(httpCode).c_str());
  }

  httpClient.end();
  Serial.println("Closing connection\n");
}
/// End of main function that performs HTTP OTA ///

Did you mess with iotappstory? They have a OTA update for Nextion that isn’t well documented but looks rather simple If it is like the esp OTA. (Maybe you like the hard way🤷‍♂️) I have been playing with their OTA for my D1 Minis but 2 out of 3 keep loosing their certificates. (That’s a different topic) My displays are sitting on the other side of the pond waiting for me but I’m trying to learn some stuff before I get there. (Difficult for me).

I’m too lazy :joy:
And I use Python server, because I use it for blynk images, it’s really easy to update Nextion.

Work in progress …
New Smart thermostat with forecast station and fuel tank control
Wifi signal strength and Blynk connection control
NodeMcu - Nextion 3.5" - openweathermap API - DHT22 - HC-SR04 Ultrasonic Sensor

Video_2020-10-18_203810

3 Likes