Documentation

Welcome to Smart-hub.cloud

A very lightweight IoT solution for your life. You have just connected the thing and set it up without coding. A best way to make home automation and smart agriculture system

Overview

Overview

Raspberry pi, relay modules, sensor and camera module are connected together. data from sensor is read by raspberry and then send to server smart-hub.cloud.

User login to smart-hub.cloud using credential and then they can monitor sensor data and send command ON/OFF to electronic device like pump, lamd, valve,etc via relay module. Also, user can schedule time to ON/OFF delay via calendar interface.

Getting Started

INSTALLING OPERATING SYSTEM IMAGES FOR RASPBERRY PI 3

You will need another computer with an SD card reader to install the image. We recommend most users download NOOBS, which is designed to be very easy to use.

To begin, make sure you have all of the required items from the last step. Then, follow the steps on the Raspberry Pi website on installing Raspbian on your Micro sd card, found here.

Before start setting up a new smart hub, it’ll be good to have a look on Hardware Requirement.

Start by connecting the Pi to the cobbler, using the ribbon cable, and then plug the cobbler into the breadboard. Make sure each row of pins on the cobbler sit either side of the gap that runs down the middle of the breadboard.

t_plus

Hardware Requirement

Here are the components which we will be using through this guide to make a smart hub.

No Name Qty
1 Raspberry pi ( version 3 recommended) 1
2 T plus cobbler and breakout board extension GPIO 1
3 Relay module 4 channel 2
4 DHT22 Digital Temperature and Humidity Sensor AM2302 Module+PCB 1
5 YL69 Soil Moiture sensor 1
6 Liquid PH Value Detection detect Sensor Module Monitoring Control For arduino BNC Electrode Probe 1
7 ADS1015 12-Bit ADC - 4 Channel with Programmable Gain Amplifier 1

Relay Module

Firstly we will connect the raspberry and the 4 array module. Let use breakout board extension GPIO to make it easier. it depends on your needed to use 1 or 2 relay. you can control 4 equipment if you just use 1 relay and control 8 equipments if you use 2 relays.

Wiring for only 1 relay

1relay4module

PI GPIO -------Relay module

Pin 4 ---------VCC

Pin 6 ---------GND

Pin 29 ----------IN4

Pin 31 ---------IN3

Pin 33 ---------IN2

Pin 35 ---------IN1

Wiring for only 2 relays

2relay4module

Relay 1

PI GPIO -------Relay module

Pin 4 ---------VCC

Pin 6 ---------GND

Pin 29 ----------IN4

Pin 31 ---------IN3

Pin 33 ---------IN2

Pin 35 ---------IN1

Relay 2

PI GPIO -------Relay module

Pin 4 ---------VCC

Pin 6 ---------GND

Pin 37 ---------IN4

Pin 36 ---------IN3

Pin 38 ---------IN2

Pin 40 ---------IN1

Temperature/Humidity

We strongly recommend using DHT22/AM2302 digital sensor. It is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use

Wiring DHT22/AM2302

DHT22/AM2302

PI GPIO -------DHT22/AM2303

Pin 4 ---------VCC(+)

Pin 6 ---------GND(-)

Pin 7 ---------OUT

Soil Moiture

YL-69 Soil Hygrometer Humidity & Soil Moisture Detection Sensor is a simple sensor that can be used to detect soil moisture/ relative humidity within the soil The module is able to detect when the soil is too dry or wet. Great for use with automatic plant watering systems.

Here is how to use the YL-39 (logic) + YL-69 (probe) pair that form the soil humidity sensor. The YL-39 module has 4 pins:

  • VCC: 3.3-5V

  • GND

  • A0 : analog output that can be easily read by ADS1015 board.

  • D0 : digital pin that goes LOW or HIGH depending on a preset value

The Raspberry Pi itself doesn’t actually have an analogue GPIO pin, so we will need to use an analogue to digital converter or ADC for short. we recommend using ADS1015 12-BIT ADC - 4 CHANNEL WITH PROGRAMMABLE GAIN AMPLIFIER

Wiring YL-69 & YL-39

YL69

Raspberry pi 3 to ADS1015

Pin 1 ---------VCC(+)

Pin 3 ---------SDA

Pin 5 ---------SCL

Pin 9 ---------GND(-)

YL-39 to ADS1015

Pin A0 ---------A0

Note that pH sensor also use ADS1015. see below the guide.

pH Sensor

If you worked with PH metering before you will know that PH values range from 0-14. Where PH 0 Will be very acidic, PH 7 will be neutral and PH 14 very alkaline. Water is near a PH 7 and this is usually around here that we will need to monitor PH of many things. A swimming pool, for example, should be slightly alkaline at 7.2, hydroponics systems around 6 (for optimum plant nutrition takeup) and aquaponics around 6.8.

We recommend using PH probe module BNC connector PH PH Probe Sensor Pinout

TO – Temperature output connest to A2 of ADS1015
DO – 3.3V Output (from ph limit pot)
PO – PH analog output connects to A1 of ADS1015
Gnd – Gnd for PH probe (can come from the same Gnd)
Gnd  – Gnd for power supply 
VCC – 5V DC power supply
POT 1 – Analog reading offset (Nearest to BNC connector)
POT 2 – PH limit setting

