im bulding an automated plant monitoring system using ldr, soil moisture sensor and dht11 temp and humidity sensor connected to a fan, water pump and led light via a relay to the arduino mega. the arduino is connected to the bolt via SoftwareSerial using 10,11 pin of arduino mega to Rx&Tx pin of bolt respectively. I’m unable to send the sensor data to bolt via uart communication.
arduino code:
#include <DHT.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);//(connected to Rx of Bolt, Tx of Bolt)
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
int ldr = A0; //LDR connected to pin A0
int fan = 7; // Fan relay connected to pin 7
int light = 5; // Light relay connected to pin 5
int pump = 6; // pump relay connected to pin 6
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
dht.begin();
pinMode(DHTPIN,INPUT);
pinMode(ldr,INPUT);
pinMode(fan,OUTPUT);
pinMode(light,OUTPUT);
pinMode(pump,OUTPUT);
}
void loop() {
String data;
int hum = dht.readHumidity();
int temp = dht.readTemperature();
if(digitalRead(ldr>800))
{
digitalWrite(light,LOW);
}
else
{
digitalWrite(light,HIGH);
}
delay(1000);
if(temp>25||hum>80)
{
digitalWrite(fan,LOW);
}
else{
digitalWrite(fan,HIGH);
}
int moist = analogRead(A1);//Moisture Sensor connected to A1
if(moist>500)
{
digitalWrite(pump,LOW);
}
else
{
digitalWrite(pump,HIGH);
}
data="Temp: "+String(temp)+“C Hum: “+String(hum)+” % Sunlight: “+String(ldr)+” Moisture:”+String(moist);
Serial.println(data);
if (mySerial.available() > 0)
{
delay(50);
String readData = “”;
Serial.print("Command from Bolt: ");
while (mySerial.available() > 0 )
{
readData = readData + (char)mySerial.read();
}
Serial.println(readData);
if (readData.indexOf("RD") != -1)
{
String uploadData =String(temp)+","+String(hum)+","+String(ldr)+","+String(moist);
mySerial.print(uploadData);
Serial.print("Data sent to Bolt: ");
Serial.println(data);
}
}
delay(300000);
}
Upon researching online i came to know that the bolt should be able to send an “RD” command for arduino to start sending the data. but im not getting the “RD” command
bolt code:
setChartTitle(‘Smart Automated Monitoring System’)
var lineGraph1 = new boltGraph();
lineGraph1.setChartType(“lineGraph”);
lineGraph1.setAxisName(‘Time’,‘Temp C’);
lineGraph1.plotChart(‘time_stamp’,‘temp’);
var lineGraph2 = new boltGraph();
lineGraph2.setChartType(“lineGraph”);
lineGraph2.setAxisName(‘Time’,‘Humidity %’);
lineGraph2.plotChart(‘time_stamp’,‘hum’);
var lineGraph3 = new boltGraph();
lineGraph3.setChartType(“lineGraph”);
lineGraph3.setAxisName(‘Time’,‘Sunlight’);
lineGraph3.plotChart(‘time_stamp’,‘ldr’);
var lineGraph4 = new boltGraph();
lineGraph4.setChartType(“lineGraph”);
lineGraph4.setAxisName(‘Time’,‘Soil Mositure %’);
lineGraph4.plotChart(‘time_stamp’,‘moist’);