You are on page 1of 14

technology workshop craft home food play outside costumes

IoT Weighing Scale


by Henri.Lacoste on December 28, 2016

Table of Contents

IoT Weighing Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: IoT Weighing Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: How does it work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: What you will need - Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3: What you will need - Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 4: The Chassis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 5: The Internal Workings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 6: The Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 7: The Top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 8: Hardware is done . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Step 9: Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Step 10: Use it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

http://www.instructables.com/id/IoT-Weighing-Scale/
Intro: IoT Weighing Scale
Hi, thanks for taking the time to come and have a look at my instructable. It has been super fun undertaking this project, in making it I have learnt so much and, I hope in
reading this you might learn something too. If you enjoy this instructable please consider voting for it in the Internet of Things competition, it would be greatly appreciated
:)

Inspiration

Through my girlfriend I was introduced to the food sharing app OLIO, an amazing initiative whose goal is to reduce food waste through peer-to-peer food sharing. Check
it out and spread the word. With food waste on my mind and the IoT Builders competition here on instructables, I decided I would try and create something that could
help reduce food waste.

What I have come up with is essentially a WiFi enabled weighing scale. The device is configured to IBM's Watson IoT Service and from there the data stream is sent
through a Node-RED flow to visualise the data.

How can it be used?

This device is not limited to combatting food waste, it can monitor just about anything. A few examples of what you could keep track of:

the amount of milk in the fridge


any food in the kitchen, never buy something you don't need again!
the weight of a plant, so you know when to water it
medication, so you can know when an elderly loved one needs to order more
keys by the door of a student flat, so you know when your friends are home

The possibilities really are endless, if it can be weighed and its weight changes, this device could be very useful.

Step 1: How does it work?


I am an architecture student, not a computer scientist and as such this project has been a steep learning curve. I'm sure there are a great many ways of creating this
project, perhaps more simple ways too. I have tried to keep the project as simple as possible. This project handles data in this way:
Node MCU ESP8266 receives data from the load cell via the HX711 board
NodeMCU connects to the internet via WiFi and sends data to Watson IoT Service
Node-RED receives data from Watson IoT Service and visualises the data
Data can be accessed from anywhere at the url https://iot-scale.mybluemix.net/ui

What are all these things?

NodeMCU ESP8266

The easiest way to describe the NodeMCU ESP8266 is that it is an incredibly cheap "Arduino-like" development board which has WiFi built in. I paid just 3.91 for mine
on eBay. Best of all you can program it in the Arduino IDE.

Load Cell

This is simply a bar of aluminium with two holes drilled at the centre - when supported at one end and with a load applied at the other an analogue reading is produced.

HX711 Board

http://www.instructables.com/id/IoT-Weighing-Scale/
This is an amplifier which converts the analogue reading produced by the load cell into a digital one readable by the NodeMCU ESP8266. I bought the HX711 and Load
Cell together for 3.42 also on eBay.

Node-RED

Node-RED takes a lot of the work out of IoT. It requires a much lesser understanding of programming and languages since it is visually based. It is exceptionally easy to
link your project to Twitter and send tweets or link your email account and send an email from it.
IBM Watson IoT Service

An online cloud service that can securely host you IoT project. Basically in this project the sensor data is sent to IBM's Watson IoT Service where it is received stored and
sent on to other places on the internet.

Step 2: What you will need - Materials


Shopping List:

This project requires very little in the way of materials. They are as follows:
NodeMCU ESP8266 link
HX711 Board and 5kg Load Cell link
Slide switch equivalent link
Dupont cables link
HTC Cell phone battery link
100mm x 100mm x 27mm of Oak (you can use equivalent hardwood)
Sprung 4 point contact (I salvaged mine from an old printhead)
2 pieces of translucent acrylic 100mm x 100mm x 7mm
2 x M4 countersunk machine screws 18mm long
2 x M5 countersunk machine screws 18mm long
2 x M4 pan-head bolts 15mm long
6 x M5 washers
2 x M5 nuts

Note:

My brother had an old HTC cell phone lying around that didn't work anymore hence the battery being used in this project. I am still able to charge the battery using the old
phone. If you were to buy the above battery make sure you have some way of recharging it.

Cost:

I was lucky enough to be able to find the acrylic and oak in the waste bins at my university workshop. I also had a scrap printer lying around from which I salvaged wires,
a switch and a spring contact. I also already had most of the nuts, bolts and washers. Altogether I spent around 10.

http://www.instructables.com/id/IoT-Weighing-Scale/
Step 3: What you will need - Tools
I am really lucky to have access to very well equipped workshops at university and before I left for the Christmas break I used a CNC router and Laser cutter. However,
you could still achieve this project without those specialist tools. Tools I used were as follows:
CNC router
Laser cutter
Bench-top disc sander
Bandsaw
Cordless drill
Jigsaw
Drill bits, various sizes
Needle files
Sand paper, various grades
Wire cutters
Pliers
G-Clamps
2 part epoxy, Araldite or equivalent
Super glue

