Things used in this project

Hardware components:
Iotopia box rs
AllThingsTalk IOTOPIA Rapid Development kit
×1
DFRobot turbidity sensor
×1
Water pump
×1
Vacuum/Air pump
×1
Non-contact liquid level sensor
×1
SeeedStudio Groove relay
×1
Ardgen 101
Arduino 101 & Genuino 101
×1
Adafruit Motor shield v2.3
×1
SeeedStudio Grove base shield
×1
Air blower
×1
Adafruit Stepper motor
×1
11842 01a
SparkFun LilyPad Rainbow LED (strip of 7 colors)
×1
10167 01
DHT22 Temperature Sensor
×1
11026 02
Jumper wires (generic)
×1
Schneider Resi9 C4
×1
Schneider Resi9 C10
×1
Schneider Resi9 40A 300mA
×1
Software apps and online services:
Wzfnsjw4zdiosfhfhejx
AllThingsTalk Maker
Ide web
Arduino IDE
Solid Edge ST8
Hand tools and fabrication machines:
Lasercutter
Laser cutter (generic)
3drag
3D Printer (generic)
Welder

Custom parts and enclosures

Solid Edge ST8 Fish-O-Matic
Solid edge drawings of our whole project, excluded the electronics.
Scn1 ivkfuygbmz
Solid Edge ST8 Fish-O-Matic
Solid edge drawings of our whole project, excluded the electronics.
Scn3 wi8rfgiav3
Solid Edge ST8 Fish-O-Matic
Closer look at our feeding system.
Scn4 5to8d4movr
Solid Edge ST8 Fish-O-Matic
Exploded vieuw of our greenhouse.
Deel2 gqkghcnrpy
Solid Edge ST8 Fish-O-Matic
Exploded vieuw of our bottom part.
Deel1 skjw3mu9x6
Laser cutter parts
The roofpanel of our greenhouse.
dakplaaat_0q5QmUsQa2.par
Laser cutter parts
The side panel of our greenhouse.
gevelplaat_aFFV51C9DK.par
Laser cutter parts
The flooring of our settling tube.
onderkant_bezinkingsreservoir_KFUhS6bvzF.par
Laser cutter parts
Bottom panel of our garden bin.
onderplaat_JTHtgsi8V2.par
Laser cutter parts
These rings make sure that our draining system is kept in place.
rondel_drainage_vfMH3Jy2bS.par
Laser cutter parts
Another side panel of our greenhouse.
serre_zijplaat_prRp0UnZkX.par
Laser cutter parts
The side panel of our garden bin.
zijplaat_1_Set2IY8TEa.par
Laser cutter parts
The side panel of our garden bin where the draining system is attached to.
zijplaat_2_met_gaten_RMm80EVOMt.par
Laser cutter parts
Another side panel of our garden bin.
zijplaat_2_D6PG7tpRc9.par
3D Printing parts
This is our costum container for our feeding system.
voedertrommel_1_0_fpeDHkPA19.par
3D Printing parts
This is the cover of our feeding system.
deksel_voedertrommel_FUQfOpMaXO.par
3D Printing parts
This is one of our costum designed cable holders that fits onto our L-profiles.
houdertje_passend_op_l-profiel_3_ARfwr2BvoO.par
3D Printing parts
This is one of our costum designed cable holders that fits onto our L-profiles.
houdertje_passend_op_l-profiel_4_0aHE6KDobw.par
3D Printing parts
This is one of our costum designed cable holders that fits onto our L-profiles.
houdertje_passend_op_l-profiel_XFVNfY4Tc5.par
3D Printing parts
This part keeps our draining pipes closed at the end and it holds them up at their correct height.
houdertje_voor_drainagebuisje_met_gesloten_achterkant_EvAysBqbLa.par

Schematics

Electrical plan
Here you can see the electrical plan of the Fish-O-Matic.
Elektrisch schema f2kc45oryq
Electrical plan
This is the fritzing file of the electrical plan.
elektrisch_schema_vdRnvY2z5d.fzz

Code

Fish-O-Matic programArduino
The full program that runs our Fish-O-Matic.
// Gebruikte pinnen:
//  2,3,5 voor Fona.
//  4 voor DHT.
//  6 voor de capcitieve niveausensor.
//  7 voor de troebelheissensor.
//  8 voor de ventilator.
//  9 voor de LED-Strip.
//  10,11,12,13 voor de MotorShield waarop de stappenmotor is aangesloten.
//  A4 en A5 worden gebruikt voor de Dompelpomp en de Vacuumpomp