If your pH data display incorrect, you have to calibrate the probe.

This board have the ability to supply a voltage output to the analogue board that will represent a PH value just like any other sensor that will connect to an analog pin. Ideally, we want a PH 0 represent 0v and a PH of 14 to represent 5V.

BUT there is a catch……, this board by default have PH 7 set to 0V (or near it, it differs from one PH probe to another, that is why we have to calibrate the probe as you will see later on), This means that the voltage will go into the minuses when reading acidic PH values and that cannot be read by the analog ADS1015 port. The offset pot is used to change this so that a PH 7 will read the expected 2.5V to the ADS1015 analog pin, the analog pin can read voltages between 0V and 5V hence the 2.5V that is halfway between 0V and 5V as a PH 7 is halfway between PH 0 and PH 14, You will need to turn the offset potentiometer to get the right offset, The offset pot is the blue pot nearest to the BNC connector.

To set the offset is easy. First, you need to disconnect the probe from the circuit and short-circuit the inside of the BNC connector with the outside to simulate a neutral PH (PH7). I took a piece of wire, strip both sides, wrap the one side around the outside of the BNC connector and push the other side into the BNC hole. This short-circuit represents about a neutral PH reading of 7.

You will need to turn the offset potentiometer to get the right offset, The offset pot is the blue pot nearest to the BNC connector.

To set the offset is easy. First, you need to disconnect the probe from the circuit and short-circuit the inside of the BNC connector with the outside to simulate a neutral PH (PH7). I took a piece of wire, strip both sides, wrap the one side around the outside of the BNC connector and push the other side into the BNC hole. This short-circuit represents about a neutral PH reading of 7.

PH

If you have a multimeter handy you can measure the value of the PO pin and adjust the offset potentiometer until PO measures 2.5V.

Thank you botshop

Camera

In this tutorial we will be using a package called motion if you want to learn more about it you can check out their website at Motion. Since the latest version of Raspbian is missing dependencies that motion requires for it work correctly we will need to install a different precompiled version. The package maintainer (Calin Crisan) of motioneye provides a package that has everything we need and it works just fine with the Raspberry Pi. Pi camera

The first thing you'll need to do to test that everything works fine is to see if you can view the default web page. Since your Raspberry Pi will have a unique network address, you can just type it in the web browser.

For example, if the Raspberry Pi is connected to a router with the IP of 192.168.0.1, your device could have an IP like 192.168.0.106. Thus, the URL would also be http://192.168.0.106:8081. If you have success returning the default web page, you will see a message stating that everything is working properly. You might need to know local IP of raspberry via terminal command or SSH remote access

ifconfig

NAT port your router to public access camera.

If you dont know why we need to forward port. let take a couple of minutes to read this article

Raspberry Pi port forwarding is a method where we are able to allow external access to the Pi camera. In order to do this, we will need to change some settings on the router.

All routers are different but I will try and make this as generic as possible however there could still be a lot of differences between these instructions and your router. The router I am using for this tutorial is the TP Link AC1750 wireless dual band gigabit router.

  1. On a computer that is connected to the local network, connect to the router admin page via a web browser.

A router IP typically is 192.168.1.1 or 192.168.1.254

  1. Enter the username and password for the router. By default this is typically admin & admin.

  2. In the router admin page head to forwarding->virtual server.

  3. On this page enter the following

    Service Port: This is the external port.
    IP Address: This is the IP of the Pi.
    Internal Port: Set this to Pi’s application port. (A motion runs on port 8081 by default)
    Protocol: Set this to ALL unless specified.
    Status: Set this to enabled.
    

raspberry-pi-port-forwarding

  1. These settings will route traffic destined for the port specified to the port on the Raspberry Pi.

  2. You should now be able to connect to the camera on the Raspberry Pi outside your network. The best way to check if you have port forwarded correctly would be to connect or go somewhere outside your local network (A VPN could achieve this).

Application for Raspberry Pi

Raspberry pi needs installed Smart-hub controller. Smart-hub controller is a GUI software you just need download from here and double click to run it.

Smart-hub-application

Download here

After application loaded. you need login to smart-hub cloud service using credential you have register.

Registration account

This overview of how to register for an account for the Smart-hub administration site and also Smart-hub controller application for raspberry pi. It will help you understand the process of setting up your account.

Go to the Administrator site and click Create an account.

Enter the display name that you wish to use (50 characters or fewer).

Enter the email that you wish to use.we'll use the email address you provide in your contact info to send email communications related to your account such as activation email, reset password link.

Enter the password and confirmation password(6 characters or longer).

Tick on the agree terms and conditions checkbox. Smart-hub-registration

After you've signed up, your account will go through the verification process. For activation account, ensure you provided a valid email, an activation link will be send automatically to your mailbox. you have to active your account by click open activation link from email.

Administration Section

Smart-hub-administrator-sector

Schedule a task ON/OFF for Relay

Smart-hub-administrator-sector