How to build a working prototype — IoT plant watering system

Berislav Grgičak
ENTG AGENCY

--

If you have an idea that you think can make a potentially great product your first step is to proof your concept and this is mostly done by prototyping. Sometimes clients think that prototypes are a waste of money but this is wrong. Prototyping will solve a lot of your initial questions, give you a value for investors and it doesn’t need to be expensive if done correctly.

Prototyping is also phase 4 in one of our favourite approaches to innovation — design thinking. Simply put, prototyping allows you to know very quickly and quite inexpensively what is the best possible solution for the problem your idea is trying to solve.

When working in a creative tech company, proofing concepts and building prototypes is a daily routine. It is important to be fast while doing this to save time and money.

We use rapid prototyping techniques that include 3D printing, cloud computing and agile development in our process.

This article is a hands on introduction to rapid prototyping and to show you how it’s done in practice, we are going to build an actual IoT plant.

What is rapid prototyping?

Rapid prototyping is a set of techniques initially used for circuit board fabrication and in mechanical engineering. This techniques allows product developers to test their concepts without building the final product which makes the prototyping process faster and cheaper.

Hardware prototyping uses CAD (Computer aided design) and CAM (Computer aided manufacturing) because it allows engineers to directly produce their drawings using CNC machines and 3D printers.

Rapid application development is based on agile development where the product phases are much shorter than in classic development processes like waterfall. The idea is that each phase focuses on a specific set of functionalities and after the phase is done all of the planned functions are usable. To be able to rapidly develop complex functions developers often use predone cloud solutions and build them from scratch in later phases after the prototype is done.

Good products need great ideas

So how do we start with a rapid prototype process? We take an idea, write down the minimal requirements and put them in a order of priority.

Because this is a hands on introduction we will do everything step by step.

First — the idea:

It happened to all of us, you had a lot of work and you just forgot to water your plants day after day or you water them too often just because you love them. After some time you realized that your plants look a bit different and then you realize that you did something wrong. To prevent this from happening ever again you could use a system that informs you when your plant needs water.

Stop your plants from drying out by letting them send you notifications when they need water.

To implement our idea we need two components soil humidity measurement system and phone notifications. Now we can break this up into functionalities:

  • Electronics development
  • Humidity sensor
  • Power source
  • Software development
  • Sensor to server connection
  • Server to phone connection
  • Phone notification app

This would be enough for a basic proof of concept but if we want to have a prototype that can show the full potential to a future client or partner, we need to wrap it up in a case and make it look as close as possible to the real product.

Now that we have the idea and a list of functionalities, we can start building our prototype.

How to pick electronic components for a prototype

The first step in this case will be electronics development because we can’t write any software if we don’t have the hardware to run it on. In most cases, when building prototypes there is no need to build the electronics from scratch. A better approach is to use existing OpenSource hardware and just connect the parts needed.

For our prototype we need two basic functionalities; first being soil humidity measurement and the other is a processing unit that will send the data to the server. In most cases the best solution for this types of projects is a Arduino which is a OpenSource microcontroller popular in the electronics community. The best thing about using Arduino is a large community and a huge number of shields. Shields are pre done components that can easily be connected to your Arduino and add functionalities like wifi connectivity, bluetooth, stepper motor controllers and many other fun things.

After a bit of research we decided to use a Arduino like board with a built-in wifi shield called NodeMCU and a arduino soil humidity shield. With this two components we have all the hardware we need. So we can connect everything on a breadboard all we need is to connect the shield to the boards power supply, ground and a analog pin for reading the data.

Measure soil humidity with Arduino

Now we have all the electronics in place we can connect our NodeMCU to the PC start up and Arduino IDE. Since the version 1.6.4 of the IDE boards manager has been introduced and allows us to simply add new boards and code examples.

After opening a new project you get two parts (functions) the first is setup and it runs on the board start. Setup is used to initialize all the required data and set the pin state before the board starts to work continuously. The other one is loop, it is the main part of the code and it starts after setup, it runs continuously and triggers the rest of the code.

