A wireless & portable smart weighing scale embedded system that interfaces with Node-Red for IoT connectivity and ERPNext for inventory & stock tracking.
The embedded system is developed on PlatformIO IDE and built on the Arduino framework.
- This application is supported in both Windows and Ubuntu 20.04
- This application have been tested on vultr cloud platform, other cloud platforms have not been tested.
- Install Node.js at https://nodejs.org/en/
- Install Node-RED at https://nodered.org/docs/getting-started/local
- Install MySQL on windows at https://dev.mysql.com/downloads/installer/
- Install MySQL on Ubuntu 20.04 using the terminal
- Typed in
sudo apt update
- Install mySQL server package using the prompt
sudo apt install mysql-server
- Ensure that the server is running using the prompt
sudo systemctl start mysql.service
- Run the security script
sudo mysql_secure_installation
, the first prompt will ask the user to validate the password. While the second prompt will be used for the MySQL root user. - You can check the condition of the services by using the command prompt
systemctl status mysql.service
- Typed in
- Install Influxdb at https://portal.influxdata.com/downloads/
- Install ERPNext using vultr (A cloud platform) at https://www.vultr.com/
There are several process that you should be aware of before running the flow;
- Within Microsoft Visual Studio, when trying to build and/or upload the code. In main.cpp (within the src folder), change the !!!WIFI_ID!!! and !!!WIFI_PASSWORD!!! according to your own network credentials. While the mqtt_server_IP_address change it according to your own IPv4 address.
// WiFI & MQTT
const char* id = "gdWS1"; // Unique Scale ID
const char* ssid = "!!!WIFI_ID!!!";
const char* password = "!!!WIFI_PASSWORD!!!";
const char* mqtt_server = "192.168.0.164"
- In ERPNext homepage;
i. Underneath "My settings"
ii. You will able to find API Access that could "Generate API Key", likes so;
iii. Once generated, you can copy both the API Keys and the API Secret onto the Node-RED flow.
iv. By using change nodes and an inject node, you can make it so that the API Keys of the ERPNext to be global.
Inside the ERPNext domain node;
Inside the ERPNext token node;
V. Once this is done, your ERPNext should be connected to the Node-RED
- Before importing the Node-RED flow, you need to install some Node-RED modules;
- node-red-contrib-influxdb
- node-red-contrib-aedes
- node-red-node-mysql
- node-red-contrib-bcrypt
- node-red-dashboard
- To ensure that the data of the scale is being properly read, you need to ensure that influxdb is properly run. To do this, make a database called location1 and location2.
Once done, proceed with inserting measurement onto our databases by using the command insert gdWS1/main value=0.1
for scale 1 and insert gdWS2/main value=0.1
for scale 2. Following is the successful configuration of both databases and measurements within scale 1;
Lastly, to see the value that is being read by using the command select * from “[Your Database Name]” order by time desc limit 5
;
- For mysql, there is a node in node-RED that users should be aware of when running the flow, it is the mysql node that looks like;
Upon importing the flow, the node should also be configured accordingly. In our case, we set it as;
and
Follow the documentation process for further detailed explaination.