The Skygear IoT plugins only works with Skygear v0, but not in latest v1.
This is a simple Raspberry Pi setup demonstrating the usage of Skygear JS SDK in Raspberry Pi.
This demo project demonstrates the followings:
- register the active device on Skygear server
- send tempurature and other Raspberry Pi live information to the server periodically
- fetch recent records from Skygear server
Firstly please follow the installation guide on raspberrypi.org. We assume you would have a clean Raspbian installed on your pi device.
-
Find your Raspberry Pi IP at your router, or follow the instruction for scaning your subnet: https://www.raspberrypi.org/documentation/remote-access/ip-address.md
Use
nmap
to scan IPs on your network. You may have to usesudo
to get device infosudo nmap -sP 192.168.0.0/22
result:
Host is up (0.0064s latency). MAC Address: B8:XX:XX:XX:XX:9X (Raspberry Pi Foundation) Nmap scan report for 192.168.2.XXX
-
ssh to the Raspberry Pi,
ssh [email protected]
default password:raspberry
- To change your password, use command
passwd
. For more detailed instruction, please follow the instruction here: https://www.raspberrypi.org/documentation/linux/usage/users.md
- To change your password, use command
-
Update the node environment:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install nodejs
-
Check your node installation by runing
node -v
, it should show 6.x. You may also check your npm version by runingnpm -v
.
This project includes a simple health report of the Raspberry Pi to Skygear. It also includes a command to list out the latest health data of the Raspberry Pi.
-
cd /home/pi/
-
Clone the project
git clone https://github.com/skygear-demo/raspberrypi-example.git
-
Go to the project directory
cd raspberrypi-example
-
Install the required deps for this project
npm install
-
Specify environment variables required by this demo app. A script is provided to generate the
skygear.env
file needed. CheckoutSKYGEAR_API
andSKYGEAR_ENDPOINT
at https://portal.skygear.io- Run
./skygear.sh gen SKYGEAR_ENDPOINT SKYGEAR_API
- Skygear is a user based system, you can register your raspberrypi as a normal user to interact with Skygear. We suggest to use Serial No. and Mac address as the username and password respectively. The script is doing this as a showcase.
- You could use other system identifers such as IPv6 Address as well. The principle is to have a tuple that could identify your device at Skygear.
- Run
-
After the value is edited, copy
skygear.sh
to/etc/profile.d/skygear.sh
. Run. /etc/profile.d/skygear.sh
to activate the environment variables for your current session. -
Install the health check service as system services,
sudo cp skygear-health.service /etc/systemd/system/skygear-health.service sudo systemctl daemon-reload sudo systemctl start skygear-health sudo systemctl enable skygear-health
-
Check the log by
sudo journalctl --follow -u skygear-health
-
Run
./query.js
to query and display the recent health data from Skygear.