This list is not exhaustive but the main tools I used are listed here.

http://www.instructables.com/id/IoT-Weighing-Scale/
File Downloads

IoT Scale Drawing.pdf (395 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'IoT Scale Drawing.pdf']
Step 4: The Chassis
CNC Router

As mentioned earlier I used a CNC router at uni. This is how I made the main enclosure of the device. I have attached the tool-path should anyone want to replicate the
piece. I used a 4mm straight router bit.

(At this stage I hadn't completely designed the whole device, it would have been great to have routed out the battery bay and slots in the base. Instead I did this at a later
stage with a jigsaw for the battery bay and a drill and needle files for the slots.)

Bandsaw

With the CNC router I only marked the perimeter with a 4mm deep cut rater than cutting the entire depth the whole way around. This was because the CNC router is quite
slow. I cut the waste off with the bandsaw.

Disc Sander

To round off the corners I used a disc sander

Image Notes
1. 27mm thick piece of Oak
2. 4mm straight router bit

http://www.instructables.com/id/IoT-Weighing-Scale/
Image Notes
1. Slot for base to lock into (cut by hand after design developed)
2. Slot for base to lock into (cut by hand after design developed)
Image Notes
3. Recess for battery cut with jigsaw
1. Round those corners
4. Hole to reset NodeMCU ESP8266
5. Countersunk holes for mounting load cell 5mm
6. Contact from old printhead

File Downloads

IoT Chassis CNC Toolpath.dxf (22 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'IoT Chassis CNC Toolpath.dxf']
Step 5: The Internal Workings
The diagrams above should provide sufficient information on what to wire where.

A few things to note:


The load cell should be mounted from the end with the M5 holes. Mine had a sticker showing which way up it should be mounted. I placed 3 M5 washers between
the oak chassis and the load cell to give extra space under the suspended end.
Make sure nothing ends up under the suspended end of the load cell.
Watch the height of the dupont cable connectors. Bend the pins of the NodeMCU ESP8266 if necessary, you don't want them to touch the underside of the
weighing pad.
I mounted the NodeMCU ESP8266 upside down, this meant I could attach cables more easily. It also means you can reset the module using a pin through a small
drilled hole in the oak chassis.
Using some very small screws you can secure the NodeMCU ESP8266 and the HX711 to the oak chassis through the pre-drilled holes on both the boards.

http://www.instructables.com/id/IoT-Weighing-Scale/
Step 6: The Base
Since the battery is rechargeable it was necessary to make it easily accessible. The base is made up of a rounded square piece of acrylic with two pan-head machine
screws which protrude the thickness of the base of the oak chassis. These two screws slot in to two key hole slots cut into the base of the oak chassis and slide across to
secure the base.

To make the key hole I drilled a 5mm and a 3mm hole a centimetre to one side. I then used a round needle file to connect the two. You can see the base being
removed in an earlier video in the instructable.

Image Notes Image Notes


1. Pan-head machine screw M4 15mm 1. Key hole slot
2. Pan-head machine screw M4 15mm 2. Key hole slot

Step 7: The Top


Making

The weighing surface (top) is pretty much the same as the base. It is also made from 7mm thick acrylic. Two holes are drilled and countersunk to line up with the load cell
mounting holes. These countersunk holes then receive two M4 countersunk machine screws which are 18mm long. It is important they are countersunk to ensure a flat
weighing surface.

Mounting

I placed two M5 nuts over the load cell holes to allow a gap between the underside of the weighing surface and the load cell bar. Place the acrylic on top and tighten.

Image Notes Image Notes


1. M5 nuts space the top from the load cell 1. Countersunk 4mm holes

http://www.instructables.com/id/IoT-Weighing-Scale/
Image Notes
1. M4 18mm long machine screws

Step 8: Hardware is done


Great, we have finished our hardware. Now time to get the software up and running.

Step 9: Software
Arduino IDE

Download the two .ZIP files. Add the pubsubclient library in the Arduino IDE by going to Sketch>Include Library> Add .ZIP library...

You will also need to add the NodeMCU ESP8266 board to your Arduino IDE. I found this instructable to be very informative and useful in getting started with the Arduino
IDE and NodeMCU ESP8266 link.

Open the Arduino sketch and edit the following:

#define WLAN_SSID "your_network_name" //Put your SSID here

#define WLAN_PASS "your_network_password" //Put you wifi password here

You will also need to edit the following 4 lines however you won't know your relevant details until the next part of this step (configuring your IBM Bluemix device):

#define ORG "your_organisation_ID"

#define DEVICE_TYPE "your_device_type"

#define DEVICE_ID "your_device_ID"

