This Bitcoin Price Tracking Traffic Light Isn’t Just A Red LED

Quick, what’s the price of Bitcoin? Is it lower today than yesterday? Are you overdrafting your Lamborghini account? What if you had an easy way to tell at a glance how much you could have made if you sold in December of last year? That’s what this Bitcoin price tracking traffic light is all about, and it’s a great use of existing electronics.

The hardware for this build is a traffic light table lamp available on Amazon for twenty bucks. Inside this traffic light, you get a PCB with three LEDs and a small microcontroller to control the LEDs. The microcontroller isn’t used in this case, instead the microcontroller is removed and a few wires are soldered up to the base of the transistors used to drive the LEDs. The other ends of these wires are attached to a trio of pins on a Raspberry Pi Zero W, giving this traffic light table lamp Linux and a connection to the Internet.

On the software side of things, we’re looking at a Docker container running a Python script that fetches the latest Bitcoin price from Coindesk and calculates the change from the previous fetch of the price of Bitcoin. This data is shuffled off to another Python script that actually changes the LEDs on the lamp.

Sure, these days a ‘bitcoin price tracking traffic light’ is as simple as connecting a red LED to a battery, and if you’re feeling extra fancy you can add a 220 Ω resistor. But this is a project that’s so well executed that we’ve got to give it a tip ‘o our hat.

10 thoughts on “This Bitcoin Price Tracking Traffic Light Isn’t Just A Red LED

  1. IMHO. A RPi Zero is a sledgehammer to crack a nut for this problem. An ESP8266 should be able to do this, because AFIK it can GET from HTTPS sources.

    Specifically, the data seems to come from here

    which returns JSON data like this (note its only around 500 byes long)

    {“timestamp”:”2018-11-23T05:01:27.633Z”,”error”:false,”status”:200,”message”:”OK”,”data”:{“currency”:{“BTC”:{“iso”:”BTC”,”name”:”Bitcoin”,”slug”:”bitcoin”,”totalSupply”:null,”circulatingSupply”:17389225,”quotes”:{“USD”:{“iso”:”USD”,”name”:”United States Dollar”,”slug”:”united-states-dollar”,”change24Hr”:{“percent”:-6.87827801985568,”value”:-309.0606397318},”price”:4184.2163245006,”volume24Hr”:141297231.41149658,”marketCap”:72760279115.4148,”open”:4493.2850757064,”low”:4132.3302992874,”high”:4535.9336641014,”close”:4184.2244359747}}}}}}

    A quick and dirty way to get the “price” is just to look for the text “\”price\”.” and the text between the end of that string adn the next comma is the price.

    If you really wanted you could do a more complex parse on the text, but if they change the format considerably, it would probably break your code no matter how you parsed it.

    1. Any ESP could do this directly, excepting the ESP-01 likely needing to expand its IO with extra hardware.
      But rewording the old hammer and nail joke can help, in that when your only tool is python, every problem requires significant computing power and infrastructure to just flip a bit on and off – suddenly the hardware requirements make more sense.

      That’s not a knock on python btw. But it can be a far more positive mental view to think about the level to entry electronics have finally reached. The number of people that can now easily realize their ideas is amazing and a ‘good thing'(tm)
      The percentage of ideas that are crap hasn’t really changed, just that the total number of them being developed has jumped so high.

      I prefer to think of the other side of that percentage, in that this also means the number of awesome ideas being realized is also larger.
      But throwing a pretty cheap Pi at the problem to save effort isn’t all that different from throwing a cheap 74 series shift register at an ESP-01 instead of doing it with transistor gates :P

      1. No, even an ESP-01 can do it. Just give up the RX/TX pins and you have 2 additional GPIOs.
        I have once of them getting the weather data from the web, and displaying it on led matrix display.
        I still have the TX line free to send debug messages to the computer if needed.

      2. Reminds me a bit of a Arduino project I read about 5 years ago, where someone used a Uno + ethernet shield, to read data from the London Underground train system to work out which station he should walk to in the morning in order to catch the train.
        From what I recall, the project had a map printed on a piece of paper, which had holes for LED at the location of each station.

        Nice piece of KISS engineering at that time.

        1. Actually, the more I look at this, the more over-engineered it looks.

          Looks like an advert for the cloud service in question, since its posted on the blog for that particular cloud service.

          IMHO it doesn’t warrant being on HaD

  2. Why would you need a docker container to run a python script on a raspi? Besides that, very cool project! I might copy that to display other data than “you are poor!”. Weather would be nice :)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.