First prize in Instructables Pocket-Sized Contest! :D
If you invested some money in cryptocurrencies, you probably already know that they are highly volatile. They change overnight and you never know now much 'real' money you still have in your wallet. The same is valid for stock markets. You put a little faith in a particular stock and, out of nowhere, the market thinks it's worthless the next day.
So how do you track these assets and know their current value? You can work with some spreadsheets and update them regularly. Or you can create your own gadget to check these values for you: an IoT wallet!
For this project, I worked on the Google spreadsheet to track my assets and update their values for a particular currency, based on the ticker values retrieved from the Internet. This spreadsheet is accessible from an ESP32 using and Wi-Fi connection, and a summary is shown on an OLED display. A 3D printer was used to create a wallet, in which I embedded some electronic components to create my first IoT wallet prototype.
And that's not all! Why not add a clock synchronized with the internet and a step pedometer in the same gadget? In this tutorial I'll show you how to do that.
There are several ways to use this tutorial. You can use it to:
- Learn how to track and update your asset values for a particular currency using a Google spreadsheet;
- Program an ESP32 using the Arduino IDE;
- Read values from a Google spreadsheet using an ESP32 device;
- Practice your electronics and soldering skills, etc;
You can use part of this tutorial to create your own gadgets or follow it to the end and produce your own wallet.
This tutorial is divided as follows:
|1||Tools and materials|
Tools and materials used in this project
|2-3||3D printing||How to 3D model and 3D print the gadget|
|4-5||Electronics||How to wire up the circuits|
|6-7||Google Spreadsheet||How to create a Google Spreadsheet an share it with your gadget|
|8-12||Coding||How to program a ESP32 using Arduino IDE|
There are some awesome tutorials on how to track the prices of crypto currencies. This one served as a inspiration for this project: https://www.instructables.com/id/Simple-10-Crypto-Currency-Display/
Liked that projects? Please consider supporting my future projects with a small Bitcoin donation! :D BTC Deposit Address: 1FiWFYSjRaL7sLdr5wr6h86QkMA6pQxkXJ
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Tools and Materials
For this project, the following tools were used:
- 3D printer. I used it to print my wallet and produce a case for the electronics (with regular PLA filament). You can find some inexpesive 3D printers online that will work just fine for this project (link).
- 1.75mm PLA filament (link / link / link). I used rigid white and blue PLA filament for printing the case where the electronics are encased and protected. This way they won't get crushed if I sit with on my wallet, or if it accidenty falls on the floor.
- Solder iron and wire. I needed it to solder some wires between the electronic components, as you'll se later.
- Super glue. The 3D design was printed in different parts. I used some super glue to stick them together.
I used the following hardware parts for my project:
- Firebeetle ESP32 dev board (link). Firebeetle ESP32 board is really easy to use and program using Arduino IDE. It has built-in Bluetooth and Wi-Fi modules, so you can use it in a variaty of projects. It has a connector for a 3.7V battery, which was really usefull for assembling this project. I has also a built-in battery charger. It will recharge the battery when connected to an USB plug. You can also use other ESP32 based boards (link / link), or ESP8266 ones (link / link / link) if you wish. Deppending on the board you choose, it would be a little more difficult to connect and recharge the battery. The dimensions of the case will also need to be verified.
- OLED display (link / link). It was connected to the ESP board, for displaying the values obtained from Google Spreadsheet.
- GY-521 accelerometer (link / link). It was used as a step counter.
- 3.7V battery (link / link). I used to power the whole circuit.
- Micro USB cable.
- M2x6mm bolts (x9)
- M2x1.5mm nuts (x5)
The links above are only a suggestion of where you can find the items used in this tutorial (and maybe support my future tutorials). Feel free to search for them elsewhere and buy at your favorite local or online store.
As it was said before, some ESP dev boards won't have a built-in battery connector (and charger). In that case, you'll need an external battery charging module (a TP4056 (link / link), for instance). It will possibly require a mini USB cable for the connection between the charger and an USB port.
Did you know you can buy a Anet A8 for only $155.99? Get yours at Gearbest: http://bit.ly/2kqVOdO
Step 2: 3D Modeling
In this step I present how the wallet was designed for 3D printing using flexible filaments. I also introduce the step-by-step involved in design of the case where electronic components are protected.
If you're only interested in printing your own wallet, skip to the next step, where you can find finished stl files. If you are not interested in 3D printing, skip a few more steps. If you are interested in 3D printing, but do not have a printer, why not buy one? Did you know that it is possible to buy a 3D printer for only 359.99 USD? Click HERE!
The wallet was designed to hold three cards and some electronics (microcontroller, display, and battery). An elastic might be used for holding additional doccuments and maybe some paper money. It was desgined using Fusion 360 CAD software.
The model is composed of only two different part: cap, body. I'll detail how I drawed each of this parts, in case you want to replicate it on your own design.
First I made a simple representation of each component used on my wallet. They don't have to be very detailed, but should have the right measurements. This was important to help define the relative position of each component inside the wallet. This way, I had to create a model for the ESP32 Firebeetle, OLED display, battery, and of a standard credit card.
2. Arrange the components
With a model of each component, you can play with their position and choose the best position for each one. I wanted to create a gadget as slim and as small as possible. This way, I tried to organize the devices to use a footprint close to a standard credit card area.
3. Drawing the sketches
After choosing the location of the instruments, the sketches were drawn and the structure was extruded.
The model was divided in two parts: the body of the wallet and the front cover. The body has holes for the bolts for the installation of the electronics. It also has hole that allows connecting an USB cable to the microcontroller (for uploading a code or charging the battery). It was were designed usin 0,8 mm walls, and have space for 3 cards. The front conver is glued to the wallet, protecting the electronics. It also has a hole for the touch button.
Step 3: 3D Printing
You can download all the stl files on the following websites:
The whole print took me around 2h30, printed with 0.2 mm resolution and 10% infill.
This is a experimental prototype. Notice that it was designed for a given ESP32 dev board model (the ESP32 Firebbetle). If you want to use a different model, please send a comment and I can see if it's possible to change model dimensions to fit your needs.
If you don't have a 3D printer, here are some things you can do:
- Ask a friend to print it for you;
- Find a hacker/maker space nearby. The parts used in this model can be printed quickly (around 3 hours). Some hacker/maker spaces will only charge your for the materials used;
- Buy your own 3D printer. You can find the Creality3D CR10 for only $359.99. Use the coupon code cr10mini3d at Gearbest and get yours: http://bit.ly/2JIUVrf
- Improvise! You can try to assemble a structure without 3D printed parts.
Interested in purchasing a DIY Kit? If enough people are interested, I might be offering a DIY kits on Tindie.com. If you would like one, send me a message.
Step 4: Wiring Up the Circuits
The circuit uses four main components:
- Firebeetle ESP32. This development board already comes with WiFi module, and a connector for a 3.7V battery. It can also charge the battery if you connect USB cable is connected.
I soldered the wires before putting the electronics inside the case. The components were connected as shown in the schematics.
- Display Vcc pin -> ESP32 3V3 pin
- Display Gnd pin -> ESP32 Gnd pin
- Display SDA pin -> ESP32 D3 pin
- Display SCL pin -> ESP32 D5 pin
- GY-521 Vcc pin -> ESP32 3V3 pin
- GY-521 Gnd pin -> ESP32 Gnd pin
- GY-521 SDA pin -> ESP32 SDA pin
- GY-521 SCL pin -> ESP32 SCL pin
The accelerometer isn't mandatory. You might even remove it to save some battery, if you wish.
Step 5: Assembling the Components
After printing the case and soldering the componentes, it's possible to assemble the gadget. I used M2 bolts and nuts to attach the electronics to the structure. The components shall be installed in the following order:
The battery had to be connected to ESP32's power connetor before attaching the ESP32 to the case using M2 bolts and nuts. Due to space limitations, there is an interference between the case and the connectors, and you won't be able to plug/unplug the battery once the microcontroller is fixed.
The button is made of a bolt + nut connected to a wire. That wire is soldered to a touch pin of the ESP32.
You can glue the front cover to the body of the wallet using a super glue. It's recommended to that only after uploading the code and testing the gadget, as it's described later.
Step 6: Working With Google Spreadsheet
A first step to improve the organization of your financial life is to start to record your income, investments and expenses. The use of Google spreadsheet would be a good and free tool for that, specially if you're dealing with the stock markets or cryptocurrencies.
The use of Google Spreadsheet would also allow you to create a database, from which a gadgets might read all sorts of data. I this project, a ESP32 with internet access was used to get some information about my cryptocurrencies (amount, value, etc.). These data are updated inside Google Spreadsheet itself, or manually by the user (if I buy more coins, for instance). Altough I used it for a financial purpose, you might use this approach for all kinds of data.
First of all, I had to define my spreadsheet: which data should be entered in each column, for instance.
1. Create a new Google Spreadsheet. Go to https://docs.google.com/spreadsheets/u/0/ and add a new blank spreadsheet.
2. You can rename your Spreadsheet by clicking its title on top left corner. Since I want to track my different assents (cryptocurrencies, stocks, etc.) I named it 'Assets'.
3. Install Cryptofinance Add-on. It will be used for getting the value of various cyptocurrencies.
a. Go to add-ons on the menu, and click "Get add-ons";
b. Search for "cryptofinance" and click "+FREE" to install it;
4. I used first column to store the names of my assets. Use the market cap for cryptocurrencies or stocks. For instance, BTC for Bitcoin, ETH for Etherium, GOGL34 for Google stocks, etc. The first cell is reserved for the title of column ('Assets').
5. Second column stores the amount of that asset. For instance, if you have 0.1 Bitcoin, enter that value on the line equivalent to BTC. As before, the title of the column ('Amount') was fulfilled in the first line.
6. Third column will store the ticker for each asset, i.e., their conversion to a given currency. Those values will be loaded from the internet using specific functions (CRYPTOFINANCE for cryptocurrencies, and GOOGLEFINANCE for regular stock market).
7. Fourth column stores the value of the asset, converted to the currency you chosed.
Step 7: Share Google Spreadsheet
This part of my project was based on José Morais amazing tutorial. You can find more at: https://portal.vidadesilicio.com.br/lendo-dados-do-google-planilhas-banco-de-dados/
- Go to https://console.developers.google.com/apis and create a new project. I named it 'Cryptocurrency';
- Under 'Credentials' select 'Create credentials'. Copy that value somewhere (you'll need it on your code);
- Go back to https://console.developers.google.com/apis. Click on 'Library', select 'Google sheets API', and 'Enable' it;
- Open the spreadsheet you want to use as a database;
- Click on 'Share' (top right corner) then 'Advanced';
- Your spreadsheet will probably be as 'Private'. In order to allow other gadgets to read it, you'll have to activate the option 'Share with anyone with the link', and save the new settings;
- Copy the ID of your spreadsheet (you'll need it later for the code).
Now you'll be able to read data from your spreadsheets from a gadget, for instance. Notice that this way your data will be public to anyone with the link. It won't be the really safe, so I suggest you not use it if you're affraid someone would use it without your concent. Also, don't share the link to your spreadsheet to anyone! You should be aware that this method shouldn't be used if there's a lot of sensible information on your spreadsheet.
Step 8: Setup ESP32 on Arduino IDE
For this project I used Arduino IDE for programming my NodeMcu. It's the easiest way if you've already used an Arduino before, and you won't need to learn a new programming language, like Python or Lua for instance.
If you've never done this before, first you'll have to add ESP8266 board support to the Arduino software.
1. Download and install Arduino IDE latest version
You can find the latest version for Windows, Linux or MAC OSX on Arduino's website: https://www.arduino.cc/en/main/software
Download it for free, install it on your computer and launch it.
2. Adding ESP32 board
Arduino IDE already comes with support to a lot of different boards: Arduino Nano, Mine, Uno, Mega, Yún, etc. Unfortunatly ESP32 isn't by default among those suported development boards. So in order to upload your codes to a ESP32 base board, you'll have to add its properties to Arduino's software first.
- Navigate to File > Preferences (Ctrl + , on Windows OS);
- Add the following URL to Additional Boards Manager textbox (the one on the bottom of the Preferences window):
- If the text box wasn't blank, it means had already add other boards before on Arduino IDE before. Add a comma at the end of the previous URL and the one above.
- Hit "Ok" button and close the Preferences Window.
- Navigate for Tools > Board > Boards Manager for adding your ESP32 board.
- Type "FireBeetle-ESP32" on the search text box, select "FireBeetle-ESP32 Mainboard by DFRobot DFRDuino" and install it.
Now your Arduino IDE will be ready to work with ESP32 FireBeetle board.
If you wish to use an ESP8266 based board, add the appropriate board.
3. Adding the libraries
The following libraries will be used for our Arduino code. Download the following libraries:
- Arduino http client library (https://github.com/arduino-libraries/ArduinoHttpClient)
- esp_deep_sleep.h library (https://github.com/pycom/esp-idf-2.0/blob/master/components/esp32/include/esp_deep_sleep.h)
- WiFiClientSecure library (https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFiClientSecure)
- ArduinoHttpClient (https://github.com/arduino-libraries/ArduinoHttpClient)
- ArduinoJson library (https://github.com/bblanchon/ArduinoJson)
- SH1106 library (https://github.com/wonho-maker/Adafruit_SH1106)
Navigate to Sketch-> Include Library -> Manage Libraries... on your Arduino IDE and add the libraries above.
Now that your dev environment is ready, let's move on to the next step!
Step 9: Arduino (ESP32) Code
At this point the gadget is almost finished!
Download the Arduino code and open it on the Arduino IDE. Some parameters will have to be updated (WiFi router SSID and password, Google spreadsheet ID and password, etc.). Update them, and upload the code to the ESP32. The code will start running immediately.
The ESP32 will enter deep sleep mode. Whenever touch button is pressed, the microcontroller will wake up, connect the WiFi network and read the data from Google spreadsheet. The amount of your coins will be displayed, along with the current ticker and value converted to your currency, before the ESP starts sleeping again. This way we can save some battery. The display will be blank while the wallet sleeps.
As you can see, the GY-521 accelerometer won't used in this step. You might even remove it if you wish.
Step 10: Bonus Round #1: Saving Money Quotes!
When it comes to money, it's always good to have good advice to help you save money! Wouldn't it be nice if your wallet could help you, with a few quotes from great thinkers, so you can reflect a little before you spend your precious money?
As you noticed before, the code designed so far won't make a lot of use of the display. In this step I add a new feature. Whenever you press the button, it will show you a random advice before moving on.
As shown before, download the Arduino code and open it on the Arduino IDE. Some parameters will have to be updated (WiFi router SSID and password, Google spreadsheet ID and password, etc.). Update them, and upload the code to the ESP32. The code will start running immediately.
Step 11: Bonus Round #2: Time Is Money!
What is the first thing you find on the display of any electronic equipment? Whether it's a microwave, TV receiver or cell phone, you'll always find a hidden clock somewhere! And for my smart wallet, it wouldn't be any different.
In this step I added a new feature to get current time from an internet server and display it on a display connected to the ESP32. The principle used here has already been presented in another of my tutorials:
Download the Arduino code and open it on the Arduino IDE. Update the parameters (WiFi router SSID and password, Google spreadsheet ID and password, etc.), and upload the code to the ESP32.
Now your IoT wallet will periodically pool current time from Google server and display it on the OLED display. Notice this will consume more battery, once the ESP will wake up regularly to check the time and update the display. The display will also consume some milliamps for displaying the clock all the time.
Step 12: Bonus Round #3: Improve Your Fitness, Improve Your Finances!
The best long-term investment you can make is to take care of your health. A healthy life can lead to fewer expenses with medicines, health insurance and miracle diets, which can lead to a happier and more economically stable life.
In this step I show you how to turn your smart wallet into a step counter, capable of recording your physical activity. This can motivate you to reach greater distances and save a few cents on each step. Registered data will be sent to Thingspeak, so your data will be securely stored and available for other devices.
There are a lot of datalogging services available for communicating a microcontroller to the web. With those services you can upload/download data to/from the cloud, and do a lot of cool stuff. Take a look on my tutorial on how to use an Arduino + ESP8266 to send data from a mini-weather station for Thinkgspeak for instance (link).
Create Thingspeak Channel
- Sign in at https://thingspeak.com/
- Click Channels > New chanell add create a channel named "Step counter". It will create a database, and we will use it store the number of steps every now and then.
- Click Keys > Write key and copy your key value.
Download the Arduino code and open it on the Arduino IDE. Update the parameters (Thingspeak key, WiFi router SSID and password, Google spreadsheet ID and password, etc.), and upload the code to the ESP32. You might also need to change the sensibility of the accelerometer on the code for a better step count.
Your IoT wallet will now be able to measure the number of steps you've taken in a given time, and send it to the cloud. This way you'll be able to plot some fancy graphs and even use those values to driver other events.
Notice your IoT wallet will now consume a lot of battery. It will have to keep the microcontroller and the accelerometer always on. You might periodically turn off the WiFi module to save some battery, and increase the time between synchronizations with the cloud.
Step 13: Final Considerations
I put a lot of effort into the realization of this project, to make it clear and educational. If you liked it, please don't forget to 'like' and 'share' it. Your support is very important to keep my job! :D
If you still don't follow my tutorials, take a look at those other projects in which I explain a little bit about internet of things, robotics and 3D printing. I hope you enjoy it!
Liked any of my projects? Please consider supporting my future projects with a small Bitcoin donation! :D
BTC Deposit Address: 1FiWFYSjRaL7sLdr5wr6h86QkMA6pQxkXJ