// Info:
// What pins are/are not used on the motor shield?
//  The shield uses the SDA and SCL i2c pins to control DC and stepper motors.
//  On the Arduino UNO these are also known as A4 and A5.
//  On the Mega these are also known as Digital 20 and 21.
//  On the Leonardo these are also known as digital 2 and 3.
// Do not use those pins on those Arduinos with this shield with anything other than an i2c sensor/driver.



//Libraries van de FONA module
#include <SoftwareSerial.h>
#include "ATT_IOT_FONA.h"
#include "ATT_MQTT.h"

#include "ATT_IOT_GPRS.h"
#include <SPI.h>                                              // required to have support for signed/unsigned long type.

//Constanten voor de FONA module
#define deviceId "your_device_id"
#define clientId "your_client_id"
#define clientKey "your_client_key"

#define FONA_APN       "web.pro.be"
#define FONA_USERNAME  ""
#define FONA_PASSWORD  ""

#define FONA_RX 2                                             // Pin 2 is voor de RX
#define FONA_TX 3                                             // Pin 3 is voor de TX
#define FONA_RST 5                                            // Pin 5 is voor de RST
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);

ATTDevice Device(deviceId, clientId, clientKey);              // create the object that provides the connection to the cloud to manager the device.
#define httpServer "api.AllThingsTalk.io"                     // HTTP API Server host                  
#define mqttServer httpServer                                 // MQTT Server Address 


//Libraries voor de DHT serretemperatuur en serrevochtigheid
#include <dht.h>;  //Libraries voor serretemperatuursensor meer info: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html


//Constanten voor DHT vochtigheids en temperatuursensor
#define DHTPIN 4                                              // DHT is aangesloten op pin 4 
#define DHTTYPE DHT22                                         // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);                                     // Initialize DHT sensor for normal 16mhz Arduino


//Libraries voor de Motorshield
#include <Wire.h>                                             // Wire
#include <Adafruit_MotorShield.h>                             // Om de motoren aan te sturen
#include "utility/Adafruit_MS_PWMServoDriver.h"               // Om de stappenmotor aan te sturen

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); 

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *DompPomp = AFMS.getMotor(1);
// You can also make another motor on port M2
Adafruit_DCMotor *VacPomp = AFMS.getMotor(2);


//Variabelen

//Asset nummers toewijzen voor AllThingsTalk
int AssNrVocht = 1;                                           // Asset Number Vochtigheid
int AssNrTemp  = 2;                                           // Asset Number Temperatuur
int AssNrNiv   = 3;                                           // Asset Number Niveau schakelaar
int AssNrHand  = 4;                                           // Asset Number Hand/Auto schakelaar
int AssNrVent  = 5;                                           // Asset Number Ventilator
int AssNrLed   = 6;                                           // Asset Number LED-Strip
int AssNrDomp  = 7;                                           // Asset Number Dompelpomp
int AssNrVac   = 8;                                           // Asset Number Vacuumpomp
int AssNrFeed  = 9;                                           // Asset Number Voedertrommel
//Variabelen voor communicaite met AllThingsTalk
float Vocht;                                                  // AI Stores humidity value
float Temp;                                                   // AI Stores temperature value
bool  Niv;                                                    // DI Niveau sensor
bool  Hand;                                                   // DI Systeembit Hand
bool  Vent;                                                   // DO Ventilator
bool  Led;                                                    // DO LED-Strip
bool  Domp;                                                   // DO Dompelpomp
bool  DmyDomp                                                 // Dummy Dompelpomp
bool  Vac;                                                    // DO Vacuum pomp
bool  DmyVac;                                                 // Dummy Vacuum pomp
bool  Feed;                                                   // DO Voedertrommel


//Pin nummers toewijzen (2,3,5 voor Fona. 4 voor DHT. 10,11,12,13 voor stappenmotor)
//Inputs
int PinNiv  =  6;                                             // Pin Number Niveau Sensor
int PinTurb =  7;                                             // Pin Number Troebelheid Sensor
//Outputs
int PinVent =  8;                                             // Pin Number Ventilator
int PinLed  =  9;                                             // Pin Number LED-Strip
int PinSM0  = 10;                                             // Pin Number Stappen Motor 0
int PinSM1  = 11;                                             // Pin Number Stappen Motor 1
int PinSM2  = 12;                                             // Pin Number Stappen Motor 2
int PinSM3  = 13;                                             // Pin Number Stappen Motor 3

//Variabelen voor Tijdsfuncties
unsigned long CurTime = 0;                                    // Current Time
unsigned long LastTime = 0;                                   // Last saved Time
int Uur = 0;                                                  // Time of day: Uur
int Min = 0;                                                  // Time of day: Min
int Sec = 0;                                                  // Time of day: Sec

//Setpoints LED
int LedOnTime = 20;                                           // Set time Led (uur)
int LedOffTime = 8;                                           // Reset time Led (uur)

//Setpoints DHT
int VochtMax = 500;                                             // Te vochtig => Set Vent
int VochtMin = 450;                                             // Vocht ok => Reset Vent
int TempMax = 22;                                             // Te warm => Set Vent
int TempMin = 21;                                             // Warmte ok => Reset Vent

//Setpoints Voedertrommel
bool Feeding = false;                                         // Voedertrommel is bezig met voederen
int FeedTime = 8;                                             // Tijdstip voederen (uur)
int FeedRounds = 3;                                           // Aantal toeren per voederbeurt
int FeedTimeRound = 4200;                                     // Tijdsduur voederen (ms) 4200ms = 1 toer
unsigned long FeedEndTime;                                    // Tijdstip Stop voederen (ms)

unsigned long NextStep;                                       // Tijdstip voor de volgende stap
int StepTime = 1;                                             // Tijdsduur voor 1 stap (ms)
int Step = 0;                                                 // Stap nummer (0 t.e.m. 7)
int StepDir = 1;                                              // Draairichting (1 is default)

//Nodig voor de FONA module
void callback(const char* topic, const char* payload, unsigned int length);
// Setup the FONA MQTT class by passing in the FONA class and MQTT server and login details.


void setup()
{
  fonaSS.begin(19200);  								                      // Openen van de Seriële Communicatie met de Fona module aan 19200 baud
  Serial.begin(57600);                                        // Openen van een virtuele Seriële Communicatie voor het debuggen aan 57600 baud
  
	while(!Serial && millis() < 2000);                   		    // Make sure you see all output on the monitor.
	{                                                           // After 2 sec, it will skip this step, so that the board can also work without being connected to a PC
    while (! Device.InitGPRS(fonaSS, FONA_RST, F(FONA_APN), F(FONA_USERNAME), F(FONA_PASSWORD)))
    {
      Serial.println("Retrying FONA");
    }
      
    Serial.println(F("Connected to Cellular!"));
    delay(2000);                                        		  // wait a few seconds to stabilize connection
  
    while(!Device.Connect(httpServer))            				    // connect the device with the IOT platform.
    {
      Serial.println("retrying");
    }
    //Alle devices voor AllThingsTalk declareren
//  Device.AddAsset(int AssetNr, string Name,         string Discription,                      bool isActuator, string Type);
    Device.AddAsset(AssNrVocht, "Vochtigheid serre", "Vochtigheid in de serre",                          false, "number");
    Device.AddAsset(AssNrTemp,  "Temperatuur serre", "Temperatuur in de serre",                          false, "number");
    Device.AddAsset(AssNrNiv,   "Niveausensor",      "Waterniveau in het aquarium",                      false, "bool");
    Device.AddAsset(AssNrHand,  "Hand / Auto",       "Schakelaar Hand / Auto",                           true,  "bool");
    Device.AddAsset(AssNrVent,  "Ventilator",        "Schakelaar en Terugmelding werking ventilator",    true,  "bool");
    Device.AddAsset(AssNrLed,   "LED-Strip",         "Schakelaar en Terugmelding werking LED-Strip",     true,  "bool");
    Device.AddAsset(AssNrDomp,  "Dompelpomp",        "Schakelaar en Terugmelding werking Dompelpomp",    true,  "bool");
    Device.AddAsset(AssNrVac,   "Vacuumpomp",        "Schakelaar en Terugmelding werking Vacuumpomp",    true,  "bool");
    Device.AddAsset(AssNrFeed,  "Voedertrommel",     "Schakelaar en Terugmelding werking Voedertrommel", true,  "bool");
    
    while(!Device.Subscribe(callback, mqttServer, 1883))      // make certain that we can receive message from the iot platform (activate mqtt)
    {
      Serial.println("retrying");
    }
  }

  //Voor de DHT sensor
  dht.begin();


  //Voor MotorSield
  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // or with a different frequency, say 1KHz
  
  // Set the speed to start, from 0 (off) to 255 (max speed)
  DompPomp->setSpeed(155);
//  DompPomp->run(FORWARD);                                     // Dat mag hier wss nog niet staan omdat dit reeds de pomp aan zet
  VacPomp->setSpeed(250);
//  VacPomp->run(FORWARD);                                      // Dat mag hier wss nog niet staan omdat dit reeds de pomp aan zet

}


void loop()
{
  //Uurwerk
  CurTime = millis();
  if (CurTime < 900) {LastTime = 0;}
  if (CurTime >= (LastTime + 1000)) {
    LastTime = CurTime;
    Sec = Sec + 1;
    if (Sec >= 60) {
      Min = Min + 1; Sec = 0;
      Serial.println("Klok: " + Uur + ":" + Min);
      if (Min >= 60) {
        Uur = Uur + 1; Min = 0;
        if (Uur >= 24) {Uur = 0;}
      }
    }
  }

  //Ventilator
  if (!Hand) {                                                // Als het systeem in AUTO staat
    if ((Temp > TempMax) or  (Hum > VochtMax))                // Als het warmer is dan 22 graden OR vochtiger dan 500 draait de ventilator
    {
      if (!Vent){Serial.println("Ventilator: Automatisch aan");}
      digitalWrite(PinVent, HIGH);                            // Ventilator aanzetten
      Vent = true;                                            // Terugmelding voor AllThingsTalk
        
  }
    if ((Temp < TempMin) and (Hum < VochtMin))                // Als het kouder is dan 21 graden AND droger dan 450 stop de ventilator
    {
      if (Vent){Serial.println("Ventilator: Automatisch uit");}
      digitalWrite(PinVent, LOW);                             // Ventilator afzetten
      Vent = false;                                           // Terugmelding voor AllThingsTalk
    }
  }
  else {                                                      // Als het systeem in HAND staat
    if (digitalRead(PinVent) !=  Vent)
    {
      if (Vent){Serial.println("Ventilator: Handmatig aan"); digitalWrite(PinVent, HIGH);}
      if (!Vent){Serial.println("Ventilator: Handmatig uit"); digitalWrite(PinVent, LOW);}
    }
  }

  //LedStrip
  if (!Hand) {                                                // Als het systeem in automatisch staat
    if (Uur == LedOnTime  and Min == 0)                       // Om 8u 's avonds wordt de LED-Strip ingeschakeld
    {
      if (!Led){Serial.println("LED-Strip: Automatisch aan");}
      digitalWrite(PinLed, HIGH);                             // LED-Strip aanzetten
      Led = true;                                             // Terugmelding voor AllThingsTalk
    }
    if (Uur == LedOffTime and Min == 0)                       // Om 8u 's morgens wordt de LED-Strip uitgeschakeld
    {
      if (Led){Serial.println("LED-Strip: Automatisch uit");}
      digitalWrite(PinLed, LOW);                              // LED-Strip uitzetten
      Led = false;                                            // Terugmelding voor AllThingsTalk
    }
  }
  else {
    if (digitalRead(PinLed) !=  Led)
    {
      if (Led){Serial.println("LED-Strip: Handmatig aan"); digitalWrite(PinLed, HIGH);}
      if (!Led){Serial.println("LED-Strip: Handmatig uit"); digitalWrite(PinLed, LOW);}
    }
    PinLed = Led;
  }

  //Dompelpomp
  if (!Hand) {                                                // Als het systeem in automatisch staat
    if (Min == 0 and Sec < 10)                                // Ieder uur wordt de dompelpomp voor 10 seconden aangeschakeld
    {
      if (!Domp){Serial.println("Dompelpomp: Automatisch aan");}
      DompPomp->run(FORWARD);                                 // Pomp Starten
      Domp = true;                                            // Terugmelding voor AllThingsTalk
    }
    else
    {
      if (Domp){Serial.println("Dompelpomp: Automatisch uit");}
      DompPomp->run(RELEASE);}                                // Pomp Stoppen
      Domp = false;                                           // Terugmelding voor AllThingsTalk
    }
  else {                                                      // Als het systeem in hand staat
    if (DmyDomp !=  Domp)
    {
      if (Domp){Serial.println("Dompelpomp: Handmatig aan");}
      if (!Domp){Serial.println("Dompelpomp: Handmatig uit");}
    }
    if (Domp == true) {DompPomp->run(FORWARD);} else {DompPomp->run(RELEASE);}
    DmyDomp = Domp;
  }

  //Vacuumpomp
  if (!Hand) {                                                // Als het systeem in automatisch staat
    if (Min < 15)                                             // De eerste 15 minuten van ieder uur wordt de vacuumpomp aangeschakeld
    {
      if (!Vac){Serial.println("Vacuumpomp: Automatisch aan");}
      VacPomp->run(FORWARD);                                  // Pomp Starten
      Vac = true;                                             // Terugmelding voor AllThingsTalk
    }
    else
    {
      if (Vac){Serial.println("Vacuumpomp: Automatisch uit");}
      VacPomp->run(RELEASE);}                                 // Pomp Stoppen
      Vac = false;                                            // Terugmelding voor AllThingsTalk
    }
  }
  else {                                                      // Als het systeem in hand staat
    if (DmyVac !=  Vac)
    {
      if (Vac){Serial.println("Vacuumpomp: Handmatig aan");}
      if (!Vac){Serial.println("Vacuumpomp: Handmatig uit");}
    }
    if (Vac == true) {VacPomp->run(FORWARD);} else {VacPomp->run(RELEASE);}
    DmyVac = Vac;
  }


  //Voedertrommel
  if (!Hand) {                                                // Als het systeem in automatisch staat
    if (Uur == FeedTime and Min == 0 and Sec == 0 and LastTime = CurTime)// Het is tijd om te voederen
    {
      if (!Feed){Serial.println("Voedertrommel: Automatisch gestart voor " + Feedrounds + " toeren");}
      FeedTimeEnd = CurTime + (FeedRounds * FeedTimeRound)    // Bereken de stoptijd voor het voederen
      Feeding = true;                                         // Voedertrommel starten
      Feed = true;                                            // Terugmelding voor AllThingsTalk
    }
  }
  else {                                                      // Als het systeem in hand staat
    if (Feed == true and Feeding == false)
    {
      if (Feed){Serial.println("Voedertrommel: Handmatig gestart voor 1 toer");}
      FeedTimeEnd = CurTime + (FeedTimeRound)                 // Bereken de stoptijd voor het voederen
      Feeding = true;                                         // Voedertrommel starten
    }
  }
  
  if (CurTime >= FeedTimeEnd)
  {
    if (Feed){Serial.println("Voedertrommel: gestopt met draaien");}
    Feeding = false;                                          // Voedertrommel stoppen
    Feed = false;                                             // Terugmelding voor AllThingsTalk
  }

  if (Feeding = true or Step  !=  0)
  {
    if (CurTime >= NextStep)
    {
      NextStep = CurTime + StepTime;
      if (StepDir){Step++;} else {Step--;}
      if (Step > 7) {Step = 0;}
      if (Step < 0) {Step = 7;}
    }
    switch(Step)
    {
      case 0:
        digitalWrite(PinSM0, LOW);
        digitalWrite(PinSM1, LOW);
        digitalWrite(PinSM2, LOW);
        digitalWrite(PinSM3, HIGH);
      break;
      case 1:
        digitalWrite(PinSM0, LOW);
        digitalWrite(PinSM1, LOW);
        digitalWrite(PinSM2, HIGH);
        digitalWrite(PinSM3, HIGH);
      break;
      case 2:
        digitalWrite(PinSM0, LOW);
        digitalWrite(PinSM1, LOW);
        digitalWrite(PinSM2, HIGH);
        digitalWrite(PinSM3, LOW);
      break;
      case 3:
        digitalWrite(PinSM0, LOW);
        digitalWrite(PinSM1, HIGH);
        digitalWrite(PinSM2, HIGH);
        digitalWrite(PinSM3, LOW);
      break;
      case 4:
        digitalWrite(PinSM0, LOW);
        digitalWrite(PinSM1, HIGH);
        digitalWrite(PinSM2, LOW);
        digitalWrite(PinSM3, LOW);
      break;
      case 5:
        digitalWrite(PinSM0, HIGH);
        digitalWrite(PinSM1, HIGH);
        digitalWrite(PinSM2, LOW);
        digitalWrite(PinSM3, LOW);
      break;
      case 6:
        digitalWrite(PinSM0, HIGH);
        digitalWrite(PinSM1, LOW);
        digitalWrite(PinSM2, LOW);
        digitalWrite(PinSM3, LOW);
      break;
      case 7:
        digitalWrite(PinSM0, HIGH);
        digitalWrite(PinSM1, LOW);
        digitalWrite(PinSM2, LOW);
        digitalWrite(PinSM3, HIGH);
      break;
      default:
        digitalWrite(PinSM0, LOW);
        digitalWrite(PinSM1, LOW);
        digitalWrite(PinSM2, LOW);
        digitalWrite(PinSM3, LOW);
      break;
    }
  }



  //om de 5 seconden wordt de data op het AllThingsTalk platform gerefreched
  if (Sec % 5 == 0 and LastTime == CurTime){                  // Als Sec deelbaar is door 5 zonder rest en de nieuwe seconde is net begonnen (puls op de seconde)
    Vocht = dht.readHumidity();
    Temp  = dht.readTemperature();
    Niv   = PinNiv;
    Device.Send(String(Vocht), AssNrVocht);
    Device.Send(String(Temp),  AssNrTemp);
    Device.Send(String(Niv),   AssNrNiv);
    //Device.Send(String(Hand),  AssNrHand);                  // Hand wordt voorlopig enkel gelezen van AllThingsTalk en nooit geschreven.
    Device.Send(String(Vent),  AssNrVent);
    Device.Send(String(Led),   AssNrLed);
    Device.Send(String(Domp),  AssNrDomp);
    Device.Send(String(Vac),   AssNrVac);
  }
  
  Device.Process(); 
}

