瞎玩物联网系列--Hello 树莓派

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zcw1994/article/details/80494708

条件

  • Raspberry Pi 3b+
  • 32G存储卡
  • mac
  • 网线
  • 面包板、led灯、杜邦线、传感器若干

系统安装

各种下载

刻录镜像

images

允许远程ssh连接

在存储卡根目录新建一个空文件命名为ssh即可,无需后缀

touch /Volumes/boot/ssh

未开机前设置wifi

touch /Volumes/boot/wpa_supplicant.conf

内容如下

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="WiFi-Name"
    psk="12345678"
    key_mgmt=WPA-PSK
    priority=1
}

远程桌面连接

sudo apt-get install xrdp
sudo update-rc.d xrdp defaults

其它

docker

curl -sSL get.docker.com |sh

仅仅是安装,x86、x64的镜像都是不能用的,要使用arm架构的,很少。

nodejs

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
$ sudo apt install nodejs

nginx

  • 安装
sudo apt-get install nginx
  • 配置

建议放在/etc/nginx/con.d/下

gpio

  • 引脚定义

    树莓派40Pin引脚对照表

  • 面包板

    面包板的使用

  • led控制demo

这里使用nodejs控制led

$ mkdir gpio-demo & cd gpio-demo
$ npm init -y
$ npm install -S rpio
$ node
> let rpio = require('rpio')
> rpio.open(11, rpio.OUTPUT)    //rpio.OUTPUT == 1,填1也行,打开11号针脚作为输出
> rpio.write(11, rpio.HIGH)     //rpio.HIGH == 1, 表示11号针脚输出高电平,打开led灯
> rpio.write(11, rpio.LOW)      //rpio.LOW == 0, 表示11号针脚输出低电平,关闭led灯

推荐文章

猜你喜欢

转载自blog.csdn.net/zcw1994/article/details/80494708