Temelelektronik.info

Ds18b20 Esp8266 Micropython hava durumu istasyonu

Devre


Bu devre Eylül ayından itibaren 850  defa ziyaret edilmiştir.

Açıklama


#main.py
import os
from urllib import urequest
from time import sleep
from machine import Pin
import time, ds18x20
import onewire
try:
  import usocket as socket
except:
  import socket
import network
import esp
esp.osdebug(None)
import gc

gc.collect()
led = Pin(4, Pin.OUT)
station = network.WLAN(network.STA_IF)
ssid = 'f@tih'
password = '!1qaz2WSX3edc4RFV%56'

def Baglan():
  station.active(True)
  station.connect(ssid, password)
  if station.isconnected() == True:
    print('Connection successful')
    print(station.ifconfig())
    return True

def getTemp():
  ow = onewire.OneWire(Pin(14))
  ds = ds18x20.DS18X20(ow)
  roms = ds.scan()
  ds.convert_temp()
  time.sleep_ms(750)
  for rom in roms:
    return ds.read_temp(rom)
    

def sayfagetir(value):
    if station.isconnected() == False:
      exec(open('./main.py').read(),globals())
      Baglan()
    response = urequest.urlopen("http://www.temelelektronik.info/lion.aspx?sensor=3&temp={}".format(value))
    #page_source = response.read().decode('Windows-1254')
    #a=page_source.count('Green')
    #print(a)
    #if a==1:
    #led.value(1)
    #else:
    # led.value(0)

while True:
  lasttemp=getTemp();
  sayfagetir(lasttemp)
  sleep(600)

Program Kodları:
http://temelelektronik.info/bilgi.aspx?bilgi=3938