1

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 ?

Datasheet of SHT10

SHT10

4
  • DId you try to connect the GSM and GPS modules without connecting the temperature sensor?
    – Macit
    May 20, 2017 at 10:08
  • @Majid_L Yes, I have done that. And it works. May 20, 2017 at 11:06
  • 1
    You 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
    May 20, 2017 at 11:13
  • @Majid_L I am powering Arduino with my PC itself. Jun 1, 2017 at 12:33

2 Answers 2

1

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.

0

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.

1
  • 1
    NEVER 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
    Mar 17, 2018 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.