KenLagoni / MavlinkGPRS

Mavlink Telemetry from drone to server via GPRS (SIM800l)
11 stars 2 forks source link

Asking question #1

Closed mohanbabi closed 2 years ago

mohanbabi commented 3 years ago

Can i use Arduino uno instead of Arduino MKRZero.

KenLagoni commented 3 years ago

Can i use Arduino uno instead of Arduino MKRZero. No the code is c++ and is made for 32-bit ARM MCU. The UNO is only 8-bit and with only one HW UART you will have to port it to the UNO. The concept however can transferred to an UNO, but why would you do that? the MKRZERO is a lot more powerful.

mohanbabi commented 3 years ago

thank you. i am not worked with Arduino mkr zero. that is why i am asking sir.

sir can you give real time example for this command ./MavlinkGPRSServer [GPRS INPUT UDP PORT] [TCP CLIENTHS PORT] [UDP CLIENT PORT]

GPRS INPUT UDP PORT=? TCP CLIENTHS PORT=? TCP CLIENTHS PORT=? UDP CLIENT PORT=?

sorry about my English.

KenLagoni commented 3 years ago

The UNO is a very old MCU and a'lot has happened since it was released in 2005. I would strongly suggest the MKRZero, since it can be programmed just like the UNO in the Arduino sketch and is miles ahead of the UNO in performance.

Regarding the MavlinkGPRSServer:

GPRS INPUT UDP PORT = Is is the UDP port where the SIM800L (MKRZero) sends the data to. It is default 14450 in "ArdupilotGPRSLink.ino" line 52.

TCP CLIENTHS PORT= Mission planner and QgroundStation uses default TCP port 5760, but it can be changed.

UDP CLIENT PORT= I would suggest setting it to 6000 but never use it. Instead connect to the server via TCP (5760), this will be more reliable if you connect to it from the Internet/4G modem.

This will give you: ./MavlinkGPRSServer 14450 5760 6000

Good luck and let me know if you have any issues :-)

mohanbabi commented 3 years ago

Thank you, Sir,

I will definitely be going to test this code with MKRZero only. But in India, only a few online stores having MKRZero boards, that to it is costing around INR3000 (40 USD). I am planning to buy this month's budget.

Regarding the MavlinkGPRSServer: I understood your explanation, sir, I have no doubt at all.

Thank you very much @KenLagoni sir for your support. I will give updates on my learning.

mohanbabi commented 2 years ago

@KenLagoni Sir Just today I was received MKRzero, I just run without a flight controller, It is working very well. Thank you very much for your guidance. I will share photos later. Thank you @KenLagoni Sir

mohanbabi commented 2 years ago

@KenLagoni Drone is not connecting to Ground control station Screenshot from 2021-07-26 15-33-57 Screenshot from 2021-07-26 12-59-38

KenLagoni commented 2 years ago

Are you getting data from Drone to QGroundControl? as in can you se the artificial horizon move around when you move the Drone?

mohanbabi commented 2 years ago

no, I did not get any data. may be i did not use memory card in mkrzero, that is why not getting data! memory card is necessary? sir

KenLagoni commented 2 years ago

no, I did not get any data. may be i did not use memory card in mkrzero, that is why not getting data! memory card is necessary? sir

Yes you need an SD card for the program to log to.

There is a lot of places where things can go wrong. I would suggest starting with the MKRzero and insure it is running correctly and gets MAVLINK data from drone first. To do this run the MKRzero with USB connected to PC, it will output debug on that serial port, baudrate 115200. It will start debug: "Initializing SD card.." and then (if successful) it will show the name of the txt file on the SD which it will log to.

Next I would then ensure MAVLINK data is received on the GPRSserver. To do this the simplest way is to include (remove the "//") the printf in the main.cpp linie 209: "printf("MAIN: MSG=%d received from Drone\n",msg.msgid); " and then rebuild the program. Then the program will output each time a MAVLINK msg is received from the Drone (MKRZero).

Once you see the messages coming in to the program, then you can try connecting QgroundControl.

In order words: Step 1: Ensure MKRzero is running and forwarding messages via SIM800L. Step 2: Ensure Data is recieved in the GPRSServer. Step 3. Connect Qgroundcontrol to GPRSServer.

Good luck :-)

mohanbabi commented 2 years ago

@KenLagoni ok sir.... i will do this today, and give results after completing.

Thank you @KenLagoni sir 🙏

mohanbabi commented 2 years ago

My work flow @KenLagoni Sir, This is my setup: Is ok? or do I need to make changes to it?

Thank you @KenLagoni sir

mohanbabi commented 2 years ago

no, I did not get any data. may be i did not use memory card in mkrzero, that is why not getting data! memory card is necessary? sir

Yes you need an SD card for the program to log to.

There is a lot of places where things can go wrong. I would suggest starting with the MKRzero and insure it is running correctly and gets MAVLINK data from drone first. To do this run the MKRzero with USB connected to PC, it will output debug on that serial port, baudrate 115200. It will start debug: "Initializing SD card.." and then (if successful) it will show the name of the txt file on the SD which it will log to.

Next I would then ensure MAVLINK data is received on the GPRSserver. To do this the simplest way is to include (remove the "//") the printf in the main.cpp linie 209: "printf("MAIN: MSG=%d received from Drone\n",msg.msgid); " and then rebuild the program. Then the program will output each time a MAVLINK msg is received from the Drone (MKRZero).

Once you see the messages coming in to the program, then you can try connecting QgroundControl.

In order words: Step 1: Ensure MKRzero is running and forwarding messages via SIM800L. Step 2: Ensure Data is recieved in the GPRSServer. Step 3. Connect Qgroundcontrol to GPRSServer.

Good luck :-)

I am doing now your suggestions with my setup.

mohanbabi commented 2 years ago

LOG.TXT This log file is saved on the memory card. @KenLagoni Sir can we run Arduino MKR Zero and sim800l using USB power.

KenLagoni commented 2 years ago

Sorry I didn't include this in my description of the setup: The SIM800L needs to be able to draw up to 2A and the VCC must be between 3.7V-4.2V. One way to do this is to use an external 5V/2A PSU to power the MKRzero and the SIM800L using two diodes to get the voltage down to the correct levels (this is what I have done): image

Next the IP you need must be a global (preferred fixed) IP. 192.168.1.39 is a local IP generated from your 4G modem to your PC. If you access www.myip.com from the PC via the 4G modem, you will se the global IP. Now I don't think this will work. I have never tried routing back through an 4G modem and I would be surprised if it works, since I don't see a way to allow incoming traffic to your PC. Also the global IP the 4G modem gets is not fixed and will change and thus you need to reprogram the MKRZero. I would suggest using a more fixed internet connection (cabled), one were you can set the firewall to forward traffic from port 14550 (or what you are using) directly to the PC. This is what I do.

Best of luck.

mohanbabi commented 2 years ago

Ok, @KenLagoni Sir

Sorry I didn't include this in my description of the setup

yes, That setup is planned by me😊

I will Buy Diodes and will do the experiment again.

Coming to IP can we use Cloud computing like AWS?

Today I am stopping experimenting, because of my weak power supply. After procurement of all components, I will restart. In a meenwhile, I will work on AWS, to get public IP.

Thank you very much Sir @KenLagoni

KenLagoni commented 2 years ago

Just to understand, the reason you want to use 4G modem on the server is because that is the only Internet option you have or? I don't if AWS is the solution, but let me know what you find out.

mohanbabi commented 2 years ago

Ok @KenLagoni Sir,😊

KenLagoni commented 2 years ago

You can add some more debug output from MKRZero via Serial, if you change "DEBUG_MODE 0" to "DEBUG_MODE 1" in line 14 in the SIM800L.h file. This debug will only be printed on serial (USB) on MKRZero, not logged to SD card.

mohanbabi commented 2 years ago

@KenLagoni Sir When I am uploading sensor data to "thingspeak" using Arduino uno, Sim800l is working. I am also seeing values in "thingspeak". But in this why it is showing like this in debugging window 231149:SIM800L:Status: Send Errors:0 Under Voltage warnings: 0 Over Voltage warnings: 0 Total Errors: 0 Total service: 0 Total Bytes: 0 Bandwidth: 0 byte/sec

