MicroPython on ESP8266 update

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi backers so with this update we're going to show you a little bit how you can use your esp8266 board here is a Adafruit hussar feather board and we have connected to some Adafruit neopixels here so we have power and ground and then the single data pin okay so you can see here I have the prompt the repple connected to the board and this is just through a normal USB serial port but it could also be through the web Ripple okay so let's import the machine module so that we can access the pins so make a pin object that the neopixel is connected to pin 14 now import the neopixel module okay and I'll create a neopixel object and give it the pin that I'm on and there's eight neopixels okay so this neopixel object can controller neopixel lights we can look at all of the colors okay so they're all black at the moment so let's make the first neopixel red like this let's have a look so an easy way is just to list the neopixel lights so you can see the first one is actually it's red even though the two by 5's in the second place so if we do the right then you'll see that the near pixel turns on okay and we can do other things so say the last neopixel let's turn it on to white MP dot right okay so you can control the neopixels very easily like this so I have a little demo that takes a neopixel object and does a little light demo there you go so the esp8266 actually runs at 80 megahertz so let's have a look at its frequency so it's running at 80 megahertz at the moment and the neopixel timing is tuned for that frequency I can also change the frequency on the fly to 160 megahertz it's other available frequency so we can see okay now we're at 160 megahertz and I can still do the neopixel demo because it will reach into the correct frequency right so in this demo we're going to get some information from the internet downloading it from the open weather map website so let's import our socket module and create a socket and get the address of the website that we want to connect to okay let's see address there that's the IP address now we'll connect ok the socket connected now send our request so get so let's say want to get the weather for London 0 / ends option and item insert my key there okay and receive say the data okay so there we got the response back let's save that using the underscore last variable for the HTML is the data we got back now let's split it up so we can extract the actual JSON data so okay and then get the last one of that the last element of that list is the actual JSON data here so let's save that now let's import the JSON module and we can load that data okay so now that returns an actual dictionary so we can say access the the main data and say the temp the current temperature okay so that's in Kelvin so subtract the right value to convert to Celsius and that's the current temperature in London okay in this last demo we're going to use one wire temperature sensor and read that sensor and then post some data to to the Internet okay so let's again import machine so we can access our pins and the one wire library as well so let's create the pin that our sensor is on so the temperature sensors here there's two of them and they're connected to GPIO pin 14 and then this is the power what power rail so the one wire object one wire dot one wire on the pin so I've created a 1-wire bus there and then a temperature so on the 1-wire bus you can have many different things so here we're going to create a bus that holds these d s 18 big 20 temperature sensors okay so let's scan for our different sensors okay so you can see there are two and that's their ROM addresses so let's save that okay so roms is now the variable containing out addresses of our one wire temperature sensors let's do the starter measurement you have to wait about a second for that to finish which we have and then we can get temperature from the first and the second temperature sensor okay so that's great now what we try and do is post that to the two AM feed on zyv ly so we have a nice little lively module here and create a feed ons ively so I've got my ID and key here stores some variables and I can just right I can right the temperature there so that's just written the current temperature to my sensor feed so let's make a lupin and do that for for a while so let's define a function read and post temperature sensor and to the feed so keep going forever start our measurement sleep for a second then a readout temperature sensor and print it out just so we know what we're doing and then write it to the feed okay so that's our function we'll need to import time for that to work right so now we should be able to run that function read and post the temperature sensor and feed are the arguments okay so here every second it will read the temperature and post that to the zyv we feed so if i try and increase the temperature of this sensor by holding it you can see that the temperature's going up see if we can get it to 30 there we go and it should go down again now if I stop touching it so this data is being posted to the zyv the website and you can see here the the data being graphed so if we if we reload this page we'll see the updated data okay and so to break out of this loop we can just press ctrl C and it will stop that infinite loop okay so I hope that you got a good sense of what you can do so far so there's lots of things that are implemented but still lots of things that we've got to go would like to implement and make the the esp8266 a really great chip for doing Internet of Things applications thank you
Info
Channel: viktoriya sk
Views: 39,783
Rating: undefined out of 5
Keywords: MicroPython, ESP8266, Python, Microcontrollers, Coding
Id: _voIwFB4mu0
Channel Id: undefined
Length: 10min 17sec (617 seconds)
Published: Wed Feb 17 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.