raspberry pi 關閉7寸觸控螢幕的方法

關閉:

sudo sh -c 'echo 1 > /sys/class/backlight/rpi_backlight/bl_power'

開啟:

sudo sh -c 'echo 0 > /sys/class/backlight/rpi_backlight/bl_power'

切換:

if [ "$(cat /sys/class/backlight/rpi_backlight/bl_power)" -eq "0" ]; then sudo sh -c "echo 1 > /sys/class/backlight/rpi_backlight/bl_power"; else sudo sh -c "echo 0 > /sys/class/backlight/rpi_backlight/bl_power"; fi

參考出處:

使用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);
});

install nodejs 6 on raspberry pi

armv6的raspberry pi似乎無法直接用apt-get install方式安裝.
所以改用下列語法安裝

wget http://nodejs.org/dist/v6.9.5/node-v6.9.5-linux-armv6l.tar.gz  && \
tar -xzf node-v6.9.5-linux-armv6l.tar.gz && \
mv node-v6.9.5-linux-armv6l nodejs  && \
rm node-v6.9.5-linux-armv6l.tar.gz && \
cp -R * /usr/local/ && \
rm -r -f nodejs && \
ln -s /usr/local/nodejs/bin/node /usr/bin/node && \
ln -s /usr/local/nodejs/bin/npm /usr/bin/npm

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