UCL - IIoT - Farmers Market

About: Studying at UCL in Odense, Denmark - The group consists of the following three members: Rasmus - rasm247g@edu.eal.dk Julian - juli087z@edu.eal.dk Jonas - jona1086@edu.eal.dk

The Farmersmarket wallet can be used at fairs, farmers markets or other gatherings where goods are sold.

The Farmersmarket wallet is a coin counting machine, made to make it possible to quickly see the total contents of a box holding coins. The farmersmarket wallet will also upload the total to a server programmed via Node-red.

It is made by three students of University College Lillebælt in Denmark. Since our previous project, The coin sorter, we’ve learn many new things which we’ll be incorporating into the build. We’ve chosen to forego the sorting of the coins and instead make the machine count them, depositing them in a communial coin box.

The wallet consists of five slides or slots, one for each type of coin. When a coin is put into the proper slot, it will fall down passing a reflector, which sends a HIGH signal to the arduino. We will use the signal to add the coins value to the counted total, display it on the external display and send the new total to a server. Once the server receives the total, it will update a UI found online showing the new total.

A box with five coin slots leading to five individual, internal slides, one for each type of coin: 1kr, 2kr, 5kr, 10kr, 20kr

A LCD display showing the total cash diposited on top of the box.

The top of the box is secured with hatches. Lifting the top will take out the arduino housing along with the top containing the LCD, coin slots, reflectors ect., leaving only the box where the coin are deposited into.

Components and materials
- Tools and equitment for making a box (could be cardboard or wood)

- Arduino Mega 2560

- 30 jumperwires

- 5 x LDR "Light sensor"

- 5 x 220 ohm resistors

- 5 x 10k ohm resistors

- 5 x White LED’s

- LCD 16x02 Module

- Coins

Code in Arduino

As mentioned earlier this project originates from an earlier project we made approximately eight months ago (https://www.instructables.com/id/Coin-Sorting-Machine/). Because of this we are able to reuse a large part of the code in arduino, though there are some smaller changes to it. As you'll see the code is fairly simple, which any person with a bit of experience with Arduino should be able to understand.

Node-RED is the tool we will use to get the data from the arduino and to your computer, and further on to the internet, if that is in your interest. Another important reason to use Node-RED, is the ability to present data from Arduino in a way that is easy to understand, for people who do not have any programming/coding experience with Arduino and Node-RED.

Using Wampserver we can store our values from Arduino in a database. With Wampserver its possible to create and alternate your own database as you like, using phpMyAdmin to administrate MySQL. In our case we have six values we need to store (one for each kind of coin and one for the result), and therefore we have created six columns in which each value can be stored.

Step 1: How Does It Work?

In a more detailed manor, we will now explain how our system works.

As you'll see at the flowchart the first thing that sets of the proces, is when a coin is put into its correct slot.

The LDR light sensor will notice the reduced amount of light, when the coin passes by the sensor, which will trigger the Arduino program to increment the variable "Antal"(Number of) with one, as there is now one coin in the machine. At the same time the value of the coin is added to the variable "result". "result" will be displayed on the LCD with its new value.

The new values of "Antal" and "result" are sent to Node-RED, in which the dashboard will update itself with these values. At last Node-RED sends on the values to our database.

And repeat.

Step 2: Making a Box

This time we have been using Illustrator to design our box. With a laser cutter we have been to precisely craft this box, and the features that are required for our project. In the end its up to you, to decide how to make the perfect box for your project.

Step 3: Adding Arduino

It's time to implement the Arduino into the box. This can quite difficult, as the sensor can behave unpredictable. (New) In this step we have changed the sensor we are using, because of the before mentioned unreliability of these sensors (tcrt 5000). Instead we have chosen a more simple LDR-sensor (Light dependent resistor). The output from this sensor is an analog value, that changes depending on the amount of light reaching the sensor itself.

Step 4: Arduino Code

In this step we are putting our focus on the software. The Arduino code looks like this:

const int sensorPin1 = 3; //TCRT-5000 sensor which is connected to pin nr. 2
int sensorState1 = 0; //Contains the value of the sensor (High/low)

int Antal10 = 0; //Variable that stores the amount of coins that have been put into the machine int

Resultat = 0; //Variable that stores the combined value of all coins put into the machine

void setup() { Serial.begin(9600); }

void loop() { int sensorState1 = analogRead(sensorPin1); //Reads the state of the sensor

if (540 < sensorState1 < 620) { //When the sensors output value is between 540 and 620

Antal10 += 10; // - there is a coin passing the sensor, which blocks some light

resultat += 10; // - and the sensor will read a lower level of light }


Serial.print(","); //Seperates the variables with a comma, which is necessary when reading the values of variables in Node-RED

Serial.println(Antal10); // - and also needed when these values are to be stored in the database

delay(100); }

This code is written for one sensor only, to make easier to read.

Complete code:

Step 5: Node-RED

When the Arduino code is running as it should be, you can start programming Node-RED, which is going to act as the middlelink between Arduino and the database and as a visual display of how the machine is performing. The programming of Node-RED consists of using nodes with different functions, and putting in the right parametres for these nodes to work properly.

When our data arrives in Node-RED, it is sent to two different split functions. One of these functiosn sents the now splittet data on to the database. The other one sents the different datavalues on to each of their dashboard nodes, which now should be visable on the dashboard.

As mentioned ealier we have six values that to be treated. With the dashboard abilities of Node-Red we are able to display these values, as you'll see in the image to the right at the top of Step 3.

Node-RED code:

Step 6: Database

Now we are going use a database to store the values. With Wampserver its possible to use phpMyAdmin to administrate MySQL and making your own database, using a local server to fit for your specefic needs.

First when making a database (farmers_market) from scratch you need to make a table (mont_tabel), in which you store you're values. Depending on how much data you have, and how you need to order it, you can make as many tables as you need. Because we need to store six different values, and we therefore needed six coloumns, one for each value, in our table. In the picture above you are able to see our database.

When our data arrives in Node-RED, it is splittet by a split function, and the now data is sent on to the database.

Step 7: Evaluation

First of we want to mention that making the box out of wood instead of cardboard, makes the whole physical setup much more reliable, and we therefore recommend doing so.

Changing the sensors from a TCRT-5000 and to a simple LDR light sensor gave alot more stability, as to sensors ability to quickly read when a coin goes by it. When working with a TCRT-5000 there are many factors that need to be taken into account, in order for the sensor to work as you would like.

Hooking the system on to a database, and being able to visually present your data in a way, that any person without any preknown knowledge of this project, is able to understand what is going on, seems to give the project more value.



    • Pocket Sized Contest

      Pocket Sized Contest
    • Remix Contest

      Remix Contest
    • Paper Contest

      Paper Contest