Sir, I am studying IP addressing and how to communicate with local servers from the outside of the network.

Thank you @KenLagoni Sir

KenLagoni commented 2 years ago

Please enable the DEBUG MODE 1 in line 14 in SIM800L and send me the serial output. Let it run for 2min.

mohanbabi commented 2 years ago

@KenLagoni Sir please look this serialDebugLog.txt

KenLagoni commented 2 years ago

Please save the log to a file next time and upload it :-)

Okay, so you are not getting any data from SIM800L to MKRZero. I would double check that you have connected it as described: image

It can also be that the SIM800L is not running 115200 Baudrate. Have you perhaps changed the baudrate? like when testing on UNO?

Is the RED led flashing on the SIM800L?

mohanbabi commented 2 years ago

Please save the log to a file next time and upload it :-)

Ok Connection all are correct sir. Now, I will change baud rate 9600, And will give you an update on it, sir.

Is the RED led flashing on the SIM800L?

light is flashing every second some time, and flashing every 3 seconds.

Thank you @KenLagoni Sir

mohanbabi commented 2 years ago

9600 baud rate serial Debug_log.txt @KenLagoni Sir please find the log file.

Sir, I am using lion single cell to power to sim800l. Battery parameters are voltage=4.2v and A=2000mah.

the result is negative.

KenLagoni commented 2 years ago

Baudrate must be 115200 on SIM800L. Can you verify with command: "AT+IPR?" ?

Battery should be fine, just remember to connect battery ground (-) to MKRZero GND.

mohanbabi commented 2 years ago

Baudrate must be 115200 on SIM800L.

Ok Sir.

Can you verify with command: "AT+IPR?" ?

Ok sir AT+IPR?

+IPR: 0

OK

Battery should be fine, just remember to connect battery ground (-) to MKRZero GND.

OK SIR i done this

KenLagoni commented 2 years ago

By the way thank you for testing this, It is good to find the bugs/improvment :-)

The default baudrate on SIM800L is 9600, but this needs to be changed since I didn't make the code which does this automatically. It has been a while since I last used the SIM800L, but I think you can just do this: AT+IPR=115200 This should say OK

Then Power the SIM800L OFF. Set the Baudrate to 115200 on PC Power ON SIM800L and try AT+IPR? It should say +IPR:115200

mohanbabi commented 2 years ago

AT+IPR=115200

ok

Then Power the SIM800L OFF. Set the Baudrate to 115200 on PC Power ON SIM800L and try AT+IPR? It should say +IPR:115200

This is not working sir

KenLagoni commented 2 years ago

AT+IPR=115200

ok

Then Power the SIM800L OFF. Set the Baudrate to 115200 on PC Power ON SIM800L and try AT+IPR? It should say +IPR:115200

This is not working sir

What does it say/do?

mohanbabi commented 2 years ago

good news for me Sir😊 it is worked

AT

OK AT+IPR?

+IPR: 115200

OK

KenLagoni commented 2 years ago

good news for me Sir😊 it is worked

AT

OK AT+IPR?

�+IPR: 115200

OK

Great!, if it goes back to +IPR:0 after power cycle, you need to save the settings with "AT&W". So: AT OK

AT+IPR=115200 OK AT&W OK

Done.

Now try the MavlinkGPRS program and sent Serial log :-)

mohanbabi commented 2 years ago

⸮T⸮ OK ⸮T+IPR?

+IPR: 114200

OK ⸮T+IPR?

+IPQ: 115200

OK AT+IPR?

+IPR: 115200

OK the above result is after one power cycle

KenLagoni commented 2 years ago

⸮T⸮ OK ⸮T+IPR?

+IPR: 114200

OK ⸮T+IPR?

+IPQ: 115200

OK

AT+IPR?

+IPR: 115200

OK

Looks good, now try the MavlinkGPRS and send serial log, it should do more stuff :-)

mohanbabi commented 2 years ago

SIM800l baud rate is 115200 serial Debug_log.txt

The happy news for me is this time i got new messages in serial windows. Please check this log @KenLagoni Sir. now i am not connected pixhwak(flight controller).

Now RED light in SIM800l is blinking every second

