Skip to content

Instantly share code, notes, and snippets.

@timatooth timatooth/Readme.md
Created Sep 17, 2017

Embed
What would you like to do?
Monitor plant status with arduino

LoRa Shield, TFT Display

Plant monitoring project

Uses RadioHead RFM95W SX1272 (RF96) RF chip

Senses

  • Soil Moisture
  • Light level
  • Temperature
  • Humidity

Hardware:

  • DHT11 Temperature & Humidity sensor
  • 128x128 ST7735 Color TFT LCD Display
  • Arduino LoRa Shield 915MHz
  • LDR for light level sensor
  • Soil Moisture sensor (resistance type)
  • Arduino Uno/Duemilanove

SPI

The Dragino LoRa shield & LCD use SPI.

CLK  13
MOSI 11
MISO 12

LORA Shied (not changeable)

CS/SS 10
RST   9

TFT LCD

CS/SS 7
RST   5
D/C   6
#include <SPI.h>
#include <TFT.h>
#include <dht.h>
#include <RH_RF95.h>
/*
# LORA Shied (not changeable)
CS 10
RST 9
# TFT LCD
CS 7
RST 5
D/C 6
*/
#define TFT_CS 7
#define TFT_DC 6
#define TFT_RST 5
#define DHT11_PIN 4
RH_RF95 rf95;
TFT tft = TFT(TFT_CS, TFT_DC, TFT_RST);
dht DHT;
void setup(){
Serial.begin(9600);
while (!Serial) ; // BusyWait for serial port to be available
if (!rf95.init()) {
Serial.println("Radio init failed");
}
rf95.setFrequency(916.000);
rf95.setTxPower(5, false); //5 - 20dBm
//rf95.setModemConfig(RH_RF95::Bw125Cr48Sf4096); //long range and shittly slow 1s transmit time
tft.begin();
tft.background(0, 0, 255);
delay(100);
tft.setRotation(2);
tft.background(0, 0, 0);
tft.stroke(255, 255, 255);
tft.setTextSize(2);
tft.text("Parsley ", 10, 10);
tft.setTextSize(1);
}
void loop()
{
// Send a message to rf95_server
int chk = DHT.read11(DHT11_PIN);
int lightVal = analogRead(A5);
int soilVal = analogRead(A0);
tft.stroke(255, 255, 255);
String humidity = String("Humidity: ");
humidity += DHT.humidity;
humidity += "%";
tft.text(humidity.c_str(), 10, 50);
String temperature = String("Temp: ");
temperature += DHT.temperature;
tft.text(temperature.c_str(), 10, 60);
String light = String("Light: ");
light += lightVal;
tft.text(light.c_str(), 10, 70);
String soil = String("Soil: ");
soil += soilVal;
tft.text(soil.c_str(), 10, 80);
//Data
String msg = String(DHT.temperature);
msg += ", ";
msg += DHT.humidity;
msg += ", ";
msg += lightVal;
msg += ", ";
msg += soilVal;
Serial.println(msg);
rf95.send(msg.c_str(), msg.length() + 1);
rf95.waitPacketSent();
delay(5000);
// erase the text you just wrote
tft.stroke(0, 0, 0);
tft.text(humidity.c_str(), 10, 50);
tft.text(temperature.c_str(), 10, 60);
tft.text(soil.c_str(), 10, 80);
tft.text(light.c_str(), 10, 70);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.