Go Down

Topic: My GSM cannot send data to my database TT TT please help (Read 72 times) previous topic - next topic

angelinajolin

This is my code. I was able to receive but the sending has problems/

Code: [Select]
#include <DHT.h>
#include <SoftwareSerial.h>


#include "Ultra.h"
#define DHTPIN 2
#define DHTTYPE DHT22

SoftwareSerial SIM900(7,8);
Ultrasonic ultrasonic(12, 13);
Waterpump waterpump(A0);
DHT dht(DHTPIN, DHTTYPE);

void setup() {
    Serial.begin(4800);
SIM900.begin(4800);
delay (20000);
SIM900.print("AT+CMGF=1\r");
  delay (100);
  SIM900.println("AT+CMGS=\"+6394542753959\"");
  delay (100);
  SIM900.println("helloworld");
  delay(100);
  SIM900.println((char)26);
  delay(100);
  SIM900.println();
  delay(5000);
}

void loop() {
   float h = dht.readHumidity();
   float t = dht.readTemperature();
 
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
 Serial.println("  ");

  float distance = ((ultrasonic.timing() * (331.3 + (0.606 * dht.readTemperature())))/10000)/2;
//  float dist;
//  if (distance == 16.8){
//      dist=1;
//      //16.4-distance;
//    }
//   else {
//    dist=0;}
//  Serial.println(ultrasonic.timing(),1);
  Serial.println("Distance in CM: ");
//  // Pass INC as a parameter to get the distance in inches
  Serial.println(ultrasonic.distanceRead(),1);
  Serial.println((distance),1);
 // Serial.println(dist,1);
  delay(1000);
//  Serial.println("Volume: ");
//  Serial.println(ultrasonic.volume());
//  delay(1000);
//  Serial.println("Precipitation: ");
//  Serial.println(ultrasonic.precipitation());
//  delay(1000);
//  if(ultrasonic.distanceRead()>=6){
//  waterpump.runWaterpump();
//  Serial.println("gwapa ko");
//  delay(10000);
//  waterpump.stopWaterpump();
//  delay(1000);
sendSMS();
do {} while (1);
//}

}
//8.9 cm
void sendSMS()
{
   float h = dht.readHumidity();
   float t = dht.readTemperature();
   
  SIM900.print("AT+CMGF=1\r");
  delay (100);
  SIM900.println("AT+CMGS=\"+6394542753959\"");
  delay (100);
//  SIM900.println("distance");
//  delay(100);
  SIM900.println("h");
  delay(100);
  SIM900.print(",\t");
  SIM900.println("t");
  delay(100);
  SIM900.print(",\t");
  SIM900.println((char)26);
  delay(100);
  SIM900.println();
  delay(5000);
}

PaulS

Quote
but the sending has problems
So, fix them. If you need help, you need to tell us what the problems are. What does the code ACTUALLY do? What do you expect it to do? How do those things differ?

The art of getting good answers lies in asking good questions.

angelinajolin

So, fix them. If you need help, you need to tell us what the problems are. What does the code ACTUALLY do? What do you expect it to do? How do those things differ?


I am supposed to send data from ultrasonic to the other end of arduino using GSM sim900, but sadly I cant received in my base station any text from the other end.

PaulS

Quote
I am supposed to send data from ultrasonic to the other end of arduino using GSM sim900
You have an Arduino that is so large that you need to use a GSM Shield to send data from one end to the other?

I think that you need to be a bit clearer about what you need to send data to, and what the code that you posted actually does.
The art of getting good answers lies in asking good questions.

Go Up