• Categories
  • Recent
  • Popular
  • Tags
  • Users
  • Groups
  • Register
  • Login
MakerGram Logo

MakerGram

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Popular
  • Tags
  • Users
  • Groups

GPS + RF433 Not working together.

Arduino
3
14
1.4k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • rafitc99
    rafitc99 last edited by 12 Jun 2020, 19:18

    I need to get GPS location while a Trigger occurs. I'm sending trigger via 433Mhz RF transmitter. In the receiver, part contains a GPS module (NEO-7M) to get GPS location and RF 433Mhz to receiver RF message. (Refer code) My problem is by combining GPS + RF. GPS module not giving location details. While checking i found that while (gps.available( gps_port )) not running while #include <VirtualWire.h> is occur. I got a similar error while using SoftwareSerial.h with Radiohead.h

    What is the problem with these two libraries? Why Serial.available() not working in this code

    #include <NMEAGPS.h>
    #include <NeoSWSerial.h>
    #include <VirtualWire.h> 
    
    byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
    byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
    int received_number = 0;
    int LED = 5;
    int i =0;
    
    
    NeoSWSerial gps_port(6,7);
    NMEAGPS gps;
    
    
    void setup(){
      Serial.begin(9600);
      Serial.println( F("GPS Start") );  // F macro saves RAM
    
      gps_port.begin(9600);
      vw_set_rx_pin(11); // pin
      vw_setup(2000); // bps
      vw_rx_start();
    }
    
    void loop(){
        // Set buffer to size of expected message
        uint8_t buf[1];
        uint8_t buflen = sizeof(buf);
        // Check if received packet is correct size
      if (vw_get_message(message, &messageLength)) // non-blocking
      {
        Serial.print("Potentiometer: ");
          //Serial.print(message[i]);
          received_number = message[i];
        Serial.println(received_number);
    
          if(received_number == 1){
            Serial.println("Triggered");
            getGpsData();    
          }
        }
    }
    
    void getGpsData() {
      Serial.println("im here");
      while (gps.available( gps_port )) {
        
        gps_fix fix = gps.read();
        if (fix.valid.location) {
          
          float outArray[2];
          outArray[0] = fix.latitude();  // Arrays start at 0, not 1.  Did you really mean [1] here?
          outArray[1] = fix.longitude();
    
          Serial.println( F("Latitude:") );
          Serial.println( outArray[0], 6 );
          Serial.println( F("Longitude:") );
          Serial.println( outArray[1], 6 );
          Serial.println("___________");
        }
        else {
          Serial.println("GPS Not availble");
        }
      }
    }
    
    salmanfaris manthan555 2 Replies Last reply 12 Jun 2020, 21:07 Reply Quote 1
    • salmanfaris
      salmanfaris @rafitc99 last edited by salmanfaris 12 Jun 2020, 19:27 12 Jun 2020, 19:25

      @rafitc99 said in GPS + RF433 Not working together.:

      I got a similar error while using

      Can you share the error here, also share the library link that you are using.

      rafitc99 1 Reply Last reply 12 Jun 2020, 19:26 Reply Quote 1
      • rafitc99
        rafitc99 @salmanfaris last edited by 12 Jun 2020, 19:26

        @salmanfaris Not syntax error. its not reading GPS data. That's the problem.

        1 Reply Last reply Reply Quote 0
        • salmanfaris
          salmanfaris last edited by salmanfaris 12 Jun 2020, 19:30 12 Jun 2020, 19:28

          What output you are getting? Just some zeros?

          rafitc99 1 Reply Last reply 12 Jun 2020, 19:31 Reply Quote 1
          • rafitc99
            rafitc99 @salmanfaris last edited by rafitc99 12 Jun 2020, 19:32 12 Jun 2020, 19:31

            @salmanfaris No any output. Arduino not wating for GPS data.Not runing this loop while (gps.available( gps_port ))

            1 Reply Last reply Reply Quote 0
            • salmanfaris
              salmanfaris last edited by salmanfaris 12 Jun 2020, 19:45 12 Jun 2020, 19:44

              does it return one/true when you are testing only with gps and gps.available( gps_port )?

              rafitc99 2 Replies Last reply 12 Jun 2020, 19:53 Reply Quote 0
              • rafitc99
                rafitc99 @salmanfaris last edited by 12 Jun 2020, 19:51

                @salmanfaris gps.available( gps_port ) Is not return a True case.

                salmanfaris 1 Reply Last reply 12 Jun 2020, 19:54 Reply Quote 0
                • rafitc99
                  rafitc99 @salmanfaris last edited by 12 Jun 2020, 19:53

                  @salmanfaris for running while(gps.avaible()); MCU need to wait some time. but after adding VirtualWire library it's not waiting for Serial.available()

                  salmanfaris 1 Reply Last reply 12 Jun 2020, 19:57 Reply Quote 0
                  • salmanfaris
                    salmanfaris @rafitc99 last edited by 12 Jun 2020, 19:54

                    @rafitc99 said in GPS + RF433 Not working together.:

                    ps.available( gps_port ) Is not return a True case.

                    Then how is the while loop will work? It should return!

                    rafitc99 1 Reply Last reply 12 Jun 2020, 19:59 Reply Quote 0
                    • salmanfaris
                      salmanfaris @rafitc99 last edited by 12 Jun 2020, 19:57

                      @rafitc99 said in GPS + RF433 Not working together.:

                      library it's not waiting for Serial.available()

                      did you try manual waiting? Instead of delay, you can use mills, so the background works will keep run.

                      1 Reply Last reply Reply Quote 2
                      2 out of 14
                      • First post
                        2/14
                        Last post

                      Recent Posts

                      • @codelery Awesome. That's great news. Kudos to @rafitc99 . 🙌

                        @codelery Please keep us updated about your project, looking forward to seeing it in action 🤩

                        7 Jul 2023, 06:58 • read more
                      • C

                        @rafitc99 I changed the buffer and that solved the problem. Thanks a lot for coming to my rescue.

                        7 Jul 2023, 00:44 • read more
                      • C

                        @salmanfaris I did change the buffer size and everything is working perfectly. Thanks coming to my rescue.

                        7 Jul 2023, 00:41 • read more
                      • @codelery said in Help needed: Arduino Wireless Notice Board project:

                        I am using the hardware serial (pin 0 and 1 on Arduino Uno)

                        As @rafitc99 mentioned, you need to expand the Serila buffer, in the hardware serial also the Arduino board package implements a 64-byte ring buffer for send and receive on the hardware serial messages. So you need to change that to 256 as per your message length.

                        6 Jul 2023, 12:22 • read more
                      • C

                        @rafitc99 The thing is that I am not using the SoftwareSerial library in receiving the message from the first microcontroller. I am using the hardware serial (pin 0 and 1 on Arduino Uno)

                        6 Jul 2023, 01:45 • read more
                      By MakerGram | A XiStart Initiative | Built with ♥ NodeBB
                      Copyright © 2023 MakerGram, All rights reserved.
                      Privacy Policy | Terms & Conditions | Disclaimer | Code of Conduct