Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Ricardo Mena C
- ricardo@crcibernetica.com
- http://crcibernetica.com
- This example code is in public domain
- */
- #include <SoftwareSerial.h>
- #include <Nextion.h>
- #include <TimeLib.h>
- #include <DS1307RTC.h>
- #include <Wire.h>
- #include <DHT.h>
- #include <DHT_U.h>
- #define DHTPIN 6
- #define DHTTYPE DHT22
- DHT_Unified dht(DHTPIN, DHTTYPE);
- uint32_t delayMS;
- SoftwareSerial nextion(2, 3);// Nextion TX to pin 2 and RX to pin 3 of Arduino
- Nextion myNextion(nextion, 9600); //create a Nextion object named myNextion using the nextion serial port @ 9600bps
- void setup() {
- Serial.begin(9600);
- dht.begin();
- myNextion.init();
- }
- void loop() {
- sensors_event_t event;
- int brightness = (event.relative_humidity);
- int bright = map(brightness, 30.0, 100.0, 100, 10);
- String dim = "dim=" + String(bright);
- myNextion.sendCommand(dim.c_str());
- dht.temperature().getEvent(&event);
- myNextion.setComponentText("temp", String(event.temperature));
- //delay(100);
- dht.humidity().getEvent(&event);
- myNextion.setComponentText("fukt", String(event.relative_humidity));
- tmElements_t tm;
- (RTC.read(tm));
- myNextion.setComponentText("tim", String(tm.Hour));
- myNextion.setComponentText("min", String(tm.Minute));
- myNextion.setComponentText("ar", String(tmYearToCalendar(tm.Year)));
- myNextion.setComponentText("man", String(tm.Month));
- myNextion.setComponentText("dag", String(tm.Day));
- delay(1000);}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement