UbiMakerMaka Hernandez
Published © CC BY-NC-SA

Do You Know How Your Plants Are Feeling? [Particle+Ubidots]

Build and deploy a soil moisture and temperature sensor for commercial greenhouses or private garden monitoring and treatment.

IntermediateFull instructions provided5 hours1,281
Do You Know How Your Plants Are Feeling? [Particle+Ubidots]

Things used in this project

Hardware components

Electron
Particle Electron
×1
Adafruit Soil Temperature/Moisture Sensor - SHT10
×1
Resistor 10k ohm
Resistor 10k ohm
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Protection plastic case
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Ubidots
Ubidots
Particle IDE

Story

Read more

Schematics

Diagram connections

Code

CODE

C/C++
// This example is to get the last value of variable from the Ubidots API

// This example is to save multiple variables to the Ubidots API with TCP method

/****************************************
 * Include Libraries
 ****************************************/

#include "Ubidots.h"
#include <SHT1x.h>
#include <application.h>

/****************************************
 * Define Constants
 ****************************************/

#ifndef TOKEN
#define TOKEN "Put_your_Ubidots"  // Put here your Ubidots TOKEN
#endif

#ifndef DATAPIN
#define DATAPIN D0
#endif

#ifndef CLCKPIN
#define CLCKPIN D1
#endif

#ifndef LED
#define LED D7
#endif

Ubidots ubidots(TOKEN);


/****************************************
 * Auxiliar Functions
 ****************************************/

SHT1x sht10(DATAPIN, CLCKPIN);

/****************************************
 * Main Functions
 ****************************************/

void setup() {
    Serial.begin(115200);
    pinMode(LED, OUTPUT);
    //ubidots.setDebug(true);  //Uncomment this line for printing debug messages
}

void loop() {
    
    float humidity = sht10.readHumidity();
    float temperature = sht10.readTemperatureC();
    
    ubidots.add("soil-moisture", humidity); 
    ubidots.add("temperature", temperature);
    
    ubidots.setMethod(TYPE_TCP);  //Set to TCP the way to send data
    if(ubidots.sendAll()){
        // Do something if values were sent properly
        Serial.println("Values sent by the device");
        digitalWrite(LED, HIGH);
    }
    delay(5000);
    digitalWrite(LED, LOW);
}

Credits

UbiMaker

UbiMaker

53 projects • 228 followers
Maker @ ubidots.com
Maka Hernandez

Maka Hernandez

29 projects • 122 followers

Comments