Sinamics
wow. great job m8. You are really close. You cant use "AT+CIPSERVER=1,1234" while trying to open UDP stream. "AT+CIPSERVER=1,1234" are only for TCP protocoll. I see i have posted that in my code, but it is wrong. i will change that. You dont need to open any ports to get OK from this. It should start UDP anyway.
frejus
AT+CIPSTART="UDP","philgib.ddns.net","14550" OK CONNECT Yup !!!! Now if I disconnect it from my PC and connect it to the APM, the settings won"t be saved right ? Should I type in a command to save all those settings ? I mean once the UDP connection starts, I cannot even type ATWR to save all parameters... Do you think I could create a startup file to run when modem is powered on ?
Sinamics
great work.. Correct, your settings wont be saved. You need to power the dronecell from your lipo. That way you could disconnect from your laptop and still keep the dronecell alive. Connect tx/rx to apm and whoila.. you should then be able to retrive the telemetry on your laptop if you have open the correct ports in router. The only way to create a autoamtically boot up with AT commands, is to add all syntax to APM software and send them to dronecell during boot up.
frejus
Posted By: Sinamics The only way to create a autoamtically boot up with AT commands, is to add all syntax to APM software and send them to dronecell during boot up. Yes that is very clear. I wonder if there could not be a boot file on the SIM900 side. So that is my next learning chapter the coming week : know how to program, compile and add to the APM. I know how to program in PHP or javascript, hopefully it won't be super complicated. But anyway this is so super interesting ! http://dev.ardupilot.com/wiki/where-to-get-the-code/ Sinamics I want to thank you again for your amazing help and kindess. I learnt a lot from you.
Sinamics
No problem m8..
frejus
Hey, Did you experiment any communication problem with Mission Planner such as time-outs ? Did you have to lower any transmission settings ? Thank you
Sinamics
Hi again.. No. It should work out of the box.. :) no need for tweaking. MP will timeout if no telemetry stream are found. Check the following: Correct port has been chosen in MP Correct baud rate has been chosen in MP Your router has that port open, and forwarded to your laptop IP adresss.
frejus
Thx :-)
frejus
OK, I have just purchased an arduino, a few leds, and I learnt to upload a little progrm from Blink to switch lights on, etc... Fewww, that was a learning curve ! Now I have to learn your way of uploading those files into the APM to make the SIM900 work from the APM :-) Do you think that you could give me a hint ? I REALLY would love to try that UDP telemetry... Thank you xxx PS : I think I am not so lucky with the SIM900a I purchased, I have the feeling I need extra libraries for it as AT commands do not work through the Arduino, and I spend too many hours trying to figure out. I have contacted the provider for those libraries, so beware if you intend to purchase that one...
Sinamics
Hi xxx PS : I think I am not so lucky with the SIM900a I purchased, I have the feeling I need extra libraries for it as AT commands do not work through the Arduino, and I spend too many hours trying to figure out. I have contacted the provider for those libraries, so beware if you intend to purchase that one... That odd, Serial communction is a standard communication protocoll which are equal for Arduino as on your laptop. Serial data stream is only a string of bytes, and i belive your sim900a should work with arduino the same way as when you use your computer. Please post your Arduino code and i can check. Arduino is really cool to work with. C, lanuage is acutally not so bad to understand either.. What i did was just to put every line of at commands in a new function with a desired sleep time between the lines. ( very ugly way of doing it ). If you should programilly achieve this the correct way, you should send AT command from APM board and the code should wait until it get`s OK from the dronecell before its moving on to the next line(at command). This is the code i was using in THIS video. as said, this is pretty ugly code, but it will work. Im used this line for power on the Dronecell automatically. This will sett the (if i remeber correct) Pin 1 high on the AMP board. digitalWriteFast(COPTER_LED_1, COPTER_LED_ON); static void modem() { if (0 == modem_ready) { delay (3500); digitalWriteFast(COPTER_LED_1, COPTER_LED_ON); // A4 = COPTER_LED_1 = Modem ON A5 = COPTER_LED_2 osv Serial2.begin(57600); //delay (1500); // hal.uartA->println("+++~~~~ATH0"); // Break into channel if there is an existing connection // delay (1500); Serial2.println("AT V1 E1 X1 S0=0"); // Set error response and do not pickup on ring delay (1500); Serial2.println("AT+CREG=2"); // Set various notice messages and parameters delay (1500); Serial2.println("AT+CMEE=2"); delay (1500); Serial2.println("AT+CR=1"); delay (1500); Serial2.println("AT+CRC=1"); delay (1500); Serial2.println("AT+CSNS=4"); delay (1500); Serial2.println("AT+CSMINS=1"); delay (1500); Serial2.println("AT+CSCLK=0"); delay (1500); Serial2.println("AT+CIURC=1"); delay (1500); Serial2.println("AT+CGEREP=2"); delay (1500); Serial2.println("AT+CIPMUX=0"); delay (1500); Serial2.println("AT+CIPMODE=1"); delay (1500); Serial2.println("AT+CIPCCFG=8,15,15,0"); delay (1500); Serial2.println("AT+CMUX=0,0,4,127,10,3,30,10,2"); delay (3500); Serial2.println("AT+CSTT=\"internet.public\""); //set APN delay (3500); Serial2.println("AT+CIICR"); //open GPRS delay (3500); Serial2.println("AT+CIFSR"); // Get local IP address delay (3500); Serial2.println("AT+CIPSTART=\"UDP\",\"Dyn_DNS\",\"14550\""); // Start the UDP server modem_ready = 1; } } Then you could do simething like this in the Main code to call the Modem function. // 1Hz loop static void super_slow_loop(){ // Added for for Modem if (ap_system.usb_connected){ return; } else { if (0 == modem_ready){ modem(); } }
frejus
I wonder... Wouldn't there be an easier solution to have the code externalised from the APM, i.e. arduino and modem, arduino containing all the connection code ? That way no matter the APM firmware update, the connection would always work without modifying anything again and again. And it would work for any mavlink connection I guess, so compatible with FY41, etc...
Sinamics
Hi Sure that will be possible, and maybe the best solution. The reason why im using APM is simply becouse of the extra weight you will get when adding another board the the aircraft.
frejus
So the extra weight would be the arduino nano + cables right, so maybe 10 grams extra ? Here is a link of someone who did it http://diydrones.com/profiles/blog/show?id=705844%3ABlogPost%3A1819556&xg_source=activity&page=2#comments and the link of the same code "cleaned" https://gist.github.com/billbonney/0bbb90699f6d36f853d1 See if you like it... There is an extra line that I did not see before : while (! sendATCommand ( "AT+CLPORT=\"UDP\",8888" , "OK" , 100 )); I have built the red and green leds, will give it a try, unless you see a better code to play with ? Cheers
Sinamics
hehe 10grams will not effect the flying time im supose. That code should definitely do the job correctly. Im looking forward to see the result you get. I never seen the AT+CLPORT either, but i assume this will have the same effect as CIPSTART
frejus
Hmmm... Testing that code. It does not pass the test of line 44 (it goes into the "Else" direction) if (b. indexOf ( "+CREG: 1" ) > 0 || b. indexOf ( "+CREG: 2" ) > 0 ){ If I do manually AT+CREG? on my modem, I obtain : +CREG: 2,1,"60E2","E62B"
Sinamics
What is the respons of this code AT+CREG=1 Or this AT+CREG=2
frejus
AT+CGREG=1 OK AT+CGREG=2 OK
frejus
OK, when setting everything on 19200 bds, I now have the fixed green light, should mean that the modem is connected, but in 19200bds. Now I guess I should tell the APM to communicate to the arduino / modem at 19200 bds right ? Not sure how...
Sinamics
I believe you could change the baud rate in mission planner ( Advanced paramter list)
frejus
Hey Sinamics, How are you ? Need some help again please. Arduino Uno works fantastically with the SIM900. But I am stocked : it keeps on looping and does not enter positively into mySerial test (line 133) and serial test (line 154) of the program here : https://gist.github.com/billbonney/0bbb90699f6d36f853d1 Here is my diagram.... I have not put yet the power pin and the reset pin, I do not think that this is necessary at the moment.