Facebook
From Karol, 3 Years ago, written in C.
This paste is a reply to Untitled from JA - view diff
Embed
Download Paste or View Raw
Hits: 260
  1. #include "DHT.h"
  2. #include <SPI.h>
  3. #include <Wire.h>
  4. #include <Adafruit_GFX.h>
  5. #include <Adafruit_SSD1306.h>
  6. #define DHTPIN 2  
  7. #define DHTTYPE DHT22
  8. DHT dht(DHTPIN, DHTTYPE);
  9. #define SCREEN_WIDTH 128
  10. #define SCREEN_HEIGHT 64
  11. #define OLED_RESET     -1
  12. Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
  13.  
  14.  
  15. void setup() {
  16.   Serial.begin(9600);
  17.   dht.begin();
  18.   display.begin(SSD1306_SWITCHCAPVCC, 0x3C); }
  19.  
  20. void loop() {
  21.   float temp = dht.readTemperature();
  22.   float wilg = dht.readHumidity();
  23.   display.clearDisplay();
  24.   display.setTextSize(1);
  25.   display.setTextColor(SSD1306_WHITE);
  26.   display.setCursor(20, 5);
  27.   display.println("STACJA POGODOWA");
  28.   display.drawLine(0, 15, display.width()-1, 15,SSD1306_WHITE);
  29.   display.setCursor(2, 25);
  30.   display.print("TEMPERATURA: ");
  31.   display.print(temp);
  32.   display.println(" `C");
  33.   display.setCursor(2, 40);
  34.   display.print("WILGOTNOSC:  ");
  35.   display.print(wilg);
  36.   display.print(" %");
  37.   display.display();
  38.   delay(2000);}