ESP8266 - DS18B20 - 18650

Everything about esp8266 and more.

Moderator: leecollings

Post Reply
blacksn0w
Posts: 99
Joined: Friday 10 March 2017 22:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany
Contact:

ESP8266 - DS18B20 - 18650

Post by blacksn0w »

Hey folks,
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.

Image

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

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&param=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&param=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)
An error message i send to Domoticz log, if there is an error while reading the temperature.

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)
Next step is to use the Deep Sleep mode to enhance battery and to print a nice case, the 3d printer is ready.

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 :roll:

Image
Migration done, hello Home Assistant.
User avatar
heggink
Posts: 980
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: ESP8266 - DS18B20 - 18650

Post by heggink »

Do you use a protected 18650? How do you measure its battery charge state? Looks good!
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
elRedeo
Posts: 9
Joined: Thursday 15 October 2015 23:44
Target OS: Linux
Domoticz version: newest
Location: Germeny
Contact:

Re: ESP8266 - DS18B20 - 18650

Post by elRedeo »

Hi,

an euro less : https://www.conrad.de/de/spannungsregle ... 47028.html

But you have a Problem, if you use unprotected 18650, it will run down to death, also in powersave mode.

A protected will run down to 2.5V, your voltage controller steps out earlier, better would be a stepup/stepdown converter.

For such a simple logic, you do not use normally a pcb, but never the less, it looks good :)

For the beginning good, welcome tinker :) !!!!

P.S. Next time please bend the legs in 90°, it looks a lot better.
Regards
Dominic
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest