Introduction: Instructables View Counter + ESP8266 Guide

Picture of Instructables View Counter + ESP8266 Guide

Subscriber counters for Youtube and Facebook are quite common, but why not make something similar for Instructables?
That's exactly what we're going to do: in this instructable, we'll make an Instructables view counter!

The views will have to be captured from the interwebs, so we'll use the common (and cheap) ESP8266 WiFi module to get the required information. It needs some configuration, but I'll go through all the steps required to get it up and running.

To keep the project as accessible as possible (i.e., not requiring a 3D printer, laser cutter or particle accelerator), I decided to use Lego for the case! So get out that bin of Lego and let's get building!

Step 1: Parts & Tools

Picture of Parts & Tools

Parts

  • ESP8266 ESP-01
  • MAX7219 7 digit LED display module
  • 3.3V compatible FTDI breakout (programmer)
  • Pin headers
  • 4x 10k Ohm resistor
  • 2x Push button
  • 2x 10uF capacitor
  • 3.3V regulator (LM1117-3.3V)
  • USB cable
  • Lego!

Total cost: < 10$

Tools

  • Soldering iron

Step 2: Electronics

Picture of Electronics

Let's begin the project by building the circuit.

The electronics of the project are not very complicated, but the ESP8266 module requires some special treatment to get it to work. So first of all, what is this ESP thing all about?

The ESP8266 is best known as a low-cost WiFi chip, but it also has a full fledged microcontroller unit capability. This makes it ideal for projects that require WiFi and controlling of external components like our 7 segment display. The programming is done with a USB to serial converter, also called an FTDI converter.

Schematic

The components can simply be connected as in the schematic, but a bit more information is given here.

First of all, the ESP8266 operates from 3.3V, while the display (and the USB which we'll use for power) operates on 5V. This means we'll need a voltage converter to transform the 5V of the USB into 3.3V for the ESP8266.

When powering up the ESP8266, it will enter one of its "boot modes", depending on the voltage at its IO pins. In other words: if we want it to execute our code when it boots, we'll have to configure this!
For program execution this means:

  • CH_PD to VCC
  • RST to VCC
  • GPIO0 to VCC
  • GPIO2 to VCC

While for programming the device, this translates to :

  • CH_PD to VCC
  • RST to VCC
  • GPIO0 to GND
  • GPIO2 to VCC

As can be seen, the only difference is the state of the GPIO0 pin. Hence, we'll us a push button to connect GPIO0 to GND when programming.
After booting, the pins can be used freely, in our case for 2 things:

  1. As an input: there is a button connected to GPIO2.
  2. Driving the screen. Since it needs more than 2 signals, the TX and RX line will also be used as IO.

Now that we have the theory of operation out of the way, we can translate this into a physical design.

PCB

To make the PCB, I designed a perfboard/stripboard layout in KiCad (an open source PCB layout software). By setting the grid spacing to 2.54mm (0.1 inch), you can make layouts which can be soldered onto stripboard.

This makes it super easy to solder the electronics together: simply print out the design (included as a PDF) and copy the design on the stripboard. Use header pins to connect the screen, FTDI and ESP8266.

After soldering, cut the perfboard to the right size and plug in all the components.
With the electronics soldered together we can blow life into them with some code!

Step 3: Programming the ESP8266

Picture of Programming the ESP8266

Setting up the libraries

Before we can upload any code to the board using the Arduino IDE, we will need to add its libraries. This can be done by following the next steps:

  1. Go to File>Preferences and paste following link in the "Additional board manager URLs" box: http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json
  2. Go to Tools>Boards>Boards Manager and search for ESP8266
  3. From this window, install the most recent package
  4. Restart the IDE
  5. From Tools>Boards, select "Generic ESP8266 Module" as a board
  6. Open the sketch and render it (ctrl+R) to see if the board has been added correctly.

Uploading the code

To program our device, we will need to put it into programming mode and connect it to the FTDI breakout board. This can be done by pulling the appropriate pins to VCC or GND and making the connections as listed below.

  • CH_PD to VCC
  • RST to VCC
  • GPIO0 to GND
  • GPIO2 to VCC
  • RX to TX of FTDI
  • TX to RX of FTDI

Fortunately, all connections those connections are already present on our PCB. I tried it on a breadboard first, and as you can see, it is a bit clumsy. So to upload code:

  1. Remove the display and plug in the FTDI
  2. Hold down the program button when connecting the USB cable
  3. Upload the code. After uploading "Set net" should be displayed

Possible errors

You might get an error when uploading like "error: espcomm_upload_mem_failed", simply reupload the code.
If the display remains blank on powerup, also reupload the code.

Running the code

To run the code we just uploaded, the programming mode should be disabled by pulling the GPIO0 pin to VCC. Or in our case, power up the device without pressing the program button.

With the code uploaded and running, we can now configure our viewcounter!

Step 4: Setting Up the Viewcounter

Picture of Setting Up the Viewcounter

The configuration of the viewcounter is done via a webpage interface. This allows to change the settings on the fly instead of having to reupload the code each time.

Configuring the web server

  1. Power up the unit and wait for "set net" to be displayed
  2. Press the Mode button, the device will show "setup"
  3. On your PC, go to your WiFi networks and select "Instructables Hit Counter"
    (When asked for a password, enter 'password'.)
  4. A browser window should open (otherwise open one yourself and type in 192.168.4.1)
  5. A page opens, press "Configure WiFi"
  6. Choose a network and type in your password. Fill in a static IP, gateway and subnet
  7. Hit save, a confirmation page will appear

Now that the ESP8266 is connected to our WiFi network, we can fill in our Instructable credentials.

User Setup

  1. Open a browser and type in the static IP you choose in the previous step.
  2. Go to the "User setup" tab
  3. Fill in your Instructables name and save
  4. To see the views of a specific Instructable, follow the instructions on the page
  5. Hit save, your views will now be displayed!
  6. For more options, explore the settings ;)

