Alex Winiarski
Published © GPL3+

Smart Garden - Alexa consults & automates your garden

How might we utilise smart water management systems to enhance our human experience for the people of today, and also tomorrow.

AdvancedWork in progress14 hours1,651
Smart Garden - Alexa consults & automates your garden

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1

Software apps and online services

AWS Lambda
Amazon Web Services AWS Lambda
Alexa Skills Kit
Amazon Alexa Alexa Skills Kit

Story

Read more

Schematics

Thinxtra Kit

Code

Soil Moisture

Arduino
#include <dht.h>
#include <WISOL.h>
#include <Tsensors.h>
#include <Wire.h>
#include <math.h>

int temp;
int mositure;

Isigfox *Isigfox = new WISOL();
Tsensors *tSensors = new Tsensors();

typedef union{
    float number;
    uint8_t bytes[4];
} FLOATUNION_t;

typedef union{
    uint16_t number;
    uint8_t bytes[2];
} UINT16_t;

typedef union{
    int16_t number;
    uint8_t bytes[2];
} INT16_t;



int val = 0; //value for storing moisture value 
int soilPin = A0;//Declare a variable for the soil moisture sensor 
int soilPower = 7;//Variable for Soil moisture Power


void setup(){
  Serial.begin(9600);
  pinMode(soilPower, OUTPUT);//Set D7 as an OUTPUT
  digitalWrite(soilPower, LOW);//Set to LOW so no power is flowing through the sensor

  Isigfox->initSigfox();
  Isigfox->testComms();

// Init sensors on Thinxtra Module
  tSensors->initSensors();

  // Init an interruption on the button of the Xkit
  tSensors->setButton(buttonIR);

}

void loop()
{
static unsigned long dataTime=millis();
if(millis() >= dataTime)   //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
  {
  dataTime=millis()+600000;
  Send_Data();
  }
}

int readSoil()
{
    digitalWrite(soilPower, HIGH);//turn D7 "On"
    delay(10);//wait 10 milliseconds 
    val = analogRead(soilPin);//Read the SIG value form sensor 
    digitalWrite(soilPower, LOW);//turn D7 "Off"
    return val;//send current moisture value
}




int readTemp(){
  int temp = (tSensors->getTemp() * 100);
  return temp;
  }  
  



void Send_Pload(uint8_t *sendData, const uint8_t len) {
  recvMsg *RecvMsg;

  RecvMsg = (recvMsg *)malloc(sizeof(recvMsg));
  Isigfox->sendPayload(sendData, len, 0, RecvMsg);
  for (int i = 0; i < RecvMsg->len; i++) {
    Serial.print(RecvMsg->inData[i]);
  }
  Serial.println("");
  free(RecvMsg);
}

void Send_Data(){
  UINT16_t mositure, temp;

  mositure.number = (uint16_t)readSoil();
  Serial.println(mositure.number);
  temp.number = (uint16_t)readTemp();
  Serial.println(temp.number);

 

const uint8_t payloadSize = 4; //in bytes
//  byte* buf_str = (byte*) malloc (payloadSize);
  uint8_t buf_str[payloadSize];

  buf_str[0] = mositure.bytes[0];
  buf_str[1] = mositure.bytes[1];
  buf_str[2] = temp.bytes[0];
  buf_str[3] = temp.bytes[1];


  
  
Send_Pload(buf_str, payloadSize);
  
  }




void buttonIR(){
    
Send_Data();
Serial.print("Button Works");

}

Credits

Alex Winiarski

Alex Winiarski

2 projects • 4 followers

Comments

Add projectSign up / Login