I am connecting my Soil Moisture Temperature Sensor SHT10 with GSM Module SIM900A and GPS GY-GPS6MV2. Individually, all components work properly and give proper values. But when I interface all three components with Arduino, only Temperature sensor seems to work and GPS does not give any values. Even If I connect only SHT10 and GPS with Arduino Uno (without GSM), only SHT10 gives values but GPS doesn't.
My code is:
#include <AltSoftSerial.h>
#include <TinyGPS++.h>
#include <SHT1x.h>
AltSoftSerial gpsSerial (11,12);
TinyGPSPlus gps;
#define dataPin 6
#define clockPin 7
SHT1x sht1x(dataPin, clockPin);
float TEMP, HUMID;
void setup()
{
Serial.begin(9600);
gpsSerial.begin(9600);
}
void loop()
{
TEMP = sht1x.readTemperatureC();
HUMID = sht1x.readHumidity();
Serial.println(TEMP);
Serial.println(HUMID);
gps_value();
}
void gps_value()
{
while(gpsSerial.available())
{
gps.encode(gpsSerial.read());
}
if(gps.location.isUpdated())
{
Serial.println("Latitude: ");
Serial.println(gps.location.lat());
Serial.println("Longitude: ");
Serial.println(gps.location.lng());
Serial.println("Altitude Feet: ");
Serial.println(gps.altitude.feet());
Serial.println("Horizontal Dilution of Precision: "); //lower the better
Serial.println(gps.hdop.value());
Serial.println("");
}
}
What is happening here ?
-
DId you try to connect the GSM and GPS modules without connecting the temperature sensor?Macit– Macit05/20/2017 10:08:49Commented May 20, 2017 at 10:08
-
@Majid_L Yes, I have done that. And it works.knowledgeispower– knowledgeispower05/20/2017 11:06:48Commented May 20, 2017 at 11:06
-
1You should share the temperature sensor circuit and the power supply you are using. From the info you have given till now I think it is a problem related to hardware not software. It could be over loading the power supply or maybe the arduino is getting reset.Macit– Macit05/20/2017 11:13:51Commented May 20, 2017 at 11:13
-
@Majid_L I am powering Arduino with my PC itself.knowledgeispower– knowledgeispower06/01/2017 12:33:31Commented Jun 1, 2017 at 12:33
2 Answers 2
As already mentioned this seems to be a current related problem. You are powering your Arduino over Usb. The sensors themselves do work fine. Yet connecting all of them seems to draw too much current so they won’t work properly. (See this post for more information on current.
You could have used SoftwareSerial instead of AltSoftSerial.Since you are using AltSoftSerial please go through its library file to check how you need to deal with it. For Software Serial you need to use predefined Rx , Tx pins of Arduino rather than defining any other pins of it for Rx,Tx for connecting those to Rx Tx of tempterature sensor. For GPS try to define any 2 pins of Arduino as Rx Tx so that you can connect them to Rx Tx of GPS.Hope this helps you.
-
1NEVER use a software serial library on the HardwareSerial pins (RX pin 0 and TX pin 1). And
SoftwareSerial
is the worst alternative. See this answer for more info.slash-dev– slash-dev03/17/2018 14:46:57Commented Mar 17, 2018 at 14:46
Explore related questions
See similar questions with these tags.