For Fun Wemos D1 Mini - Deep Sleep 0.02 A

Posted on
  • Input: 8.0V - 2x Liteon 2500mAh
    Output: 5.52
    Getting: 20mAh
    Send to server every 5 min from sensor AM2301


    1 Attachment

    • 20161005_191403_resized.jpg
  • Neat!

    So how'd you do it?

  • What exactly are you powering with these 20mA?

  • This only one board Wemos D1 Mini + Sensor DHT21(AM2301)

    My script:

    // Init ESP8266
    var ESP8266 = require("ESP8266");
    //ESP8266.setLog(1);
    //ESP8266.printLog();  
    E.setClock(80);
    
    
    // Init WiFi Networks
    var wifi = require("Wifi");
    wifi.setHostname("WemosD1mini");
    wifi.connect("XXXX", {password:"XXXX"}, function(err){
      setTimeout(function(){
        console.log("connected? err=", err, "info=", wifi.getIP());
      },5000);
    });
    wifi.stopAP();
    wifi.save();
    
    
    
    var dht2 = function(){
      var dht = require("DHT22").connect(D14); // GPIO0
      dht.read(
        function(a){
          console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());
          var newDht = a.temp.toString()+","+a.rh.toString();
          postToServer(newDht);
      });
      return true;
    };
    
    
    // Send Every 5 min
    setInterval(function() {
    
      setTimeout(function () {
        dht2();
      }, 20);
      
    }, 300000);
    
    setDeepSleep(1);
    
    function postToServer(data){
      var options = {
        host: 'XXXXX',
        port: '80',
        path:'/event',
        method:'POST',
        headers: {
          "Content-Type":"application/json",
          "Content-Length":data.length 
        }
      };
    
      require("http").request(options, function(res){
        var d = "";
        res.on('data', function(data) { d+= data; });
        res.on('close', function(data) {
          console.log("Closed: "+d);
        });
      }).end(data);
    } 
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

For Fun Wemos D1 Mini - Deep Sleep 0.02 A

Posted by Avatar for Aleksandrs @Aleksandrs

Actions