Scale project for Arduino and Wemos D1

Scale project for Arduino and Wemos D1

wemos d1 project

Scale project – Arduino and WiFi scale (see part 2 of this tutorial) from pallet wood

This scale project is built around the Arduino Uno and part 2 of this tutorial around the Wemos D1 development board. In its basic form, it will display the weight of an object on an LCD display and in the next tutorial in a web page using WiFi. This project can of cause be expanded even more to capture the weight in a database and so on. Here are lots to learn, from weight load cells all the way to Wifi with the D1 board that is cheaper than an Arduino Uno. We have a review  of the Wemos D1 here:

When doing an Arduino or Wmos D1 scale project there are a couple of things to know, The first is the development board itself, then the coding that can be done directly from an Arduino IDE and then some HTML coding to create the web page when doing the WiFi parts. If you are already coding Arduino projects you have very little learning to do on the coding of the Wemos D1 board.

 

The Wemos D1 board is designed to be similar than an Arduino Uno and you will immediately recognise the power headers and I/O header.

If you are not planning to use the scale as a wifi project the Arduino Uno will be just fine.

The D1 microcontroller is much more powerful than that of an Arduino

Saying that… you can easily build this scale using an Arduino Uno if you prefer.

One thing that stands out from the D1 is that it uses the very powerful ESP8266 chip that is a microcontroller and Wifi chip all in one. What’s even more impressive is that the microcontroller is much more powerful than an Arduino microcontroller with much more memory for your wifi projects.

Read this post first: Before you move on, read this blog post that has much more details about the Wemos D1 development board and how to set it up for the first time. https://www.botshop.co.za/wemos-d1-review-wifi-development-board/

Let’s look at the scale first.

To build a scale you need 3 parts: load cells, an amplifier and then a micro controller to interpret the results and display it somehow. The micro controller can be one of many, including a WeMos D1, ESP8266 controller, Arduino and Raspberry Pi.

load cell image

Load cells come in many different types and if you plan on working with them extensively you will need to read up on all the types available. In this tutorial, we use  50kg load cells that is one of the products we sell on our site here. You will need 4 load cells that you must place on the 4 corners of a solid base that will act as the weighing platform of your scale.

The 4 load cells can handle 50kg each so you will end up with a scale that can measure up to 200kg.

scale frame   load cell

It does not have to be fancy, we used a couple pieces of pallet wood to create the base as shown in above picture, then you need to drill big holes for the cells to fit, note the correct way to fit the cells in above picture.

The HX711 load cell amplifier

Load cells operate at very small voltage changes, therefore an amplifier will be required. We sell the HX711 Load Cell (Weight) Amplifier that works perfectly with the load cells.

Below is a diagram on connecting the cells to the amplifier. The diagram and code below are for an Arduino and in our next tutorial, we will show you how to connect it to a Wemos D1 to change your scale into an “Internet of things” project.

load cell amplifier

Below is the code to get it going for your Arduino. It will print the weight out in Serial monitor for now.

#include "HX711.h"

// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0

HX711 scale(A1, A0);

void setup() {
 Serial.begin(9600);
 Serial.println("HX711 Demo");

Serial.println("Before setting up the scale:");
 Serial.print("read: \t\t");
 Serial.println(scale.read());

Serial.print("read average: \t\t");
 Serial.println(scale.read_average(20));

Serial.print("get value: \t\t");
 Serial.println(scale.get_value(5));

Serial.print("get units: \t\t");
 Serial.println(scale.get_units(5), 1);

scale.set_scale(2280.f); 
 scale.tare();

Serial.println("After setting up the scale:");

Serial.print("read: \t\t");
 Serial.println(scale.read());

Serial.print("read average: \t\t");
 Serial.println(scale.read_average(20));

Serial.print("get value: \t\t");
 Serial.println(scale.get_value(5));

Serial.print("get units: \t\t");
 Serial.println(scale.get_units(5), 1); 
 Serial.println("Readings:");
}

void loop() {
 Serial.print("one reading:\t");
 Serial.print(scale.get_units(), 1);
 Serial.print("\t| average:\t");
 Serial.println(scale.get_units(10), 1);

scale.power_down(); 
 delay(5000);
 scale.power_up();
}