All we need to do now is include our ESP library to be able to send date to the internet, on setup start the WiFi connection, inside the loop read the analog pin value and if the value is low ping the server to sent a notification to the user.

#include <ESP8266WiFi.h>//WiFi dataconst char* ssid = “WIFI_NETWORK_NAME”;const char* password = “WIFI_NETWORK_PASSWORD”;//IFTTT dataconst char *host = “maker.ifttt.com”;const char *privateKey = “YOUR_MAKER_PRIVATE_KEY”;//Analog pin toreadint aReadPin = 0;//Global valuesint lastReadValue = 0;boolean alertSent = false;void setup(){//Start serial monitorSerial.begin(115200);//Connect to WiFiWiFi.mode(WIFI_STA);WiFi.begin(ssid, password);while (WiFi.status() != WL_CONNECTED) {delay(200);}Serial.println(“Connected”);}void loop(){//get sensor valuelastReadValue = analogRead(aReadPin);//if humidity is low and the alert wasn’t already sentif(lastReadValue < 200 && !alertSent){//Connect to hostWiFiClient client;if (!client.connect(host, 80)) {return;}//Send data to IFTTTclient.print(“GET /trigger/need_water/with/key/” +String(privateKey) +“ HTTP/1.1\r\n” +“Host: “ + host + “\r\n” +“Body: { value1: 33 } \r\n” +“Connection: close\r\n\r\n”);//Wait for the responsewhile(client.connected()){if(client.available()){//Print response to serial monitorSerial.println(client.readStringUntil(‘\r’));}else {//If no response wati for 50 millisecondsdelay(50);};}//Close connection to hostclient.stop();//Set the alert as sentalertSent = true;}//If humidity is high set the alert as not sentelse if(lastReadValue > 200 && alertSent){alertSent = false;}//Delay the next call of the loopdelay(1000);}

IFTTT maker connection using ESP8266

The hardware programming is now done and the next step is to send push notifications to the user. Because this is a prototype we can make things simple and use a outside service to send the notifications and skip building mobile apps and push notification servers.

For this part we will use my favorite automation tool IFTTT. This service allows us to connect a large number of apps and devices to interact on a principle if this happens than do that.

To make our code work we need three things. We need to register a new applet in the IFTTT interface. This applet needs to use Maker webhooks that listen for our event and then send a push notification to your phone. To be able to receive push notifications on your phone you need to install the IFTTT mobile app. And now the last thing is to go back to Arduino IDE and set ping url to be the maker webhook server.

All functionalities are now done, you can test everything out by putting the measurement part of the sensor in a cup of water or wet dirt. After you take the sensor out the event will be triggered and you will receive a notification on your phone.

3D printing a prototype case

Now that we have tested everything out and made sure it works, we can make everything a bit more appealing by building a case. A good case needs to look nice but also protect the inside parts from the outside environment and in our case allow access to the batteries.

We are going to build our case on a 3D printer so first we need to decide how will the parts be arranged and then we can start to sketch the case. The sketch needs to show the dimensions, solve the problem of fitting the parts in and how they are going to be attached to the case. After the sketch is done, drawing the 3D model is simple, we just need to copy the sketch in our 3D modeling tool using the exact dimensions and extrude the 2D shapes into 3D objects.

When the 3D model is done we can heat up our printer and start making the case and when everything is complete we just need to assemble all of the parts into the case and close it.

Why is rapid prototyping great?

One of the main reasons why you should build a prototype is to get a better understanding of the future product and business potential of the same. While building this you can get a lot of ideas for improvements and new features. Also it is now more obvious what will be the main difficulties and how to solve them.

Design thinking enables us to structure our innovation process based on insights. Rapid prototyping enables us to truly test those insights and gain more which helps improve the end product.

Through this tutorial we have shown how to take a simple idea and convert it into a working prototype that you can show to clients, use it to write a business plan and get production costs easier.

This article originally appeared in ENTG company blog.

--

--