////Asset nummers toewijzen voor AllThingsTalk
//int AssNrVocht = 1;                                           // Asset Number Vochtigheid
//int AssNrTemp  = 2;                                           // Asset Number Temperatuur
//int AssNrNiv   = 3;                                           // Asset Number Niveau schakelaar
//int AssNrHand  = 4;                                           // Asset Number Hand/Auto schakelaar
//int AssNrVent  = 5;                                           // Asset Number Ventilator
//int AssNrLed   = 6;                                           // Asset Number LED-Strip
//int AssNrDomp  = 7;                                           // Asset Number Dompelpomp
//int AssNrVac   = 8;                                           // Asset Number Vacuumpomp
//int AssNrFeed  = 9;                                           // Asset Number Voedertrommel

// Callback function: Behandeld berichten gezonden van het IOT platform naar de arduino.
// topic :   Asset name
// payload : Message
void callback(const char* topic, const char* payload, unsigned int length) 
{ 
	String msgString(payload);                            	    // convert to string object, so we can easily compare and modify the string.
  int AssNr = Device.GetPinNr(topic, strlen(topic));
    
	Serial.print("Payload (Message): ");                        // show some debugging.
  Serial.println(msgString);
  Serial.print("Topic (Asset Name): ");
  Serial.println(topic);
  Serial.print("Pin (Asset Number): ");
  Serial.println(AssNr);

  msgString.toLowerCase();                                    // to make certain that our comparison later on works ok (it could be that a 'true' or 'false' was sent)

  if (AssNr != NULL)
  {
    switch (AssNr) {                                          // We controleren voor welke Actuator het bericht is
      case AssNrHand:                                         // Asset Number Hand/Auto schakelaar
        if (msgString == "false"){Hand = false;}
        else if (msgString == "true"){Hand = true;}
      break;
      case AssNrVent:                                         // Asset Number Ventilator
        if (msgString == "false"){Vent = false;}
        else if (msgString == "true"){Vent = true;}
      break;
      case AssNrLed:                                          // Asset Number LED-Strip
        if (msgString == "false"){Led = false;}
        else if (msgString == "true"){Led = true;}
      break;
      case AssNrDomp:                                         // Asset Number Dompelpomp
        if (msgString == "false"){Domp = false;}
        else if (msgString == "true"){Domp = true;}
      break;
      case AssNrVac:                                          // Asset Number Vacuumpomp
        if (msgString == "false"){Vac = false;}
        else if (msgString == "true"){Vac = true;}
      break;
      case AssNrFeed:                                         // Asset Number Voedertrommel
        if (msgString == "true"){Feed = true;}
      break;
      default:
        Serial.println("We kregen een bericht van een onbekend Asset Number.")
        Serial.println("Asset Number: " + AssNr)
      break;
    }
    Device.Send(msgString, AssNr);          // also let the IOT platform know that the operation was succesful: give it some feedback. This also allows the iot to update the GUI's correctly & run scenarios.
  }  
}
Stepper motor programArduino
This is the individual program that runs our stepper motor.
int Pin0 = 10; 
int Pin1 = 11; 
int Pin2 = 12; 
int Pin3 = 13; 
int _step = 0; 
signed int dir = 1;
unsigned long time;

