 I'm a software engineer, but sometimes I think you're hardware or electronic hardware from time to time When I feel like it I'm going to talk about connecting internet of things or things to the internet with electric in Who among you here have used electric in before? Platform or have heard it before. Okay. Okay. There's so I'm in the right crowd So electric imp is this little thing that you see here It's not an SD card. Actually, we'll see it later So the plot I'm going to talk about the platform then the hardware later And then the smart socket is a small project that I did with it And then I'm going to show you a demo of the smart socket and maybe we can have a look at the source code How simple it is it's 20 lines of code and then if we have enough time We'll do a live coding demo. Let's we'll build an internet of things live, okay So the platform platform is as an internet electric imp is a N2N solution so it's from hardware to firmware to operating system to cloud services And everything is if every cloud services is free for use So it's not it's a commercial platform by the way But it's free for use as long as you have the hardware And there are lots of open-source libraries available in GitHub for you to start with So the hardware is this thing It's not an SD card and there's the green the board is actually a breakout board It's called the April breakout board and it has a It's a computer. It's not an SD card. It has a 32-bit arm CPU inside with 80 kb of RAM and 120 kb of code storage. It's not it's not much, but we don't need it much. We will see later and It has a built-in Wi-Fi chip inside and Built-in antenna it has other also has power saving components. It's actually very low power device So you can run the device connected to the internet at they claim like six milliamps Only and you can also configure you can actually code it to sleep and only wake up at certain time like Everyone are wake up and measure the haze the air quality of Singapore and go back to sleep again And in sleep mode it actually consumes four microamps. So you can power it in a double-A battery Okay, since it's an SD card so there are only we only have nine pins available and Two pins are power ground and positive a third pin is required for ID. It's for authentication So it requires an ID chip. So if you look at the board here, there's actually an ID chip a very small one I don't have a pointer, but yeah, it's required for every imp for authentication for security and The remaining pins are GPIOs and can be configured whatever you Wish so it can be a digital input digital output analog input output you are I to see PWM whatever you want Okay, and there are different packages of electric in So the one I showed you is the first two photos There are other packages with more GPIO pins and there are other packages the one on top It's actually a very small one 10 mm by 10 mm is used by manufacturers mostly not for Not for habeas or for makers. Okay, and then there are other Development boards here Okay, and the chip Runs an imp OS. It's a proprietary OS. So we don't have access to it and it runs a virtual machine within the chip and The idea is in the cloud. Okay, the idea if you don't need to install anything to start coding with it Okay, and then the programming language use is squirrel. So it's originally originally a programming language for for video video game scripting Yeah Okay, it's an object he's actually here Okay Okay, so it's an object rented high-level language very very familiar almost like JavaScript okay, and The photo that you see here is actually the IDE that runs in the browser and for every chip that you have for every m That you have you will have a corresponding Virtual machine running in the cloud as well that is hardwired to the virtual machine that is in the imp Okay, so though I'm going to talk about the simple project I made Let me turn this off quickly first Okay smart socket so It's a it's very simple to 150 volts which then with 10 amps It can control the 10 amps of load and can be controlled from the internet So there are some commercials that you see our commercial products We see like Belkin that you can control from your mobile app from a mobile phone But it's not the same because that one is you can control it through Wi-Fi To your phone this one you can put this is controllable through the internet So even if this thing is in Malaysia, and you're in Singapore it will work Connects to the internet so it's a bit different and Is the the circuit is very simple So if you look at this is schematic the left side three pins the I only use one pin Just because it's just an on-off put the pin seven for the devil and then a driver chip and the relay okay and The five volts switch mode power supply that I used is actually I salvaged it from an old Cell phone charger because I need to make it very small so I can fit it in a box This box like a regular convenience outlet box that you see in your HDB's Okay It's actually it's very ugly, but But it works so this is the the vertical board is the one is the power supply and the rest is just this Is the imp and this is the relay where it's more relay and the driver chip is behind Okay, so let's take a look at it. It's actually here after this one. It looks like a very regular outlet So it's turned on right now And I'm going to show you before this Let's take a look at The electric in ID Okay, so you need to create an account by the way when you have the chip you need to Set up an account and you register the imp to your account so it will it will appear here So this is this is it That's the ID so it's running it's running in browser And there's the source code of the device the right side is the source code for the device This code runs in the VM in the device in the chip so it it's this chip and Then the left side is it will run in the VM on the cloud and Then there are already connect the pipeline is ready set up for you You don't need to worry about firewall or everything. So it's really set up and it's it's programming model is similar to No JS so it's event driven and If you're going to walk through here if you look at this So the code here says agent on Switch on what it means is actually it's an event handler you wire up to Whenever you see an event it says switch on execute this function That's it and this is the function that switch that controls the switch which has says outlet that right To out the outlet state. So it's very very Verbal because it's very it's object-oriented. So you don't need to Handle memory addresses and then etc. So when you want to configure the pin You just say hardware the pin 7 configure it as a digital output. That's it and you're done So in 20 lines of code you have a switch that can be controlled through internet Okay, and then on the on the left-hand side is the source code of the Agent they call it the VM that is running on the in the cloud is actually called the agent and And here what you see here is just I created a very simple HTML page that will display two buttons so that we can use it and then the main code that Executes the command here is this thing so device the send Switch on and I'm going to send the state. It actually triggers this event So with this event So we send the data or a switch or the logic to the pin like one with zero and this thing here in the the Virtual machine in the cloud is accessible through a URL So it's specific to your device every device every chip you will have an agent URL for you So you will see it here and That URL will have an event handler here HTTP on request Execute the event event handler. That's it So it's time to see how it works Okay I have here my phone. Yeah, you can actually try it yourself if I'm going to go back here If you have a barcode reader, this is the URL of the agent and it will give you a button and you can control it yourself Okay, so I have it I already I have it here already open So I can turn it off. I can turn it on. So this is it. I plugged on Ikea lamp in there so Okay, and then to see In the idea you also see a log so because I in my call I said log So you will see the activities here in the bottom. So I see a city very quest received So it's on or off. So it's live. It's in it's in it's in the cloud. You can control it anywhere You are in the world. Okay, and then Since you already have the switch available in the internet you can control it whatever you want Yeah, your mobile phone a website a web page or you can control it through another imp So another imp that will read some data like a button. Maybe Something is going to someone's controlling it and then and then yeah Send another imp that will control is to send a signal to the agent and then the agent will control this thing And I have here Like a very simple circuit like one electric imp I'm powering it with a power bank here and then a motion sensor Like a very simple motion sensor. It's a 50 cent in Ali express Okay, let's take a look So as soon as you see the light blinks green it means it's connected to the cloud Now it's connected to the cloud and I can also open the source code of the motion detector Which is Okay Go to my models Yes Is if you look at the software very simple 16 lines of code it says here configure pin one as a as a digital input and then Read that value pin one and then once you see owner of this call the agent or raise an event in my agent And in my agent I'm calling the agent of another imp So I'm calling the this is the URL of another imp. So I can control the imp from a motion sensor So if I'm going to take look at the logs here See it is detected motion. It's already on here and it should It should turn on the imp. So make that So from the motion. So now we have two things talking to each other through the internet Yeah, and that's that's we just made an Internet of things in Few minutes. So it's very simple in 30 lines of code. You have internet of things Do you have any questions? So It's a VM running in their infrastructure and then you just you are only allowed to access it through that interface the ID So when you write write the code I wouldn't call the microservice, it's a service. Yes, but it's not really a microservice Yeah Yes I bought this in digi key for $30 $35 so the card so it's it's the same cost as your Wi-Fi module Wi-Fi Yeah, Wi-Fi card for Arduino result. Yeah, and then you already have an MCU You have a cloud service. You don't need to worry about setting up your servers each other Yes, the access control is it's your concern is you have to manage it yourself But if you look at the transport security, it's it's actually HTTPS So you don't need to worry about man in the middle attack. So you only need do some some Authentication a higher level authentication for yourself Okay Yes Any questions? Yes Okay, I'm actually currently working on a IR blaster So it's our device that will control any infrared control device at my home and I can control it through the internet So like before I go home, I can turn on my AC. So it's when I arrive. It's really cold Yeah, yeah, but I'm struggling a bit in the protocol of Sony because it's proprietary So some other infrared protocols are open. There should be open like Panasonic standards Yes, it's a personal project and I don't work for electric Yes, you want to try this out as a software developer Before I became a software developer. I was actually a consumer electronics mechanic. I did a short while I did a Independent consulting in industrial automation. So I was in the manufacturing field Yeah, okay, I think we're done here. Thank you