-
11Setup FireBeetle ESP8266 on Arduino IDE
For this project I used Arduino IDE for programming my ESP8266. It's the easier 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 ESP8266 board
Arduino IDE already comes with support to a lot of different boards: Arduino Nano, Mine, Uno, Mega, Yún, etc. Unfortunatly ESP8266 isn't by default among those suported development boards. So in order to upload your codes to a ESP8266 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): https://raw.githubusercontent.com/DFRobot/FireBeetle-ESP8266/master/package_firebeetle8266_index.json
- 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 adding your Firebeetle ESP8266 board.
- Type "Firebeetle-ESP8266" on the search text box, select "FireBeetle-ESP8266 by DFRobot" and install it.
Now your Arduino IDE will be ready to work with the Firebeetle ESP8266 development board.
3. Adding the libraries
The following libraries will be used for our Arduino code. Download the following libraries:
- Adafruit NeoPixel library (https://github.com/adafruit/Adafruit_NeoPixel)
- Arduino http client library (https://github.com/arduino-libraries/ArduinoHttpClient)
- Arduino IO library (https://github.com/adafruit/Adafruit_IO_Arduino)
- Adafruit MQTT library (https://github.com/adafruit/Adafruit_MQTT_Library)
- HX711 library (https://github.com/bogde/HX711)
- Firebeetle LED matrix library (https://github.com/Chocho2017/FireBeetleLEDMatrix)
Navigate to Sketch -> Include Library -> Manage Libraries... on your Arduino IDE and add the libraries above.
-
12Adafruit.IO Configuration
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.
Adafruit.IO is one of those free services. It's really easy to use and promises to bring internet of things to everyone!
Create Adafruit IO Web Feed
- Sign in at https://io.adafruit.com/
- Under Feeds >Create a new Feed add a new feed named "my weight". It will create a database, and we will use it store the commands received by the gadget.
- Copy your Adafruit.IO key, which will be later used for allowing your device accessing the database. Navigate for Settings > View AIO key and copy the active key code. You'll need it for your Arduino (NodeMCU) code later.
In the next step I will show you how to configure IFTTT, another platform I used in this project. Whenever the NodeMCU measures your weight, it will save this value on Adafruit.IO database. IFTTT platform will then send the value to fitness tracking plaform (Fitbit, Strava, iOS Health or Misfit).
-
13IFTTT Configuration
IFTTT is a free platform that helps you connects apps and devices. You can use it to connect your smartphone with other gadgets, or to share data between your favourite webservices (like Google, Facebook, Twitter, Instragram, etc.) and other physical devices, for instance. And the best part is that it's really easy to use!
IFTTT uses a "if this then that" logic, where "this" represents a service that will trigger a given action given by "that". This way you create small applets connecting webservices and devices.
For this project I used IFTTT for pushing the measured weight from Adafruit.io database fot Fitbit.
First you'll have to sign in at:
Then install IFTTT app on your smartphone. You can find it at Google Play Store:
https://play.google.com/store/apps/details?id=com.ifttt.ifttt
You can also find it on Apple store (for iPhone users):
https://itunes.apple.com/us/app/ifttt/id660944635?mt=8
On the website, navigate to New Applet (click the arrow button next to your login to access the menu). I the next step I'll show you how I created my applet.
-
14IFTTT Applet - IOS Health
Create the applet on the website:
- Click +This;Type "adafruit" on Seach service text box and select Adafruit.IO > Any new data. As it's described on IFTTT website, it will create a trigger that fires any time there is new data in your feed. Select "my weight" feed;
- Now choose +That;
- Type "ios health" and select iOS Health > Log your weight. This save a new weight measurement to iOS Health. Click add ingredient and select Value.
- Finish your applet and turn it on.
Testing:
- On Adafruit.io, select your feed, Actions > add data;
- Enter your current weight (or any other value). This value will be stored on Adafruit.io database. IFTTT will listen to it and upload it to Fitbit database;
- Log in your Fitbit account an verify if your current weight was updated.
-
15IFTTT Applet - Fitbit
Create the applet on the website:
- Click +This;Type "adafruit" on Seach service text box and select Adafruit.IO > Any new data. As it's described on IFTTT website, it will create a trigger that fires any time there is new data in your feed. Select "my weight" feed;
- Now choose +That;
- Type "fitbit" and select Fitbit > Log your weight. This save a new weight measurement to Fitbit. Click add ingredient and select Value.
- Finish your applet and turn it on.
Testing:
- On Adafruit.io, select your feed, Actions > add data;
- Enter your current weight (or any other value). This value will be stored on Adafruit.io database. IFTTT will listen to it and upload it to Fitbit database;
- Log in your Fitbit account an verify if your current weight was updated.
-
16ESP8266 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_SSID, WIFI_PASS, IO_USERNAME, IO_KEY, and calibration_factor). Update them, and upload the code to the ESP8266. The code will start running immediately.
To calibrate the scale, put a know weigth object on the top of the scale, and adjust its factor until it indicates the right value. You can measure your own weight on another scale you trust, them measure your weight again on the IoT scale and adjust the factor accordingly.
The smart scale will try to connect the WiFi network and start taking some measures. If the weight measured rises above a given value (THRESHOLD), it will read the weight a given number of times (NUM_MEASUREMENTS) and calculate the average weight. If the weight changes more than a certain value (THRESHOLD1) between two consecutive measures, the process will be restarted.
After the average value is determined, it will be displayed on the LED matrix and transmitted to Ardafruit.io. The scale will wait until the user steps out, and restart.
-
17Usage
The smart scale will try to connect the WiFi network and start taking some measures. If the weight measured rises above a given value (THRESHOLD), it will read the weight a given number of times (NUM_MEASUREMENTS) and calculate the average weight. If the weight changes more than a certain value (THRESHOLD1) between two consecutive measures, the process will be restarted.
After the average value is determined, it will be displayed on the LED matrix and transmitted to Ardafruit.io. The scale will wait until the user steps out, and restart.
-
18Final Considerations
I put a lot of effort into this project, to make it as clear and educational as possible. If you liked it, please don't forget to 'like' and 'share' it. Your support is very important to keep my job! :D
Please vote on this project for Instructables Woodworking Contest!
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 them too!
https://www.instructables.com/id/IoT-Wallet-smart-Wallet-With-Firebeetle-ESP32-Ardu/
https://www.instructables.com/id/IoT-Air-Freshner-with-NodeMCU-Arduino-IFTTT-and-Ad/
https://www.instructables.com/id/Minimalist-IoT-Clock-using-ESP8266-Adafruitio-IFTT/
https://www.instructables.com/id/3D-Printed-Articulating-LED-Lamp/
https://www.instructables.com/id/Nunchuk-Controlled-Robotic-Arm-with-Arduino/
Liked any of my projects? Please consider supporting my future projects with a small Bitcoin donation! :D
BTC Deposit Address: 1FiWFYSjRaL7sLdr5wr6h86QkMA6pQxkXJ
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.