Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. NExtion and I2C

NExtion and I2C

Scheduled Pinned Locked Moved Hardware
1 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bos Video
    wrote on last edited by
    #1

    He i have Nextion screen. I need show on Nextion data from I2C sensors.. I have ESP8266 devkit. Here is my sketch but this sketch no showing temp and hum on the Nextion. I need alternative wire.h. ? Thanks.

    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <SimpleTimer.h>
    #include <DHT.h>
    
    #include <Wire.h>
    #include <SI7021.h>
    float temp, hum;
    bool SI7021_present = true;
    #define I2C_SCL 12      // Barometric Pressure Sensor (BMP085)
    #define I2C_SDA 13
    SI7021 sensor;
    
    #include <Nextion.h>
    #include <SoftwareSerial.h>
    
    #define DHTPIN 2 //D4
    #define DHTTYPE DHT22   // DHT 22 Change this if you have a DHT11
    DHT dht(DHTPIN, DHTTYPE);
    
    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "";  // Put your Auth Token here. (see Step 3 above)
    
    SoftwareSerial HMISerial(4,5,false,256);//RX-D1 , TX-D2
    Nextion myNextion(HMISerial, 9600);
    
    SimpleTimer timer;
    
    void setup()
    {
     Wire.begin();
      sensor.begin(SDA,SCL);
      Wire.begin(I2C_SDA, I2C_SCL);
      
      Serial.begin(9600); // See the connection status in Serial Monitor
      Blynk.begin(auth, "", ""); //insert here your SSID and password
    
      myNextion.init();
     
      // Setup a function to be called every second
      timer.setInterval(10000L, sendUptime);
    }
    
    void sendUptime()
    {
      // You can send any value at any time.
      // Please don't send more that 10 values per second.
       //Read the Temp and Humidity from DHT
      float h = dht.readHumidity();
      float t = dht.readTemperature();
      
      Blynk.virtualWrite(12, t); // virtual pin 
      Blynk.virtualWrite(13, h); // virtual pin 
    
    
     float temperature = sensor.getCelsiusHundredths()/100;
     float humidity = sensor.getHumidityPercent();
     Blynk.virtualWrite(5, temperature); 
     Blynk.virtualWrite(6, humidity); // virtual pin
    
    
      myNextion.setComponentText("t1", String(temperature));
      myNextion.setComponentText("t2", String(humidity));
      myNextion.setComponentText("t3", String(t));
      myNextion.setComponentText("t4", String(h));
      delay(1000);
    
      String dim = "dim=50";         //pro podsvíceni 
      myNextion.sendCommand(dim.c_str()); //pro podsvícení
    
    }
    
    
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    32

    Online

    11.7k

    Users

    11.2k

    Topics

    113.1k

    Posts


    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • MySensors
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular