Avatar for user56017

user56017

Member since Jun 2015 • Last active Mar 2016
  • 0 conversations
  • 3 comments

Most recent activity

  • in Electronics
    Avatar for user56017

    Thanks for your message. Unfortunately my phone hasn't the right SW 😀... I'll have a look at it when I am at home.

  • in Electronics
    Avatar for user56017

    Hi, I am on holiday... bad conditions for communication... I have some inspirative ideas for shim but as I see you are finished... great work!!! When I am back I will send you some ideas for discussion... maybe next generation of shim :). Please, can you publish electric diagramm to?

  • in General
    Avatar for user56017

    Hi - many thanks for your time and good result!
    I have been on holiday now but luckily I have Pico+ESP8266 on the breadboard with :-).
    I have made some tests "in the battle field" and all have been OK. I have also modified one of your programms and it has been running more than 24 hours without any failure... More tinkering at home again...

    var WLAN_NAME   = "MySSID";
    var WLAN_KEY    = "MyPSW";
    var WEATHER_URL = "http://open.live.bbc.co.uk/weather/feed­s/en/2643743/observations.rss"; 
    
    var wifi;
    
    // This gets the weather out of the XML and writes it to the LCD ... console.log ...
    function parseWeather(xml, date) {
      // No XML parser, so we have to be nasty
      var item = xml.indexOf("<item>");
      var descStart = xml.indexOf("<description>", item);
      var descEnd= xml.indexOf("</description>", descStart);
      var desc = xml.substring(descStart+13,descEnd);
      var titleStart=xml.indexOf("<title>");
      var titleEnd=xml.indexOf("</title>");
      var title=xml.slice(titleStart+7,titleEnd);
      var pubDateStart=xml.indexOf("<pubDate>");
      var pubDateEnd=xml.indexOf("</pubDate>");
      var pubDate=xml.slice(pubDateStart+9,pubDate­End);
      // replace the degrees symbol with a quote - built in font only does first 128 chars
      desc = desc.replace("°","'").replace("°","'")­.replace("mb,","mb");
      // make sure things fit on the tiny screen!
      desc = desc.replace("Wind Direction","Wind").replace("Temperature:­","Temp:");
      console.log("--- "+title);
      // draw one item per line
      var weather = desc.split(", ");
        weather.forEach(function(s) {console.log(s);});
      // Finally print the time from the HTTP request (so we know it's up to date!)
      // var d = new Date(date);
      // var timeStr = d.getHours()+":"+("0"+d.getMinutes()).su­bstr(-2);
      console.log("PubDate: "+pubDate);
      console.log("---");
    }
    
    // Actually get weather off the net and display it
    function getWeather() {
      // do an HTTP request
      require("http").get(WEATHER_URL, function(res) {
        // console.log("Response: ",res);
        // read the whole response into a variable
        // note: this works here but isn't a great idea - big responses can
        // easily use up all the available memory
        var xml = "";
        res.on('data', function(d) { xml += d; });
        // when the connection closes, parse the weather and write to the LCD
        res.on('close', function(d) { parseWeather(xml, res.headers.Date); });
      });
    }
    
    // When we start up...
    function onInit() {
      // if we save()d to flash after we'd already run onInit() we need to clear existing intervals
      clearInterval();
      // Set up the ESP8266
      Serial2.setup(115200, { rx: A3, tx : A2 });
      console.log("Init ESP8266...");
      wifi = require("ESP8266WiFi_0v25").connect(Seri­al2, function(err) {
        if (err) throw err;
        wifi.reset(function(err) {
          if (err) throw err;
          console.log("Connecting to WiFi");
          wifi.connect(WLAN_NAME, WLAN_KEY, function(err) {
            if (err) throw err;
            console.log("Connected");
            // Now start getting weather...
            setInterval(getWeather, 60000); // every 60s
            getWeather(); // do the first one right away
          });
        });
      });
      console.log("Please wait...");
    }
    
    onInit();
    
    
Actions