void setup() 
{ 
 pinMode(Pin0, OUTPUT);  
 pinMode(Pin1, OUTPUT);  
 pinMode(Pin2, OUTPUT);  
 pinMode(Pin3, OUTPUT);
   do {
 time = millis();
 switch(_step){ 
   case 0: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, HIGH); 
   break;  
   case 1: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, HIGH); 
   break;  
   case 2: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 3: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, HIGH); 
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 4: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, HIGH); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 5: 
     digitalWrite(Pin0, HIGH);  
     digitalWrite(Pin1, HIGH); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
     case 6: 
     digitalWrite(Pin0, HIGH);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 7: 
     digitalWrite(Pin0, HIGH);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, HIGH); 
   break;  
   default: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
 } 
 if(dir>0){_step++;}
 if(dir<0){_step--;}
 
 if(_step>7){_step=0;} 
 if(_step<0){_step=7;} 
  delay(1); 
  } while (time<8400);
} 
 
 void loop() 
{

}
 
Relais programArduino
With this program we can control our relais that we use for our LED-strip and ventilator.
//Relais aangesloten op D8. Voor D7 gewoon pin 7 gebruiken.


void setup() {
  // put your setup code here, to run once:
pinMode(9, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(9, HIGH);
delay(15000);
digitalWrite(9, LOW);
delay(5000);
}
DHT sensor programArduino
This is the program for our temperature and humidity sensor in the greenhouse.
   /* How to use the DHT-22 sensor with Arduino uno
   Temperature and humidity sensor
   More info: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
   Dev: Michalis Vasilakis // Date: 1/7/2015 // www.ardumotive.com */

//Libraries
#include <DHT.h>;

//Constants
#define DHTPIN 4     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
dht dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino


//Variables
int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

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

}