LCD screen

Next, you will need a display and here you have many choices. The easiest to use is the I2C LCD display. We also have a basic LCD display that is cheaper.

Whats the difference? The I2C LCD shield has an extra board connected to the normal LCD shield, turning it into an I2C device, that means it has much fewer wires to connect and it is much easier to program with. The little I2C board take away allot of the job the Uno had to do.

That concludes our scale project, our next tutorial will take this scale and change it into a wifi (internet of things) scale using the Wemos D1 board.

Part 2 of this project is here!

Wemos D1 review  Wifi development board

Wemos D1 review Wifi development board

ESP-12E WeMos D1 review

Wemos D1 review

This board has quickly become our board of choice when we do Wifi project development. It looks just like an Arduino Uno and many Arduino shields will work with this board. We sell them here at Bot Shop – https://www.botshop.co.za/product/esp-12e-wemos-d1-wifi-board/

We created a scale project using this board, you can read more about the project here:

We pulled in a weight from scale sensors but without much changes, you can do the same with any type of sensor.

The D1 microcontroller is a beast compared to the Arduino Uno

The WeMos D1 uses the ESP 8266 microcontroller that is 2 x faster than an Uno, has 160Kbs of Ram compared to the 2K of an Uno and a 100x  the amount of  Flash memory! And each I/O pin is interruptable!

Most importantly is that it has embedded Wi-Fi and the centre point of this wemos d1 review.

Microcontroller specs

• A 32 bit RISC CPU running at 80MHz
• 64Kb of instruction RAM and 96Kb of data RAM
• 4MB flash memory
• Wi-Fi
• 16 GPIO pins
• I2C,SPI
• I2S
• 1 ADC

The only area the Arduino chip is better is that it has 6 ADC’s and the D1 just one, although that will very seldom a problem as you have both I2C and SPI on the chip, it is still worth taking note of this. If you need more ADC’s it is easy to add a multiplexer to increase the amount of ADC’s.

Use your Arduino IDE to program the chip.

The Arduino IDE can be used to program the D1. The Wemos D1 have a USB to TTL chip on board for direct uploading of programs via USB directly from your PC. The chip used is the CH340G chip and unfortunately, a driver needs to be installed for some versions of Windows that does not include this driver. If your Windows version does not recognise the board it can easily be downloaded and installed, doing a Google search on “CH340G driver” will show many download links.

In this Wemos D1 review we do not want to go to much into details regarding programming but I have good links to follow, Also have a look at our scale project mentioned earlier in this review.

The next thing you will need to do is to add the Wemos D1 board to the list of boards already in the Arduino IDE. Here is an instructable on how to do that, it is pretty good http://www.instructables.com/id/Programming-the-WeMos-Using-Arduino-SoftwareIDE/

Oh, you will be able to upload to the board. To get the WiFi to work is not as difficult as I thought it will be, I used this instructable to do so: http://www.instructables.com/id/Programming-a-HTTP-Server-on-ESP-8266-12E/

Pin assignments

Something to note is that the pin assignment between the D1 and Uno is different. The Uno has the onboard led connected to pin 13 and the D1 to pin 14 as can be seen from the table below, If you, for example, upload the blink sketch to the D1 you will first need to change the sketch by replacing all calls to pin 13 to pin 14.

Wemos D1 pin assignments

Some things to be aware of.

  • As discussed the pinout differences, of cause the power pins are at the correct places.
  • Becuase of the pinouts some Arduino shields will not work out of the box, you will need to change the pin mappings. As an example, I had an LCD shield working in minutes without much effort.
  • The normal Arduino libraries will not always work, the LCD shield library worked with no problem though.

Wemos D1 review Summary.

Well, you can’t beat the price nor the ease of use. Microcontroller + Wifi for the same price as an Uno. I will always use my beloved Arduino Uno because of the amount of libraries and code available on the Internet but…. as soon as I need to use WiFi in my projects I will go for the Wemos D1 without a second thought. We also have a much smaller WiFI board for production here:

You can get yours from us here  https://www.botshop.co.za/product/esp-12e-wemos-d1-wifi-board/