since i got the first working version of my pcb, i would like to share the results with you.
I searched for a easy way to implement a few DS18B20 sensors to my Domoticz system. There was no possible power sources to supply them, so i had to think about that, too.
I've used the following components to implement the idea:
Standard ESP8266 ESP-01 unit.
4,7k Resistor
DS18B20
LF33ABV TO-220AB Voltage Regulator - https://www.conrad.de/de/spannungsregle ... 85794.html
Self designed PCB
So i've decided to design my own PCB in this project to fit all my needs. Now it is possible to use a 18650 Li-ion battery and the voltage regulator is turning down the voltage to 3.3V, perfect for the ESP8266.
Without the regulator, the battery would have powered the board with around 4V, when fully load. Slightly too much.

I've prepared the ESP with NodeMCU and soldered the components to the PCB.


Now the board is fully usable, but LUA is missing.
I've used the following code to connect the Board to Domoticz.
To get data from the DS18B20 upload https://github.com/nodemcu/nodemcu-firm ... s18b20.lua to the ESP.
domoticz.lua
Code: Select all
--domoticz.lua
require('ds18b20')
-- ESP-01 GPIO Mapping
gpio0 =3
gpio2 =4
ds18b20.setup(gpio2)
-- Define Domoticz Server
-- For example: 192.168.1.20:1234
domoticz="192.168.178.10:8080"
-- Domoticz Dummy Sensor ID for Temperature
sensorid=94
-- Set Timer to 30 Seconds
tmr.alarm(0,30000, 1, function()
-- Read temperature from sensor
t=ds18b20.read()
-- Check if there a "sendable" temperature
if(t==nil) then
print("Error while reading temperature")
errormsg="Sensor%20" .. sensorid .. "%20measuring%20error."
http.get("http://" .. domoticz .. "/json.htm?type=command¶m=addlogmessage&message=" .. errormsg, nil, function(code, data)
if (code < 0) then
print("HTTP request failed")
else
print(code, data)
end
end)
else
print("30 seconds over - Temperature: " .. t .. " C\n")
http.get("http://" .. domoticz .. "/json.htm?type=command¶m=udevice&idx=" .. sensorid .. "&nvalue=0&svalue=" .. t, nil, function(code, data)
if (code < 0) then
print("HTTP request failed")
else
print(code, data)
end
end)
end
end)
init.lua
Code: Select all
--init.lua
wifi.setmode(wifi.STATION)
wifi.sta.config("YOURWIFI","WIFIPASSWORD")
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
print("IP unavaiable, Waiting...")
else
tmr.stop(1)
print("ESP8266 mode is: " .. wifi.getmode())
print("The module MAC address is: " .. wifi.ap.getmac())
print("Config done, IP is "..wifi.sta.getip())
dofile ("domoticz.lua")
end
end)
Feel free to comment and giving tips, this is my second PCB ever, the first was extremely awful and destroyed a ESP and 18650, nice firework

