Here's a *duino-less (*pi-less) simple project using ESP11 (ESP8266) Wifi Module and SHT10 humidity-temperature sensor.
init.lua:
wifi.setmode(wifi.STATION) wifi.sta.config("WIFI_SSID","WIFI_PASSWORD") local DAT = 4 local CLK = 3 function DL() gpio.write(DAT, gpio.LOW) gpio.mode(DAT, gpio.OUTPUT) end function DH() gpio.mode(DAT, gpio.INPUT) gpio.write(DAT, gpio.HIGH) end function CL() gpio.write(CLK, gpio.LOW) end function CH() gpio.write(CLK, gpio.HIGH) end function DR() gpio.mode(DAT, gpio.INPUT) return gpio.read(DAT) end function W8() for i = 1, 100 do tmr.delay(10000) if DR() == gpio.LOW then return true end end return false end function RB() local val = 0 for i = 0, 7 do CH() val = val*2 + DR() CL() end return val end function shtread(cmd) DH() CH() DL() CL() CH() DH() CL() for i = 0, 7 do if bit.band(cmd, 2^(7-i))==0 then DL() else DH() end CH() CL() end CH() CL() if not W8() then return nil end DH() local val = RB() DH() DL() CH() CL() DH() val = val*256 + RB() DH() CH() CL() return val end page=[[<head><meta charset="utf-8"/> <link href="http://projectproto.blogspot.com/favicon.ico" rel="icon"/> <title>ESP+SHT</title></head> <body><h1>ESP8266 and SHT1x</h1><h2 id="T">T??</h2><h2 id="H">H??</h2> <script> function update(){ var xrq = new XMLHttpRequest(); xrq.onreadystatechange=function(){ if (xrq.readyState==4 && xrq.status==200){ var th=JSON.parse(xrq.responseText); var t0=th["t"], h0=th["h"]; var t=(t0*0.01)-39.7; var hl=(0.0367*h0)+(-0.0000015955*h0*h0)-2.0468; var h=(t-25.0)*(0.01+(0.00008*h0))+hl; document.getElementById("T").innerHTML="Temperature: "+t.toFixed(2)+"°C"; document.getElementById("H").innerHTML="Humidity: "+h.toFixed(2)+"%";} } xrq.open("GET","/get/sht",true); xrq.overrideMimeType("application/json"); xrq.send(null); }setInterval(update, 1000); </script></body>]] srv=net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive", function(client,request) local buf = ""; local _, _, mtd, path, _ = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); if(mtd == nil)then _, _, mtd, path = string.find(request, "([A-Z]+) (.+) HTTP"); end if path == "/" then buf = buf..page elseif path == "/get/sht" then t = shtread(3) h = shtread(5) if (t ~= nil and h ~= nil) then buf = buf.."{\"t\":"..t..", \"h\":"..h.."}" end end client:send(buf) client:close() collectgarbage() end) end)
References:
ESP8266 Web Server Tutorial
Github esp8266 sht10
e-Gizmo ESP11 kit
ESP8266 wiki
NodeMCU firmware
NodeMCU http server
I had been trying to get something special like that at length but now I have finally got it.
ReplyDeletechemical dosing system
This post really help me a lot and I have learnt some new things from your blog.
ReplyDeletedosing pump manufacturer in india
Admin, if not okay please remove!
ReplyDeleteOur facebook group “selfless” is spending this month spreading awareness on prostate cancer & research with a custom t-shirt design. Purchase proceeds will go to cancer.org, as listed on the shirt and shirt design.
www.teespring.com/prostate-cancer-research
Thanks
Very nice post !!!
ReplyDeleteLinkITes is an offshore
Software Development Company specialized in offering
IT outsourcing services
Tambah pengetahuan Serta Informasi anda lebih Dalam Sobat !!!
ReplyDeleteanda bisa mengunjungi Website kami di bawah ini :
1. https://www.youtube.com/channel/UCNy48zN8a3K1Na0lYoGZnQA
Thank you so much for your post.
ReplyDeletegoldenslot casino
บาคาร่าออนไลน์
gclub casino
ฉีดเผาผลาญไขมัน
ReplyDeleteของใหม่
ฉีดลดแฟตที่ปลอดภัยรวมทั้ง
มีคุณภาพ
ที่สุดในโลกที่ศิลปิน
ฮอลลีวู้ดใช้ ประกัน
ผล
กับการฉีดลดแฟตที่เยี่ยมที่สุด
ได้ผล
เยอะที่สุด
ในโลกจากอังกฤษ
ยุโรป อเมริกาแล้วก็
กาหลีตัวยาที่ทรงอำนาจ
ที่สุดในตอนนี้
ฉีดสลายไขมัน
meso fat
Thank you for giving the information and its usefull for me training with placement company in Hyderabad
ReplyDeleteThank you for giving the information
ReplyDeleteYaaron Studios is one of the rapidly growing editing studios in Hyderabad. We are the best Video Editing services in Hyderabad. We provides best graphic works like logo reveals, corporate presentation Etc. And also we gives the best Outdoor/Indoor shoots and Ad Making services.
Best video editing services in Hyderabad,ameerpet
Best Graphic Designing services in Hyderabad,ameerpet
Best Ad Making services in Hyderabad,ameerpet
ReplyDeleteThis are new articles style for you. http://site-2272261-6860-7525.mystrikingly.com/blog/stunning-garage-find-bizarre-history-lamborghini-miura-s-stored-in-body amazin555 http://saku38.cabanova.com/stunning-garage-find-bizarre-history-lamborghini-miura-s-stored-in-body-shop-for-45-years.html It might help you to write or think some new idea.
https://sakukrub98.hatenablog.com/entry/2020/08/19/124310?_ga=2.267397578.594202270.1597630955-1286484823.1596077192 Thanks for sharing such a wonderful post.
https://sakukrub1.wixsite.com/mysite/post/in-2020-lexus-is-all-about-one-f-ing-thing-in-particular I am very glad for reading my articles.
I just bought a lot of Mirror of Kalandra from POECurrency, super cheap price and extremely fast and legal delivery, which allows me to show my ambitions in the Path of Exile Expedition League!
ReplyDeleteAttached link: https://www.poecurrency.com/