void loop()
{
    //Read data and store it to variables hum and temp
    hum = dht.readHumidity();
    temp= dht.readTemperature();
    //Print temp and humidity values to serial monitor
    Serial.print("Humidity: ");
    Serial.print(hum);
    Serial.print(" %, Temp: ");
    Serial.print(temp);
    Serial.println(" Celsius");
    delay(2000); //Delay 2 sec.
}
Non-contact liquid level sensorArduino
This program is used for the non-contact liquid level sensors to control our water level.
int functCap;

void setup(){
 //start
 Serial.begin(9600);
 pinMode(6, INPUT);
 pinMode(6, INPUT);
}
void loop()
{
functCap();
}

int functCap
{
 //De variabelen worden ingelezen.
 int sensorVal = digitalRead(6);
 //De waarde van het vloeistofniveau wordt weergegeven.
 Serial.println(sensorVal);
}
Vacuum and water pump programArduino
This program is used to run our vacuum pump or the water pump via the Adafruit motor shield.
//A4 en A5 worden gebruikt

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); 

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Adafruit Motorshield v2 - DC Motor test!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
  
  // Set the speed to start, from 0 (off) to 255 (max speed)
  myMotor->setSpeed(150);
  myMotor->run(FORWARD);
}

void loop() {
  uint8_t i;

 
  myMotor->run(FORWARD);
  delay(300000);
  
  
  myMotor->run(RELEASE);
  delay(2700000);
  

  
}

Credits

01ff89220c8fc82d46fd1398bc6986f8
Robbe Timmerman
1 project • 4 followers
Student Science and technology at the VTI of Veurne
Contact
66db8166bedeb65da4ba2be36855670e
Sebastiaan Lamers
1 project • 4 followers
Contact
C3db1147859400607622797aa3f98fc5
Andries Dedeurwaerder
1 project • 3 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog