Kassian's IoT Hour
Presented by: Kassian Rosner Wren
Originally aired on March 4, 2022 @ 8:30 AM - 9:30 AM EST
Let's dig into how you can use Serverless to supercharge your IoT projects! We'll walk through setting up a remote sensor and LED with Cloudflare Workers, Workers KV, and a Raspberry Pi
English
Transcript (Beta)
Good afternoon everyone. I'm Kassian and it's time for Kassian's IoT Hour. So today what we're going to do is we're going to rewind and we're going to start up a Pi from scratch.
We've got this Pi here and it's got a Pimeroni Unicorn HD on it and what we're going to do is we're going to write the driver to node and then we're going to run it.
So yeah that's what we're going to do today. So hope you enjoy it. We're going to, like I said, start with flashing the Pi with what's called Bolena Etcher and then put the SD card in here and get started from there.
So what we'll do is let me share my screen real quick.
Okay and so I've got my screen here and what I'm going to do is I'm going to go over to, oh I don't have Bolena Etcher running right now, so let's get that.
Okay so the first thing we're going to do is we're going to take the Raspberry Pi image.
We're going to select target. We've got this generic storage device which is our micro SD card.
We select it and we'll flash. It's going to ask for my password. There it goes.
Okay so while that's flashing we're going to get ready for the rest of the process.
So I've written down this entire process in the Cassian IoT Hour readme. So what we've got is we are currently installing Raspbian and then we are going to set up Wi-Fi and SSH so that we can SSH directly into the Pi and set it up while we're at work.
And then we will SSH in and get started and we'll do all these steps. We'll install the Cloudflare vDamon so that we can have Arduo access and then we'll get started writing, pulling down the IoT Hour code and then go from there.
So it's flashing and it's going to be verifying.
Luckily validation is a little bit faster than flashing.
Okay so now we can close the Linux Etcher and we're going to remove and put the SD card back in.
And we're going to go into mount. Hopefully there will be a volume. That's it.
I've been spending too much time on Linux. So let's see what's in this folder.
Make sure it looks right. It does. First we're going to test the file called SSH and what that does is allows us to SSH into the Pi remotely.
That's not done by default.
And then another thing we're going to do is we're going to say get the file.
Okay so now, oh weird.
Don't know why I copied that.
Awful lot of stuff there. You know what?
We can fix this with this.
Let's try this one more time. Okay and we didn't get all the extra stuff this time.
That's helpful. Okay put my network here and then I'm going to say yes.
Yes.
No. There we go.
Okay so now we can take the card out.
And we're going to put it in the Raspberry Pi and then we're going to plug the Raspberry Pi in.
Raspberry Pi is plugged in now. While it's booting up, we'll get ready to SSH in.
Okay.
Thinking about it. There it goes.
Oh right. We're going to have to... Okay so we're in the Raspberry Pi.
The first thing we're going to do is run the password because this is on a unsecured password.
Come on Pi, you can do it.
Oh damn it.
There we go. Okay there we go.
So we now have updated the password to something else. Now what we need to do is we need to sudo .getupdates.
What this is doing is it's updating all the packages that are available to it and then we'll run upgrade which will actually get the packages together and upgraded.
This will take a little bit.
Hmm. Hmm. Okay so now we're going to sudo .getupgrade.
This will take a minute.
Hmm.
Hmm.
Hmm.
Hmm.
Hmm.
Hmm.
Okay should be done soon.
Almost done.
There we go.
So the next thing we're going to do is we're going to go back to our steps.
We're going to install Node.js.
Okay.
Thanks.
So yeah.
So now we have node version 14.5. So that's the latest version of stable node. So what we're going to do next is update npm.
Hmm.
Hmm. Okay so next we're going to change npm's working directory.
Okay.
Okay.
Next we will install the Cloudflare daemon.
So first we're going to get, first we're going to actually create a folder.
Okay.
So and now we're going to check if it works.
Perfect.
And then we're going to use this to log in. What this will do is it'll give us a URL.
We can go into our browser and log in with.
Okay.
How do I get it back on my.
Here we go.
Okay.
Okay. So now we log in and then that and now we'll go back to here. Okay.
Yes. Okay.
So I downloaded this automatically. Okay. That's right I need to make the directory.
Okay.
So we got the configuration.
Okay. Then we install the daemon.
Okay. Try that again.
There we go. Awesome. All right. Okay. All right, so what we're going to do is we're going to reboot and we'll have to wait a second and see if that helps the daemon kind of get its feet underneath it.
So let's try ssh-ing back in, I'll give it some time to reset.
Still failed.
Okay, it runs on its own.
That's interesting. All right, we'll deal with that in a little bit.
For now, let's get our... So I have a public key that I'm going to put in here.
Questions?
Okay.
Okay. So back here. We're actually going to cancel out of this.
Okay. Okay.
And we create the file.
Leave.
That is not what I wanted. So, here. Okay.
Key stored here. Yes, I will rotate this key as soon as I'm done. Show.
Back up to code.
And so what we're going to do is we're going to pull down the IoT Hour.
And we're going to install Git.
Okay. Okay.
So now Git clone. Okay. Okay, we're just going to try this through HTTPS.
Okay, so we've got the code.
So now what we're going to do is we're going to start writing the drivers for the device.
So first thing we're going to have to do is change some settings.
First we're going to change the host name to.
And then we're going to turn on the PC.
We're going to turn on the PI. I'm not sure if it uses.
And then we're going to finish. It's going to ask me to reboot. We'll say yes.
And then when we get SSH. Let's make sure it's not the singular.
That was it.
Hmm.
There we go.
We're going to go into SSH IoT Hour.
PI code. And we're going to create a new directory called Unicorn Hunt.
We're going to do that in a minute.
Yes. Now we're going to open up Visual Studio Code.
And we're going to. We're going to. We're going to.
We're going to say host.
While that's going, I'm going to close this window.
It's ready.
So we're going to open the folder. We're going to go into code. We're going to go PI code.
So. Jason.
And so now we're going to do is. We're going to. Take a look at what.
So what I've got here is the unicorn had HD library that's in Python.
And so we're going to rewrite this in node. So let's take a look at what we might need and how we can get.
So. Okay, so this will be using SPI.
Okay. Okay. Okay. Okay.
Okay. Okay.
Okay.
Okay. Okay. I still have one address. Okay. Okay.
All right.
So. Okay. Okay.
Not much about the actual.
Okay. Okay. Plus one plus address.
And a list of UN aids.
Okay. So what we need to do is we need to use a library for SPI.
Okay. On the library pie, which. Okay. Okay.
Here it is.
Okay. Okay.
Okay.
So, the first thing we're going to do is Okay.
So. Right here.
Okay, so that doesn't need to be that.
Okay, so let's just programmatically setting it up.
So, here we are. So my speed and hurts.
Let's get open. Let's figure out how to do this. Okay.
One here. And we're going to say. Okay. Library first.
Okay. Okay.
Okay.
Okay. Here.
Okay. Okay.
Let's see what this. Okay. Here. Right.
This isn't rust.
In a little while. Okay, so we've got the SPI device loaded.
Next, we're going to send it a buffer of zeros.
Xerox 72. So. We're going to say what. Buffer. And start with.
And then we'll try a white pixel.
Okay.
We got to transfer that buffer. Okay.
Okay. So, let's say. And buffer.
Okay. You don't need a receipt.
Okay. Let's say send and say five.
Speed.
There's a nine followed by six years.
Okay.
So we're going to say. Okay. Okay.
So when we run this, what should happen. Is the first person should light up.
Yeah. Incorrect arguments or transfer.
Okay. Let's add a receipt. Okay. Okay, so we'll just give it a three.
Not arguing.
Okay. Okay.
Okay. Let's check. Okay. Okay. Okay. Okay.
Okay.
One of them must be set. There's no question.
Nope.
No question. All right. So. Okay. Let's try lowering this and let's try getting rid of this.
Okay. You don't actually need it. Okay. Change this from five.
That's wrong.
Correct. Correct. Okay. Okay.
Okay. Okay. Okay. Okay.
Okay.
Okay.
That's not it.
Okay. Okay.
Okay.
Okay. Okay.
Okay.
Okay.
Okay. Okay. Oh, so bite length is not optional.
Okay. And. To transfer. Okay. We're going to try something here.
Okay. Okay.
Okay. Okay. Okay. Okay. Okay.
Oh, huh.
You know what would really help? If I passed the message. Here.
Here. And pass message. Okay. Okay. Okay. Okay. Okay.
That's weird.
Okay. Okay.
It's. Okay. Okay.
Okay. Okay. Okay. Okay. Okay.
Okay.
Okay. Okay. Okay.
Okay.
Okay. Okay. Okay. Okay. Okay. Okay.
Okay.
Okay. Okay. Okay.
Okay. Let's see if this works.
Let's see if this works. Okay. Let's see if this works either.
Message array.
Okay. It's not an array. Yes. It's just silly, but.
With it.
It did send it, but nothing is lighting up on the pie.
Okay. So we're making progress though.
We can start sending. Messages to the device. So we're going to try a little bit more.
The end of the day. Let's see.
Okay. So looking at this line here. SLF. Plus that to list. So. 72. Let's go.
Let's go. Hang on. No messages. Yes.
Thank you, Rachel Williams. I got the, I got the message. Thank you. Yes. Thank you for the update.
So I really appreciate it. I'm just getting your, your, your messages through here.
So I appreciate it. Now to run it again without the one.
Okay.
Oh. Oh, right.
Did that manually. Let's change that back to. Okay.
Okay. Nothing's lighting up still, but that's okay. We're still making progress.
All right. I'm going to try one more thing. Yes.
Thank you to Daniel Horner and Rachel Williams. I wish I'd gotten your message a little bit.
Earlier, but that's okay. I appreciate Okay. The help really. All right.
So. Oh, No.
No, I don't think that's for each transfers week after the transfer. So, No need for a delay here.
Oh, okay.
Wait, let's see. How it sets things in here. Okay. Okay.
Okay.
Okay, so it's using an eight for chip select.
So we might have to set up your chips. So, Hi.
Okay, so we're going to have to figure out the chip select later.
Thank you all very much. And I hope you have a good rest of your day and enjoy the rest of popper TV.
Thank you.