SmartHome, Your own weatherstation with ESP8266 to measure temperature and humidity

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SmartHome, Your own weatherstation with ESP8266 to measure temperature and humidity

    Before you start, please read my previous topics how to program and prepare your esp8622 here: http://coding-talk.com/forum/main-fo...ows-is-similar Click image for larger version

Name:	Screenshot 2016-07-08 11.09.15.png
Views:	2
Size:	99.3 KB
ID:	153408
















    to make your weatherstation,
    you need:Solder additional the 104 ceramic capacitor between VCC and GND pin of esp8266-03 to use it as decoupling capacitor for more stability and prevent unexpected restarts.

    Download the attached weatherstation.zip php script and upload it to your webhost, remember the url of the receive_data.php file, you will need it in next steps.

    Make sure you have correct firmware installed, this setup requires the dht and http module included in your build.

    upload this init.lua code to your esp8266
    Code:
    --init.lua
    wifi.setmode(wifi.STATION)
    wifi.sta.config("your_wifi_ssid", "password")
    wifi.sta.connect()
    
    -- Connect
    tmr.alarm(1, 1000, 1, function()
        if wifi.sta.getip()== nil then
            print("IP unavaiable, Waiting...")
        else
            tmr.stop(1)
            print("IP avaiable:"..wifi.sta.getip())
            dofile ("main.lua")
        end
    end)
    and main.lua
    Code:
    -- main.lua --
    tmr.delay(5*1000000)
    
    sensor = 1 --define the sensor number if you use multiple
    pin = 4
      
     -- send data every 10 minutes
    tmr.alarm(2, 600000, 1, function()    
    
    
    status, temp, humi, temp_dec, humi_dec = dht.read(pin)
    
    http.get("http://yoursite.net/weatherstation/sensors/receive_data.php?temp="..temp.."&humi="..humi.."&sensor="..sensor.."&key=blabla", nil, function(code, data)
        if (code < 0) then
          print("HTTP request failed")
        else
          print(code, data)
        end
    end)
    
    end)
    change yoursite.net in the code to your domain name, you can also define your custom key in the url instead blabla and do the same in the receive_data.php file which is located in the attached php script.

    Now connect everything like on the image: Click image for larger version

Name:	Untitled Sketch_Steckplatine.jpg
Views:	1
Size:	338.3 KB
ID:	153417









    if you have done everything correctly, you should be able to view your sensor data in the generated graph with a php script.

    There is another better, battery saving setup with esp8266 sleep mode, if you are interested in such setup please post your request here.
    Attached Files

  • #2
    Love it man, maybe I should start posting basics about doing different stuff with android; Which in return will index more pages in search engines for users..

    Comment


    • #3
      Originally posted by andre3 View Post
      Love it man, maybe I should start posting basics about doing different stuff with android; Which in return will index more pages in search engines for users..
      will be cool

      Comment

      Working...
      X