diff options
-rw-r--r-- | config.lua | 55 | ||||
-rw-r--r-- | display_setup.lua | 30 | ||||
-rw-r--r-- | local_config.lua | 4 | ||||
-rw-r--r-- | update_display.lua | 16 | ||||
-rw-r--r-- | update_time.lua | 32 | ||||
-rw-r--r-- | wifi_config.lua | 47 |
6 files changed, 0 insertions, 184 deletions
diff --git a/config.lua b/config.lua deleted file mode 100644 index 6764f12..0000000 --- a/config.lua +++ /dev/null @@ -1,55 +0,0 @@ - --- wifi config start -myIP = "" -AP_name = "beamhome" -AP_password = "C930F921D7F672A23C55638F3B" - --- time sync -ntp_server = "192.168.2.17" -uts_offset = -4*60*60 -- EST time zone, use 4 for summer and 5 for winter - --- timers -tmr_tmp = 0 -tmr_time = 1 -tmr_display = 2 -tmr_weather = 3 -tmr_server = 4 - - --- weather station setup -weather_update_interval = 5000 -display_update_interval = 1000 -time_update_interval = 500 - --- PINS -dht_pin = 4 -relay_pin = 1 -relay_pin_default_setting = 0; -- gpio.LOW - --- Display defaults -lineH = 10 -dstr = "" -tstr = "" -wstr = "" -IPstr1 = "IP1:unknown" -IPstr2 = "IP2:unknown" - --- Some stats -dht_data={} -dht_data.temperature = "" -dht_data.humidity = "" -dht_data.status = "Unknown" -dht_data.temp_max = -100000000; -- should be crazy small to be overwritten by first read -dht_data.temp_min = 100000000; -- should be crazy big to be overwritten by first read -dht_data.humi_max = -100000000; -- should be crazy small to be overwritten by first read -dht_data.humi_min = 100000000; -- should be crazy big to be overwritten by first read -dht_data.last_checked_time = 0; - -relay_data={} -relay_data.switched=0; -relay_data.switch_time=relay_pin_default_setting; -relay_data.status="OK" - -nodemcu_data={} - - diff --git a/display_setup.lua b/display_setup.lua deleted file mode 100644 index 78dfb21..0000000 --- a/display_setup.lua +++ /dev/null @@ -1,30 +0,0 @@ --- setup I2c and connect display -function init_i2c_display() - -- Pinsa are hardwired on the oled display shield - local sda = 2 -- GPIO14 - local scl = 1 -- GPIO12 - local sla = 0x3c -- 0x3c or 0x3d - i2c.setup(0, sda, scl, i2c.SLOW) - -- old 1.5.1 nodemcu firmware - -- disp = u8g.ssd1306_64x48_i2c(sla) - -- new 3.0.0 nodemcu firmware - disp = u8g2.ssd1306_i2c_64x48_er(0, sla) -end - -function prepare() - -- old 1.5.1 nodemcu firmware - --disp:setFont(u8g.font_6x10) - --disp:setFontRefHeightExtendedText() - --disp:setDefaultForegroundColor() - --disp:setFontPosTop() - -- old 3.0.0 nodemcu firmware - disp:setFont(u8g2.font_6x10_tf) - disp:setFontRefHeightExtendedText() - disp:setDrawColor(1) - disp:setFontPosTop() -end - -init_i2c_display() -prepare() - - diff --git a/local_config.lua b/local_config.lua deleted file mode 100644 index 3124d29..0000000 --- a/local_config.lua +++ /dev/null @@ -1,4 +0,0 @@ -local_config={} -local_config.relay_present=false; -local_config.display_present=true; - diff --git a/update_display.lua b/update_display.lua deleted file mode 100644 index fe3d08d..0000000 --- a/update_display.lua +++ /dev/null @@ -1,16 +0,0 @@ -function update_display() - disp:clearBuffer() - disp:drawStr(0, 0*lineH, dstr) - disp:drawStr(0, 1*lineH, tstr) - --disp:drawStr(0, 2*lineH, "test") - disp:sendBuffer() - - display_tmr:start() -end - --- set up timer for display update -display_tmr=tmr.create() -display_tmr:register(display_update_interval, tmr.ALARM_SEMI, function() update_display() end) - -print("--- Starting Display Updates ---") -display_tmr:start() diff --git a/update_time.lua b/update_time.lua deleted file mode 100644 index a57217c..0000000 --- a/update_time.lua +++ /dev/null @@ -1,32 +0,0 @@ -function update_time() - -- Update time - -- note that rtctime.get() provided updates only if time was set at least once - -- either with rtctime.set() or with sntp.sync() which sets it internally - sec, usec = rtctime.get() - local usingUptime=false; - if ( sec <= 0) then - sec = tmr.time(); -- uptime - usingUptime = true; - else - sec = sec + uts_offset; - end - - tm = rtctime.epoch2cal(sec) - -- print(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])) - if ( usingUptime ) then - local days = math.floor(sec/86400) - dstr = string.format("up %03d days", days) - else - dstr = string.format("%04d/%02d/%02d", tm["year"], tm["mon"], tm["day"]) - end - tstr = string.format("%02d:%02d:%02d", tm["hour"], tm["min"], tm["sec"]) - - time_tmr:start() -end - --- set up timer for time update -time_tmr=tmr.create() -time_tmr:register(time_update_interval, tmr.ALARM_SEMI, function() update_time() end) - -print("--- Starting Time Updates ---") -time_tmr:start() diff --git a/wifi_config.lua b/wifi_config.lua deleted file mode 100644 index 9f43d28..0000000 --- a/wifi_config.lua +++ /dev/null @@ -1,47 +0,0 @@ -local wifiConfig = {}
-
--- wifi.STATION -- station: join a WiFi network
--- wifi.SOFTAP -- access point: create a WiFi network
--- wifi.wifi.STATIONAP -- both station and access point
-wifiConfig.mode = wifi.STATIONAP -- both station and access point
-
-wifiConfig.accessPointConfig = {}
-wifiConfig.accessPointConfig.ssid = "ESP-"..node.chipid() -- Name of the SSID you want to create
-wifiConfig.accessPointConfig.pwd = "ESP-"..node.chipid() -- WiFi password - at least 8 characters
-
-wifiConfig.accessPointIpConfig = {}
-wifiConfig.accessPointIpConfig.ip = "192.168.23.1"
-wifiConfig.accessPointIpConfig.netmask = "255.255.255.0"
-wifiConfig.accessPointIpConfig.gateway = "192.168.23.1"
-
-wifiConfig.stationPointIpConfig = {}
-wifiConfig.stationPointIpConfig.ip = "10.160.137.16" -- provided by WM IT department
-wifiConfig.stationPointIpConfig.netmask = "255.255.255.0" -- provided by WM IT department
-wifiConfig.stationPointIpConfig.gateway = "10.160.137.1" -- provided by WM IT department
-
-wifiConfig.stationPointConfig = {}
-wifiConfig.stationPointConfig.ssid = "WM-Welcome" -- Name of the WiFi network you want to join
-wifiConfig.stationPointConfig.pwd = "" -- Password for the WiFi network
-
-
-
-
--- Tell the chip to connect to the access point
-
-wifi.setmode(wifiConfig.mode)
-print('set (mode='..wifi.getmode()..')')
-
-if (wifiConfig.mode == wifi.SOFTAP) or (wifiConfig.mode == wifi.STATIONAP) then
- print('AP MAC: ',wifi.ap.getmac())
- wifi.ap.config(wifiConfig.accessPointConfig)
- wifi.ap.setip(wifiConfig.accessPointIpConfig)
-end
-if (wifiConfig.mode == wifi.STATION) or (wifiConfig.mode == wifi.STATIONAP) then
- print('Client MAC: ',wifi.sta.getmac())
- wifi.sta.config(wifiConfig.stationPointConfig)
- wifi.sta.setip(wifiConfig.stationPointIpConfig)
-end
-net.dns.setdnsserver("128.239.51.1", 1)
-print('DNS Server 1: '..net.dns.getdnsserver(1))
-print('IP: '..wifi.sta.getip())
-
|