Our names are Celia Garrido-Hidalgo and Luis Roda-Sánchez, Industrial Electronics and Automation engineers and currently students of the Master Degree in Industrial Engineering by the University of Castilla-La Mancha (Spain). Our project is called "Logifox" and is focused on reverse logistics using Sigfox.
Logifox in a NutshellLogifox is a low-power IoT device that contributes to circular economy by managing the reverse flow of reusable parts disassembled from products that are returned to supply chain by end-customers. It consists of a Sigfox-ready prototype attached to a pallet thought to be used in warehouses for real-time inventory tracking of parts. In this video we introduce the prototype:
The concept is simple: IoT for reverse logistics to minimize e-waste. Here's the architecture of the solution implemented:
According to the U.S.Environmental Protection Agency (EPA), more than 416, 000 mobile phones and 142, 000 personal computers are discarded every day. In fact, only the 16 % of these devices are actually recycled, reaching the amount of 49.8 million tons of worldwide e-waste expected to be generated by the end of this year.
Environmental monitoring of pollution and greenhouse gases is a great application for IoT but, what if we tackle the roots of the problem by reducing the amount of electronic waste worldwide? Not only could we promote Circular Economy to raise global awareness, but also provide end-customers with an active solution able to simplify the ordering of electronic components that could be reused. Well, here is where Logifox comes into play.
The Idea Behind LogifoxLogifox is a Sigfox device thought to be attached to pallets in smart warehouses to keep inventory levels of reusable parts updated. It includes a load cell to classify incoming parts disassembled from products such as computers, televisions of phones and, on the arrival of any new item, it updates inventory information on Sigfox backend.
Although Logifox is the core of the hardware prototype, the low-power wireless connectivity provided by Sigfox enables a sustainable IoT development. Besides, to track inventory levels and enable customers to access real-time information, we have developed a multiplatform application for SmartPhone, considering RAM memories, hard disks and graphic cards as categories of reusable parts:
The next picture shows how a typical supply chain would cooperate, highlighting the reverse flow of products from many organizations to an intermediate warehouse, where many smart pallets based on Logifox track inventory levels and update information on the app using the global Sigfox network infrastructure and cloud.
The main benefits of Logifox are:
- Reverse Logistics enabler: it facilitates the management of a reverse flow of reusable parts by providing automatically inventory information associated to each pallet. By promoting the reuse of electronic parts we can avoid the manufacturing of extra components (so that the existing ones can be used until their end of life) and minimize the impact on the environment of disposed components, whose recycling procedure can also be harmful.
- Simplicity of use: it encourages customers to get information of second-hand products and parts that are perfectly reusable, through the use of a straightforward interface updated in real-time through the Sigfox backend.
- Smart connectivity: its IoT connectivity provided by Sigfox technology enables a full cooperation with Smart Logistics platforms based on Industry-4.0 solutions.
- Power awareness: not only it promotes recycling and reusing strategies, but demands a reduced power itself.
- Few resources: Logifox is a lightweight device that exploits the hardware resources used. A tiny IoT board, the MKR FOX 1200, sending at most 140 messages a day is more than enough to update inventory information of a specific pallet, not requiring further wireless technologies or infrastructures.
Logifox is composed of a load cell, accelerometer and Sigfox radio module (integrated in the MKR FOX 1200 board). Since it communicates with the Sigfox backend to transmit inventory data, the mobile app acts as user interface for end-customers aiming to order reusable parts contained on pallets. The app is based on Apache Cordova framework and JQuery Mobile plugin and connects to Sigfox backend to gather inventory information.
The inteface of the app is simple, a main menu to select the category of reusable part to track and three secondary screens (as an example) to get useful information from each category such as pallet identifier, number of items on it or warehouse ID, among others. For this, Firebase has been used as an intermediary database to store Sigfox messages from the pallets in a JSON file and forward these messages to the app in real-time.
The following sections describe the hardware developments and software programming required to implement the prototype of Logifox, in addition to some screenshots of the app developed working with Firebase and the Sigfox backend.
1. CREATE IT: #HWThis section focuses on the hardware and the setup of the tools and materials used to develop Logifox.
#HW1: Setting Up the PalletIn the first place, we have acquired tiny pallets to be used as weighing platform for inventory management. The following picture shows the ones required for the first step: drill, load cell, screws, methacrylate sheet and double-sided PCB.
Then, we have hollowed the pallet using the drill and introduced the screws as shown in the following picture. Here you can find a useful guide on how to setup a load cell with the HX711 amplifier. Any amplified could have been used, but this one is typically distributed with the load cell itself, since it includes an analog to digital converter and facilitates the programming developments.
A brief checklist to ensure that everything is OK with the load cell:
- The arrow should point to the right direction (down).
- The thinnest screws should be used to screw the load cell to the upper surface and the thicker to fix the usion with the base of the prototype.
- A small separation is required between the load cell and the two surrounding surfaces, in any other case the sensor would find difficulty in weighing correctly parts because it would receive stress in different points.
In this second step we used the Dremel to hollow the surface of the methacrylate sheet and screw the platforms.
Then, all sensors with no pre-soldered connections were setup (see the following picture of the accelerometer), and a first prototype of Logifox was achieved, using a normal breadboard in order ro test its operation.
*Important: do not forget to connect the 868 MHz antenna before using Sigfox radio, since it could damage the device (check the official documenation here for more information).
Once the prototype is deployed and everything works (see the #SW sections before continuing with this step), let's move it to a more robust design!
For this, we need one more time the soldering iron to solder the Arduino MKR 1200 FOX board to the double-sided PCB (our recommendation is to solder just the required pins, because in any other case it will be very difficult for you to remove the connections without damaging the pins). The same happens with the accelerometer and HX711 board.
In this case the soldered pins are: Digital2, Digital3, SDA, SCL, Vcc and GND.
The initial and final results of the connections (done with jumpers on the bottom side of the PCB) are in the following picture:
Eventually, two pins were screwed to the battery pins in order to source it with an external voltage. The battery used is a 3V7 LiPo of 660 mAh. For the selection of the battery, the answers of the Arduino forum were quite useful and (we can confirm) that everything works as expected:
Once followed all the steps, the hardware setup of Logifox is done, now let's change to software and programming (more time-demanding).
2. MAKE IT WORK: #SWThis section focuses on the software and the setup of the tools and platforms used to develop the functionality of Logifox. Since we have used many platforms combined to achieve the end-to-end connectivity, please, follow the steps in the same order as described.
#SW1: Arduino Libraries SetupIn the project Fox Advisor, we explained some months ago how to include Arduino libraries (from zero). A brief description is included in this project:
We can find the MKR FOX 1200 libraries directly in the sketch menu of Arduino IDE. In case they're not present, we can include them using the libraries manager.
In this case, apart from the MKR library, we'll need the following:
- <SigFox.h> (download)
- <MPU9250> (download)
- "HX711.h" (download)
Although the HX711 and MPU9250 boards used are not the official ones from SparkFun, these guides are equally useful by the time of setting up the libraries, documentation and connections: "HX711" "MPU9250".
In the first place, to program the load cell a previous calibration sketch is required. One calibrated, we will obtain a calibration factor (in this case 671) which should be introduced into the final programming code. This sketch is available online and at the end of this project (referenced to the original author with some small modifications).
Regarding the accelerometer, we measure acceleration and compare it with reference values to ensure that the Smart Pallet doesn't check inventory while it's being transported by a truck, for instance. Thus, weight is only measured by the load cell when the three acceleration data say that the pallet is not moving. This is a double-check security purpose. See the programming code for further information about the way in which we check motion.
#SW2: Apache CordovaApache Cordova is an open source development framework. It enables developers to build mobile apps using HTML, CSS and JavaScript (JS). Cordova can be used across several platforms easily and it provides access to native device APIs. In this case, we have chosen an Android device, but with other platforms the procedure is analogous. We recommend this guide to create a new Cordova project. Open your terminal and perform the following steps:
cordova create DemoProjectcom.evothings.demoapp DemoApp
cd DemoProject
cordova platform add android
cordova build android
Finally, your app folder should show something like this:
After that, you have to add some packages using the command android sdk
on your terminal. Once the Android SDK Manager is open, you must install your android API (depending on your android version), the android tools package and several extra packages (found in Extras folder) in order to use Firebase Realtime Database. These packages are:
- AndroidSupport Repository
- GoogleRepository
- GoogleUSB Driver
As you can see in the next figure:
We will extend the way to use this framework to develop our app.
#SW3: FirebaseWe selected Firebase Realtime Database to store data from Sigfox backend. It's a NoSQL cloud-hosted database where data is stored as JSON and synchronized in realtime to every connected client.
First, we have to create a Firebase account. When we log in with our Google account we can see something like this, where we have to click on add new project:
We are sorry but the web automatically translated the content to spanish, so we couldn't include screenshots in english. Anyway, we will comment all structions and you will be able to follow the steps.
Now, we have to add a project name and accept the conditions as far as you agree.
Once we have accepted, our project is created and we can click on database.
Then, select start with testing mode (see screenshot). In this mode, the rules of our database are set up for prototyping porpuses but for a final development an authentication mode has to be selected.
This should be the aspect of your database at this point:
Now, we should add Firebase to our app. In this case, as mentioned before, we are developing an Android app. First, we should install Firebase in our app using npm install --save firebase
command. Later, we have to select Android app configuration.
After that, another page shows some steps to install Firebase Realtime Database. The first thing we have to do is to find our build.gradle file placed in app directory and look for the applicationId name in our app since we have to write it in the textbox.
Now, a google-services.json has been created and you have to place it in your app directory.
It's time to add Firebase SDK to our project. For this, we have to open the build.gradle file located in the project path and copy the first text in the specified piece of code. The second and third texts should also be added to build.gradle file located in app level.
Finally, Firebase waits for the application connection. We should open a terminal and go to the root directory of our project. Now, we should type cordova run
to build the application. After that, a successful message should appear and our Android app is already connected to our realtime database.
Regarding the Sigfox backend, first of all it is necessary to register the device to start using it. These steps are explained in short in the following lines, being the complete explanation part of a previous Hackster project of ours: Fox Advisor.
Let's start by creating a new account and activating the Sigfox device. For this, click and select a provider (Arduino) and your country. The next step is to introduce the ID and PAC codes. You'll find them in the Serial console of Arduino IDE, by executing the FirstConfiguration.ino example of the <SigFox.h> library.
Finally, if you don't have an account, you'll be able to create it in this step so that you registered device is associated with your user account.
Once we log in we have access to the Sigfox dashboard, where we'll click on device and, then, device type. Then, on the left-hand menu click 'callbacks' and create a 'custom callback'. The following pictures summarize the process:
In this case, the configuration used for the callback to PUT data into Firebase is the following:
- Type: DATA, UPLINK
- Channel: URL
- URL pattern: https://logifox-XXXX.firebaseio.com/itemsReport.json
- Use HTTP method: PUT
- Content type: application/json
- BODY:
{
"ram":
{
"ID": "{device}",
"payload": "{data}"
}
}
#SW5: AppThe app has been developed with Apache Cordova framework and jQuery mobile plugin has been used for the design of the interface. When we create a Cordova project, in the www folder we can see our index.html document. It's used to define the content and appearance of our app. The functionality is added by the index.js file located in the www/js folder. Besides, we can include images to our app using the img folder and define styles that will be used in the project in index.css.
Here you can see very useful guides to configure Firebase in the app. The code below shows the packages added and the initialization of Firebase in index.html file to manage our database with our app (where secret keys have been removed).
<script src="https://www.gstatic.com/firebasejs/4.0.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.0.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.0.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.0.0/firebase-database.js"></script>
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "XXXXXXXXXXXXXX....XXXXXXXXXXX",
authDomain: "XXXXXXXXXXX.firebaseio.com",
databaseURL: "https://XXXXXXXXXXX.firebaseio.com",
storageBucket: "",
messagingSenderId: "XXXXXXXXXXXXX",
};
firebase.initializeApp(config);
var ref = firebase.database();
</script>
As can be observed, four packages have been added specifying their respective versions. Config variable is used to place apiKey, messagingSenderId (found in configuration/cloud messaging) and other parameters shown in database.
The code developed for our app can be observed in the programming code included in this project and the final design of the interface can be seen in the following figures:
In this project we developed the complete functionality of RAM memory category whereas hard disk and graphic card categories have been programmed with default values.
Final Result and DemoThe result is the prototype shown in the following video, which communicates with the Sigfox backend, Firebase and Cordova app to monitor inventory levels of reusable parts. In this demonstration, the parts used are RAM memories disassembled from laptops that had different reasons of failure.
That's all! From now on, reducing e-waste is in your hands!
Comments