{"id":5192,"date":"2015-03-05T15:24:30","date_gmt":"2015-03-05T15:24:30","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=5192"},"modified":"2019-04-02T10:23:35","modified_gmt":"2019-04-02T10:23:35","slug":"retrieving-bitcoin-price-using-esp8266-wifi-module","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/retrieving-bitcoin-price-using-esp8266-wifi-module\/","title":{"rendered":"Retrieving Bitcoin Price Using ESP8266 WiFi Module"},"content":{"rendered":"<p>In this project you&#8217;re going to create a simple HTTP client with an\u00a0ESP8266 WiFi module. Having your ESP8266 connected to your network, it requests the current Bitcoin price. This is an example on how to \u00a0retrieve data from the web.<!--more--><\/p>\n<p><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-5201\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esp8266_thumbnail.jpg?resize=437%2C326&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"esp8266_thumbnail\" width=\"437\" height=\"326\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esp8266_thumbnail.jpg?w=600&amp;quality=100&amp;strip=all&amp;ssl=1 600w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esp8266_thumbnail.jpg?resize=300%2C224&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 437px) 100vw, 437px\" \/><\/p>\n<p>Before you read this post, I recommend reading\u00a0these tutorials about\u00a0the ESP8266:<\/p>\n<ul>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-with-esp8266-wifi-transceiver-review\/\" target=\"_blank\" rel=\"noopener noreferrer\">Getting Started with ESP8266 WiFi Transceiver<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-web-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">ESP8266 Web Server Tutorial<\/a><\/li>\n<li><a href=\"https:\/\/randomnerdtutorials.com\/flashing-nodemcu-firmware-on-the-esp8266-using-windows\/\" target=\"_blank\" rel=\"noopener noreferrer\">Flashing NodeMCU Firmware on the ESP8266 using Windows<\/a><\/li>\n<\/ul>\n<h2>First, flash your ESP8266 module with NodeMCU<\/h2>\n<p>NodeMCU\u00a0is a firmware that allows you to program the ESP8266 modules with LUA script. And you&#8217;ll find it very similar to the way you program your Arduino. With just a few lines of code you can establish a WiFi connection, control the ESP8266 GPIOs, turning your\u00a0ESP8266 into a web server\u00a0and a lot more.\u00a0<a href=\"https:\/\/randomnerdtutorials.com\/flashing-nodemcu-firmware-on-the-esp8266-using-windows\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Follow this tutorial to Flash your ESP8266 with NodeMCU.<\/strong><\/a><\/p>\n<h2>Where to buy?<\/h2>\n<p>You can\u00a0<a href=\"https:\/\/makeradvisor.com\/tools\/esp-01-wi-fi-board\/\" target=\"_blank\" rel=\"noopener noreferrer\">click here<\/a>\u00a0to compare the ESP-01 Board price at different stores (<a href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\" rel=\"noopener noreferrer\">read Best ESP8266 Wi-Fi Development Board<\/a>)<\/p>\n<p><a href=\"https:\/\/makeradvisor.com\/tools\/esp-01-wi-fi-board\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-4815\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/01\/ESP01v0.jpg?resize=224%2C224&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"224\" height=\"224\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/01\/ESP01v0.jpg?w=700&amp;quality=100&amp;strip=all&amp;ssl=1 700w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/01\/ESP01v0.jpg?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/01\/ESP01v0.jpg?resize=300%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 224px) 100vw, 224px\" \/><\/a><\/p>\n<h2>Schematics (3.3V FTDI\u00a0Programmer)<\/h2>\n<p>The schematics for this project are very straight forward. You only need to establish a serial communication between your FTDI programmer and your ESP8266. You can\u00a0<a href=\"https:\/\/makeradvisor.com\/tools\/ftdi-programmer-board\/\" target=\"_blank\" rel=\"noopener noreferrer\">check this page<\/a>\u00a0to get an FTDI programmer at the best price.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-4814\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/01\/esp8266_pinout_h-569x236.png?resize=547%2C227&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"esp8266_pinout_h-569x236\" width=\"547\" height=\"227\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/01\/esp8266_pinout_h-569x236.png?resize=569%2C236&amp;quality=100&amp;strip=all&amp;ssl=1 569w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/01\/esp8266_pinout_h-569x236.png?resize=300%2C124&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/>Wiring:<\/p>\n<ul>\n<li>RX -&gt; TX<\/li>\n<li>TX -&gt; RX<\/li>\n<li>CH_PD -&gt; 3.3V<\/li>\n<li>VCC -&gt; 3.3V<\/li>\n<li>GND -&gt; GND<\/li>\n<\/ul>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5193\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/ESP-Bitcoin-price_bb.png?resize=588%2C216&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-Bitcoin-price_bb\" width=\"588\" height=\"216\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/ESP-Bitcoin-price_bb.png?w=759&amp;quality=100&amp;strip=all&amp;ssl=1 759w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/ESP-Bitcoin-price_bb.png?resize=300%2C110&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 588px) 100vw, 588px\" \/><\/p>\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n<h2>Downloading ESPlorer<\/h2>\n<p>I recommend using the <a href=\"https:\/\/github.com\/4refr0nt\/ESPlorer\" target=\"_blank\" rel=\"noopener noreferrer\">ESPlorer<\/a> program created by 4refr0nt\u00a0to create and save LUA files into your\u00a0ESP8266. Follow these instructions to download and install ESPlorer:<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/4refr0nt\/ESPlorer\/archive\/6987af991fe49df2c8f611588d3ea6d92260ee7e.zip\" target=\"_blank\" rel=\"noopener noreferrer\">Click here to download\u00a0ESPlorer<\/a><\/li>\n<li>Unzip that folder<\/li>\n<li>Go to the <strong>dist\u00a0<\/strong>folder (here&#8217;s the path:\u00a0ESPlorer-master\\ESPlorer\\dist)<\/li>\n<li>Run\u00a0<strong>ESPlorer.jar<\/strong>.\u00a0It&#8217;s a JAVA program, so you need JAVA installed on\u00a0your computer.<\/li>\n<li>Open the ESPlorer<\/li>\n<\/ol>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5125\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/02\/esplorer-start.png?resize=424%2C316&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"esplorer start\" width=\"424\" height=\"316\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/02\/esplorer-start.png?w=802&amp;quality=100&amp;strip=all&amp;ssl=1 802w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/02\/esplorer-start.png?resize=300%2C224&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 424px) 100vw, 424px\" \/><\/p>\n<h2>How to send commands\u00a0to your ESP8266<\/h2>\n<p>When you open the ESPlorer you should see a window similar to the preceding Figure, follow these instructions to send commands to your ESP8266:<\/p>\n<ol>\n<li>Connect your FTDI programmer to your computer<\/li>\n<li>Select your FTDI programmer <strong>port <\/strong>(COM8, for example)<\/li>\n<li>Press\u00a0<strong>Open\/Close<\/strong><\/li>\n<li>Select <strong>NodeMCU+MicroPtyhon tab<\/strong><\/li>\n<li>Copy the following script into\u00a0ESPlorer<\/li>\n<\/ol>\n<p><strong>Note: You need to add your\u00a0own network credentials to line 2.<\/strong><\/p>\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">wifi.setmode(wifi.STATION)\nwifi.sta.config(&quot;YOUR_NETWORK_NAME&quot;,&quot;YOUR_NETWORK_PASSWORD&quot;)\nprint(wifi.sta.getip())\nconn=net.createConnection(net.TCP, 0) \nconn:on(&quot;receive&quot;, function(conn, payload) print(payload) end )\nconn:connect(80,&quot;api.coindesk.com&quot;)\nconn:send(&quot;GET \/v1\/bpi\/currentprice.json HTTP\/1.1\\r\\nHost: api.coindesk.com\\r\\nConnection: keep-alive\\r\\nAccept: *\/*\\r\\n\\r\\n&quot;)\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266-Bitcoin-Price\/bitcoinprice.lua\" target=\"_blank\">View raw code<\/a><\/p>\n<p>Then you simply click the button\u00a0<strong>Send to ESP. <\/strong>And you should see a query appearing in your screen with the current Bitcoin price and a few other details<strong>.\u00a0<\/strong>Everything that you need to worry about or change is highlighted in red box in the following Figure.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5194\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esplorer_bitcoin_price.png?resize=762%2C551&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"esplorer_bitcoin_price\" width=\"762\" height=\"551\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esplorer_bitcoin_price.png?w=1038&amp;quality=100&amp;strip=all&amp;ssl=1 1038w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esplorer_bitcoin_price.png?resize=300%2C217&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esplorer_bitcoin_price.png?resize=1024%2C740&amp;quality=100&amp;strip=all&amp;ssl=1 1024w\" sizes=\"(max-width: 762px) 100vw, 762px\" \/><\/p>\n<h2>Retrieved Data<\/h2>\n<p>Here&#8217;s the data that your\u00a0ESP8266 is requesting, you can access it with your web browser right now:\u00a0<a href=\"http:\/\/api.coindesk.com\/v1\/bpi\/currentprice.json\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/api.coindesk.com\/v1\/bpi\/currentprice.json<\/a><\/p>\n<p>Below you can see the data that your ESP8266 requested\u00a0which is the current price of Bitcoins in USD, GPB and EUR.<\/p>\n<p>{&#8220;time&#8221;:{&#8220;updated&#8221;:&#8221;Mar 4, 2015 15:10:00 UTC&#8221;,&#8221;updatedISO&#8221;:&#8221;2015-03-04T15:10:00+00:00&#8243;,&#8221;updateduk&#8221;:&#8221;Mar 4, 2015 at 15:10 GMT&#8221;},&#8221;disclaimer&#8221;:&#8221;This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org&#8221;,&#8221;bpi&#8221;:{&#8220;USD&#8221;:{&#8220;code&#8221;:&#8221;<strong>USD<\/strong>&#8220;,&#8221;symbol&#8221;:&#8221;&amp;#36;&#8221;,&#8221;rate&#8221;:&#8221;<strong>282.5891<\/strong>&#8220;,&#8221;description&#8221;:&#8221;United States Dollar&#8221;,&#8221;rate_float&#8221;:282.5891},&#8221;GBP&#8221;:{&#8220;code&#8221;:&#8221;<strong>GBP<\/strong>&#8220;,&#8221;symbol&#8221;:&#8221;&amp;pound;&#8221;,&#8221;rate&#8221;:&#8221;<strong>184.6234<\/strong>&#8220;,&#8221;description&#8221;:&#8221;British Pound Sterling&#8221;,&#8221;rate_float&#8221;:184.6234},&#8221;EUR&#8221;:{&#8220;code&#8221;:&#8221;<strong>EUR<\/strong>&#8220;,&#8221;symbol&#8221;:&#8221;&amp;euro;&#8221;,&#8221;rate&#8221;:&#8221;<strong>254.3166<\/strong>&#8220;,&#8221;description&#8221;:&#8221;Euro&#8221;,&#8221;rate_float&#8221;:254.3166}}}<\/p>\n<h2>Troubleshooting<\/h2>\n<p>Sometimes your ESP8266 doesn&#8217;t have enough time to send the HTTP\u00a0request when you press &#8220;<strong>Send to ES<\/strong>P&#8221;. So It won&#8217;t show any data\u00a0retrieved. You might want to use this feature on the ESPlorer that is called &#8220;<strong>Send current line to ESP8266<\/strong>&#8220;. And send each line of your script at a time.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5195\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/send_current_line.png?resize=376%2C174&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"send_current_line\" width=\"376\" height=\"174\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/send_current_line.png?w=376&amp;quality=100&amp;strip=all&amp;ssl=1 376w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/send_current_line.png?resize=300%2C139&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/p>\n<h2>Taking it further<\/h2>\n<p>You&#8217;re requesting the current Bitcoin price, that doesn&#8217;t seem that useful&#8230; right? Wrong! Just think for one second with a $4 WiFi module you can request any data from the web, how awesome is that?<\/p>\n<p>Now my question is: which data is important for your project? The weather? Sport scores? Just type in your\u00a0search engine: &#8220;weather api&#8221;, &#8220;finances api&#8221;, pretty much any term that contains some sort of data followed\u00a0by api will be available to retrieve data.<\/p>\n<h4>Do you have any questions?\u00a0Leave a comment down below!<\/h4>\n<p>Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my\u00a0Facebook Page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this project you&#8217;re going to create a simple HTTP client with an\u00a0ESP8266 WiFi module. Having your ESP8266 connected to your network, it requests the current Bitcoin price. This is &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Retrieving Bitcoin Price Using ESP8266 WiFi Module\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/retrieving-bitcoin-price-using-esp8266-wifi-module\/#more-5192\" aria-label=\"Read more about Retrieving Bitcoin Price Using ESP8266 WiFi Module\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":5201,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[265,214,300,220,264,219],"tags":[],"class_list":["post-5192","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266-project","category-esp8266","category-0-esp8266","category-http-client","category-project","category-request-data"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2015\/03\/esp8266_thumbnail.jpg?fit=600%2C448&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/5192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=5192"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/5192\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/5201"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=5192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=5192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=5192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}