#define TOKEN "your_token"

IBM Bluemix

The first thing you need to do is go and sign up for a free trial of IBM Bluemix link. I figured a screen-shot series (above) would be the best way to describe how to
configure the online portion of the software. Follow that and once you know your organisation_ID, device_type, device_ID and token go back and edit the Arduino sketch.

Another thing you will need to do is to add the Node-RED dashboard so that you can use the "gauge" node. Instructions are included in the screen shot series.

Calibration

http://www.instructables.com/id/IoT-Weighing-Scale/
You will find that the number you get is wrong, i.e when nothing is on the scale it doesn't read 0. Find the line of code in the Arduino sketch:

valCalibrated = (val - 4137240) / 234.20;

Start by substituting this line with just "valCalibrated = val" take a note of the value arriving at the Node-RED debug window. Let's assume that value is 2500 for example.
Re upload the sketch with this line:

valCalibrated = val - 2500;

Now you need to work out your scale factor. Place a 100g weight on the scale. Note the number arriving at the Node-RED debug window. Let's assume it is 1500. Since
this is the value for 100g our scale factor is 100 times smaller i.e. 15

valCalibrated = (val - 2500) / 15;

A video which really helped me understand calibrating a load cell can be found at the following link

Final Notes

Upload the sketch for a final time. Now go to yourappname.mybluemix.net/ui you should find a nice looking gauge with a live feed of data coming from your IoT Scale.
Well done!

Image Notes
1. This is my currently working app but this series of screen shots will guide you
to creating your own.
2. Click on "Create App +"

Image Notes Image Notes


1. Click here to create an "Internet of Things Starter" 1. Name your app
2. This will be the domain of your final app
3. Click here to create your app

http://www.instructables.com/id/IoT-Weighing-Scale/
Image Notes Image Notes
1. Start your app 1. Your app is now running, click on the route url to open Node-RED

Image Notes
1. This is where you can create your first flow Image Notes
1. This is a default flow which you can delete

Image Notes Image Notes


1. Go to https://internetofthings.ibmcloud.com 1. Go to the devices tab

This is where we will add the device which sends our weighing data
2. Sign in with your IBM Bluemix details

http://www.instructables.com/id/IoT-Weighing-Scale/
Image Notes Image Notes
1. This is my connected device, we will add one as an example 1. You don't need to put lots of details in for the following windows which pop up.
2. Click here to add device I only put in Device Type and Device ID. I put "ESP8266" for both, perhaps
"ESP8266" and "IoT Scale" respectively would have been more appropriate

Image Notes Image Notes


1. This is the most important part of adding a device, this is the information 1. Our example device is added
needed for your Arduino sketch. It will ensure the data is sent to the right place.
Take note of it

Image Notes
1. Go to the route url once more, we can now reference our device in the Node-
RED flow Image Notes
1. This is the flow I created to handle the data stream. I have attached it for
download. Read on to find out how to import it

http://www.instructables.com/id/IoT-Weighing-Scale/
Image Notes Image Notes
1. To import the flow I have provided click the hamburger>import>clipboard and 1. Install this to use the "gauge" node I have used
paste the flow code

2. To add the dashboard node click here

Image Notes Image Notes


1. Double click the IBMIoT node to configure it 1. This is the function node. It grabs just the numerical data of the weight from
2. Input your device details the message payload. This makes it readable by the "gauge" node

http://www.instructables.com/id/IoT-Weighing-Scale/
Image Notes
1. If everything has worked correctly yourappname.mybluemix.net/ui
should take you to a live gauge feed of the weight on your IoT scale

File Downloads

pubsubclient-master.zip (36 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'pubsubclient-master.zip']

IBM_Watson_Node MCU_IoT Scale.zip (3 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'IBM_Watson_Node MCU_IoT Scale.zip']

Node-RED flow.rtf (1 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Node-RED flow.rtf']
Step 10: Use it
Put something on the scale and keep track of it from anywhere you have an internet connection. If you have enjoyed this instructable please consider voting for it in the
Internet of Things competition, it would be greatly appreciated :)

Any problems at all please leave a comment or message me. Hope you have enjoyed this instructable.

Happy making!

Related Instructables

IoT Oil Tank Install Node- Install node red Making a IoT Controllable Connected Cars
Gauge With IBM RED on Intel on lubuntu IoT cloud service Led (Music With Intel
Bluemix and Edison by Atlas7 by Jhon_Control with ARM mbed Visualizer + IoT) Edison by
Maximo by platform and by vhajar ShreyasUpasane-
DanF115 IBM Bluemix by DIGIT
Eric.Hyungki.Jung

http://www.instructables.com/id/IoT-Weighing-Scale/
Advertisements

Comments

http://www.instructables.com/id/IoT-Weighing-Scale/

You might also like