Inside the iot_robots
folder you'll find the following:
-
An
/activities
folder. If you want to do individual activities then start out here. Some of them have starter code in and some not. -
The
/projects
folder is where you'll do more interesting things like combine different activities or try out one your ideas. There are example projects there and some other ideas you might want to try out. All of this is described in theREADME
. -
We've created a Sphero-CLI tool to get you started super quick. Have a look inside
/resources
to find it. The repo is here: https://github.com/OfferZen-Make/sphero-cli
-
Sphero's collision detection function is very unreliable!
-
When connecting an IoT device to AWS programmatically, each Client ID must be unique. This becomes important when you subscribe with one device and publish with another.
-
Technically it is possible to connect multiple Spheros to a Pi, but this requires hacking the bluetooth device implementation in Sphero.js.
-
You can quickly and easily print the list of all Spheros with their details by running
sphero-list
in the terminal. -
Don't spend too much time in Sphero-CLI! :) It's just there to try out Sphero commands.
-
Our documentation of Sphero's commands is in the readme of the Sphero-CLI tool.
-
The official SDK has a number of examples that show off what Sphero can do. Check them out here
-
The official SDK has a Javascript API section on their website. Makers haven't found this super useful, so try the above two first!
To connect to your Sphero, you need to tell your Pi which Sphero is yours. On Linux (which is running on the Pi) the argument is the device's MAC address and on macOS it is the Device ID.
On your Pi, just run the following on the command line to get a list of the Sphero IDs:
sphero-list
Alternatively, you can just look it up in the table below.
Sphero Label | Device name | MAC address | Device ID |
---|---|---|---|
A | SK-5186 | F8:CC:A1:A7:51:86 | |
B | SK-7D19 | FF:AF:08:F6:7D:19 | 3e35859590014eaea8ed68eb3d5874f2 |
C | SK-BEAD | EB:76:90:85:BE:AD | 38a2cd60b8f14032896de2c9739d5ffe |
D | SK-40A2 | F5:77:55:BE:40:A2 | |
E | SK-C345 | E0:01:D9:64:C3:45 | |
F | SK-D4A7 | FA:34:A8:E7:D4:A7 | 47936f015f7148ae9ed81ef2a08f91b4 |
G | SK-0EC0 | FD:94:C6:CA:0E:C0 | |
H | SK-70C4 | E8:CC:F3:D0:70:C4 | 6542b255dc1741089e5fa58752f67fea |
I | SK-EC32 | C7:8A:28:6D:EC:32 | |
J | SK-76D8 | CB:68:ED:5F:76:D8 | 2493f27408cc41ad82b6abb323555f5b |
K | SK-2368 | E6:EA:05:40:23:68 | |
L | SK-E1F8 | C2:92:5C:11:E1:F8 | |
M | SK-B7DC | CC:A9:1E:50:B7:DC | 5cb4cdd41c1b4b0b8b5b0c185458b31b |
O | SK-5FCA | F4:C3:EB:77:5F:CA | |
P | SK-E8F5 | C1:EA:BB:43:E8:F5 |
Sharing is good, so contribute to the community by pushing your code to Github! Also, you probably want to have the code on your own Github profile. The readme
in the /projects
folder describes how you'll go about doing that.
NOTE: If you have any comments/suggestions about the process above then please send a message to @dan and/or @nuclearnic on Slack :)
-
A very lightweight editor you can use is called Geany.
-
If you want to install a different editor or extra extensions then go ahead! Remember that not everything you're used to has an ARM-compatible version.
-
If your Pi gets a bit slow then try closing some browser windows. If that fails then do a restart!
You might want to code on your own machine and not on the Pi itself. In that case, you can control the Pi from your own machine with VNC. Here's how to do it:
-
Click on the VNC icon on the top-right of the control panel
-
Note the IP address of your Pi
-
Use VNC-Viewer on your own device and connect to the IP Address of your Pi
-
You will be asked for a username and password: Enter "pi" and "raspberry" for these
-
That´s it!
If you want to ssh
then that's cool too B-)
- Chaining mulitple Sphero commands with async/await and delays:
async function instructions() {
orb.color("green")
await orb.roll(50,180).delay(3000)
await orb.roll(100,0).delay(3000)
await orb.roll(200,180)
}
orb.connect(instructions)
- Using async/await and delay to calibrate Sphero:
async function instructions() {
// post-calibration instructions
}
async function calibrate() {
orb.startCalibration();
await orb.color("red").delay(3000)
orb.finishCalibration()
instructions()
}
orb.connect(calibrate)
- Using
setInterval
to flash green and red forever:
async function flashForever() {
setInterval(async () => {
await orb.color("green").delay(1000)
await orb.color("red")
}, 2000);
}
orb.connect(flashForever)
- When using
setInterval
, you canclearInterval
to exit the delayed loop. The code below will change Sphero's colour 10 times then exit:
async function flashForTenSeconds() {
let i = 0
let interval = setInterval(async () => {
await orb.color("green").delay(1000)
await orb.color("red")
console.log(i)
if(i == 4){
console.log('how')
clearInterval(interval)
}
i += 1
}, 2000);
}
orb.connect(flashForTenSeconds)
- If you want to play around with Gobot, it is already installed. Check out
/home/pi/go/src/gobot.io/x/gobot
and ask the Make Masters for help. Golang is tricky if you haven´t used it before! ;)