The counter is now fully functional, but still looks a bit dull. Let's change that by making an awesome case!

Note

The code of this project comes from this awesome guy: https://www.instructables.com/id/Instructables-Hi... All credit for the code goes to him, I am merely using it to make my own version of the project. The main reason I write this is because I had to puzzle some things together to make it work (like how to program the ESP8266, adding the libraries, getting the instructables ID, making the PCB, ...) and wanted to make a complete standalone guide.

Step 5: Casing

Picture of Casing

This is the part where you can get super creative. Any case can work, but making a nice one can make or break a project. Therefore, I decided to make mine out of Lego!

Mounting the screen

To fix the screen in place, I found that a "Lego panel without side support" fits the screen perfectly. There is only one downside: it's twice as wide as I'd like... Fortunately, this is easily solved by cutting it in 2. We now have a nice mount for the display, and a good starting point for the whole case!

Making the letters

To make it more obvious that this is a view counter, I wanted to include a label with "views". But then I thought, why use a stupid label when you can make letters out of Lego? So that's what I did!
I included a close up off the letters such that they are easier to replicate.

Making the robot

I was looking for something to finish off this build, and stumbled across this awesome instructable: https://www.instructables.com/id/Lego-Instructable...

The instructables robot built out of Lego, the perfect companion for the view counter! I won't go into the detailed steps of making it here, since it is explained step by step in the original instructable.
Our little companion is the finishing touch to our case; we're done!

Step 6: Test & Enjoy!

Picture of Test & Enjoy!

We're done! The only thing left to do is to test our new view counter.

Connect it to a USB port and admire your views!
I hope you liked the project and are inspired to make something similar.

Feel free to check out my other instructables: https://www.instructables.com/member/ThomasVDD/

Comments

Eric Brouwer (author)2017-12-03

Hi ThomasVDD

Thanks for your credit towards my code.

Regards

Nate Lu (author)2017-11-21

Voted for your contests! Great design!

ThomasVDD (author)Nate Lu2017-11-22

Thanks! Glad you liked it :)

Nate Lu (author)ThomasVDD2017-11-22

:D

jeanotP1314 (author)2017-11-16

Great project!

Lego is sometime way better than 3D printing! :)

ThomasVDD (author)jeanotP13142017-11-17

Thanks! I find it often more fun to be building and coming up with a design along the way than spending hours designing a boring enclosure on the pc.

witnessmenow (author)2017-11-08

Hey, really nice project!

I wrote the Instructables API library and i love seeing people using it in projects, thanks a lot for sharing!

ThomasVDD (author)witnessmenow2017-11-09

Awesome! Thanks a lot for making the API, it's super cool to use!

inconceivable1 (author)2017-11-06

wow thats pretty smart + I love lego

About This Instructable

1,484views

24favorites

License:

Bio: I study (civil) electronics engineering at the VUB in Belgium. I have a passion for making things, both useful and cool.
More by ThomasVDD:NFC RingInstructables View Counter + ESP8266 GuideHard Drive Speaker
Add instructable to: