Posted on
  • After getting the bangle 2, I realised I like this event-based loop more than arduino coding style, so I took a bit of yesterday afternoon to reprogram my home environment monitors to be espurinos.

    Hardware-wise 8266 + dht22 + cheap screen.

    I'm on the wrong pc right now, I'll copy-paste the code I threw on them, it's about 3 tutorials sewn together.

    They were sending mqtt to an internal mosquitto server, but it kept falling over and it's a pain to unplug all 3 to fix them wired in. Now the node-red box queries them with the super tiny webserver the espurino can hold. Bonus - I can reprogram them over the air, at least when I'm at the right computer.

  • Nice - thank you! It's always nice to know when people are enjoying using it :)

  • I might try turning this into a full-blown tutorial for the pages, but in case that never gets started, here's the code I've copy-pasted together:

    var temperature;
    var humidity;
    var dht = require("DHT22").connect(D2);
    function onPage(req, res){
      var page = temperature + "," + humidity;
        res.writeHead(200, {'Content-Type': 'text/html'});
    function writeScreen(){
     g.drawString(temperature, 0, 0); 
      g.drawString(humidity, 0, 30);
    // I2C
    var g = require("SSD1306").connect(I2C1, writeScreen);
    g.setFont("4x6", 5);
    function readDHT(){ {
       temperature = a.temp.toString();
        humidity = a.rh.toString();
        console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());
    setInterval(readDHT, 2000);

    My asks http://esp_hostname.local for the page, and parses it as csv.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview


Posted by Avatar for jimr1603 @jimr1603