print('This program is to detect Temperature & Humidity surrounding Using DHT11\n')
print('Date : 04/12/2023')
print('By : AKMAL FAIZ')
#Import all necessary libraries
#import Ultrasonic #This is Ultrasonic Library (TAK PERLU .PY)
#import Servo
import ssd1306 #This is OLED Library
from machine import Pin, PWM, SoftI2C
from utime import sleep
#Declare Pin
#Trig = Pin(25, Pin.IN) #Ultrasonic
#Echo = Pin(27, Pin.OUT) #Ultrasonic
#led_red = Pin(2, Pin.OUT)
#servo = Pin(14, Pin.OUT)
#buzzer = PWM(Pin(26), Pin.OUT)
sensor = (Pin(14),Pin.IN)
i2c_oled = SoftI2C(scl=Pin(22), sda=Pin(21))
oled_width = 128
oled_height = 64
#Create the object name for sensor with library --> LIBRARYNAME.CLASSNAME
#bagi nama = Import Library Name.Class Name (trigger_pin, echo_pin,)
screen = ssd1306.SSD1306_I2C(width=oled_width, height=oled_height, i2c=i2c_oled) #library name.class name()
#Main Program
while True:
scan = sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
temp_f = temp *(9/5) + 32.0
#OLED PART
screen.fill(1)
screen.text("Temperature : %3.1f C",5,10,0) #Text, Column, Colour code
screen.text("Humidity : %3.1f %%",5,45,0) #Text, Column, Colour code
screen.show()
sleep(4)