使用google map geolocation api對raspberry pi進行地理定位

下面範例使用了Google Map GeoLocation Api對raspberry pi進行地理定位,
其中key可在https://console.developers.google.com申請,每日免費額度是2500(每100秒限制10000次)

/*
npm i pi-wifi google-geolocation
node main.js
*/
function geolocation(callback){
  var geolocation = require ('google-geolocation') ({
    key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  });
  var piWifi = require('pi-wifi');
   
  piWifi.scan(function(err, networks) {
    if (err) {
      return console.error(err.message);
    }
    //console.log(networks);
    
    var items=[];
    for(i in networks){
      items.push({
        'macAddress': networks[i].bssid,
        'signalStrength': networks[i].signalLevel,
      });
    }
    
    var params={
      wifiAccessPoints: items,
    };
    
    geolocation (params, (err, data) => {
      if (err) {
        return;
      }
      
      var result={
        'lat': data.location.lat,
        'lng': data.location.lng,
        'accuracy': data.accuracy,
        'type': 'wifi',
      };
      
      if(callback &&  typeof(callback) == "function")
        callback(result);
    });
  });
}

geolocation(function(location){
  console.log(location);
  var url = "https://www.google.com.tw/maps/search/"+location.lat+","+location.lng;
  console.log(url);
});

raspberry wifi設定

修改/etc/wpa_supplicant/wpa_supplicant.conf

sudo vim /etc/wpa_supplicant/wpa_supplicant.conf

輸入wifi ap資訊

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 
update_config=1 
country=TW 
network={ 
  ssid = "wifi_ap_ssidname" 
  psk =  "wifi_ap_password" 
  key_mgmt=WPA-PSK 
}

存檔,重開機既可

解決docker在raspberry pi上出現 cgroups: memory cgroup not supported on this system 之錯誤

目前 raspberry pi 2017-11-29-raspbian-stretch 跟 docker 17.11.0會出現 cgroups: memory cgroup not supported on this system 之錯誤
所以暫時解決的辦法是將docker降到17.09.0

sudo apt-get remove -y docker-ce
sudo apt install -y docker-ce=17.09.0~ce-0~raspbian
sudo apt-mark hold docker-ce

等之後問題解決了就可以用下列指令解鎖,並升級

sudo apt-mark unhold docker-ce
sudo apt-get upgrade -y

參考網址: https://goo.gl/DeGr3S