Thank you very much @KenLagoni Sir. sorry, if you felt any uncomfort when I am doing experiments. I do not have any programming knowledge.

mohanbabi commented 2 years ago

can we do the remaining tomorrow?

please send me some material regarding MAVlink server and public IP and private IP. today I will read those.

Thank you @KenLagoni Sir

KenLagoni commented 2 years ago

It stops when it tries to setup the GPRS. This could be because SIM card does not have a DATA plan but only Call and SMS.

Do you have data available for the SIM card?

mohanbabi commented 2 years ago

yes sir i have data. I already check with "thinkspeak". It is uploaded data into the sensor channel.

KenLagoni commented 2 years ago

It fails here: RDY +CFUN: 1 +CPIN: READY

Call Ready SMS Ready

ATE1 OK

AT+CIPMUX=1 OK

AT+CSTT="airtelgprs.com" OK

AT+CIICR +PDP: DEACT

it should be: AT+CIICR OK

We will have to look in to this...

KenLagoni commented 2 years ago

Is this ths code you are using when testing "thinkspeak"? https://how2electronics.com/send-gsm-sim800-900-gprs-data-thingspeak-arduino/

If so, could you perhaps send the output from this when it is working? :-) (Remember that the Baudrate must be set to 115200 in the "thinkspeak" code because we changed it on the SIM800L).

mohanbabi commented 2 years ago

Is this ths code you are using when testing "thinkspeak"? https://how2electronics.com/send-gsm-sim800-900-gprs-data-thingspeak-arduino/

Yes Sir,

@KenLagoni Sir I used this code(https://drive.google.com/drive/folders/1BJz814zcxkAc60fXu0MqOq1kPN6oz7_m?usp=sharing) I just modified this code for testing Sim800l. Please look into the Google drive @KenLagoni Sir.

If so, could you perhaps send the output from this when it is working? :-) (Remember that the Baudrate must be set to 115200 in the "thinkspeak" code because we changed it on the SIM800L).

Ok, I will do it now and give an update on this.

Thank you @KenLagoni Sir

KenLagoni commented 2 years ago

Change: "gprsSerial.begin(9600); // the GPRS baud rate " to: gprsSerial.begin(115200); // the GPRS baud rate

And sent me the serial output.

mohanbabi commented 2 years ago

image

Sir in serial monitor information is not copying, that is why I am sending the image.

mohanbabi commented 2 years ago

but baud rate at 9600 output is very clear and IP address also assign Sir now in this experiment, IP is not assing, Sir. I do not know why.😔 can I test the same code with 9600 baud rate @KenLagoni Sir

KenLagoni commented 2 years ago

It doesn't look good. There are many wrong characters.

Is this with baudrate 115200 ?

but baud rate at 9600 output is very clear sir.

Do you mean that there are not that many wrong charactors?

Is it the same SIM800L you are using for "thinkspeak" and MavlinkGPRS ?

Can you take a picture of the wire setup?

now in this experiment, IP is not assing, Sir. I do not know why.😔 can I test the same code with 9600 baud rate

Yes try with 9600 and see if it works. It fails the same place MavlinkGPRS does (unable to bring up wireless connection with AT+CIICR)

KenLagoni commented 2 years ago

Just to be sure, please set the Serial debug baudrate and console to the same 57600. This is propperly not relevant since Serial is USB. But just to be sure: image

image

KenLagoni commented 2 years ago

Try Manually going through these commands in this order: AT AT+CPIN? AT+CREG? AT+CGATT? AT+CIPSHUT AT+CHIPSTATUS AT+CIPMUX=0 AT+CSTT="airtelgprs.com" AT+CIICR AT+CIFSR

mohanbabi commented 2 years ago

Screenshot (273) Screenshot (274)

mohanbabi commented 2 years ago

Try Manually going through these commands in this order:

I will do sir

KenLagoni commented 2 years ago

image Same error.

You are not able to get a GPRS connection... just to be clear, you have the antenna mounted on SIM800L?

Can you provide a picture of the setup? - there is something wrong with the serial part, you get to many wrong charactors.

mohanbabi commented 2 years ago

image now I am trying sir