SM5100B & MySQL

Hi Everyone,

I am developing a remote data system for household wind turbines for the Balkans. As a part of our pilot project we will be putting up weather stations that are powered by solar panels. We are using an Arduino Uno and a SM5100B shield to transmit all of our sensor data. The collection of data we have down, but transmitting it to our server is proving more difficult, which has PHP and MySQL installed. I would like to take our data and pass in to our MySQL server, probably through php. Initially I had come up with the idea of using the php parameter parse function which I thought was very straightforward and simple. You call up http://site.com/datSend.php?UTC=XXX&wMin=XXX&wMax=XXX and the php script would parse the values and insert into our database,. The nice part is that this method takes the load off the arduino immediately and puts it on the server.

The problem is that I have no idea how to connect to the site. I’ve tried the following but I get errors

AT+CGATT?
AT+CGDCONT=1,"IP","epc.tmobile.com"
AT+CGACT=1,1
AT+SDATACONF=1,"TCP","www.kosovowind.com/database/datSend.php?UTC=RightNow&LocID=1&wMin=1&wAvg=2&wMax=3",80  //Error Here
AT+SDATASTART=1,1
AT+SDATASTATUS=1

I am using Terminal v1.9 for testing before I get into writing the code. I am a Mechanical Engineering student so coding isn’t my forte but I do have a Computer Science student working with me.

Thank you,

Josh Turner

The proper way to format your HTTP request would be to send three lines, the third line being empty (just a carriage return):

GET /database/datSend.php?UTC=RightNow&LocID=1&wMin=1&wAvg=2&wMax=3 HTTP/1.0
Host: www.kosovowind.com

I’d encourage you to test this with a telnet session to understand what the data looks like. This is what you should see:

root@myhost:# telnet http://www.kosovowind.com 80

Trying 184.168.137.128…

Connected to kosovowind.com.

Escape character is ‘^]’.

GET /database/datSend.php?UTC=RightNow&LocID=1&wMin=1&wAvg=2&wMax=3 HTTP/1.0
Host: http://www.kosovowind.com

HTTP/1.1 200 OK

Date: Mon, 25 Apr 2011 13:51:42 GMT

Server: Apache

X-Powered-By: PHP/5.2.17

Connection: close

Content-Type: text/html

Send Data

RightNow
1
2
3
Complete

Connection closed by foreign host.

FYI: This forum keeps sticking a “http://” in front of “www.kosovowind.com”. It should not be there.

I must be doing something wrong but I get 404 errors everytime I try to request any of my pages, this might because I am using Win7 Telnet and I can’t figure out how to add lines to the command. Also I’ve tried Putty but it crashes after I enter the third line.

EDIT: Nevermind I was being stupid and figured telnet out.

After I figure out telnet how do you suggest formatting that with AT commands?

Any suggestions?

Update:

So after a little more research I found that I should be sending this command:

AT+SSTRSEND=1,"GET /database/datSend.php HTTP/1.0\r\nHost: www.kosovowind.com:80\r\n\r\n"
```This gives "+CME ERROR: 4". The following doesn't give an error it doesn't seem to work either.

AT+SSTRSEND=1,“GET /database/datSend.php HTTP/1.0”

I am still looking for help regarding this topic. I have not been able to make any more progress on this. If anyone has info on people that have made web browsers with an Arduino using a GSM modulue/AT+ commands that could be a good base.

tzontzonelro:
[Subject: SM5100B & MySQL

Did you manage the connection the SM5100B module to mysql ?
[/quote]
I received this PM and I would like to share my response to all of you.

Skierarc:
No it never worked. I tried everything it simply would not work.

I switched over to using sSerial2Mobile http://code.google.com/p/sserial2mobile/ and I do the following:

  1. Use the Motorola C168i as suggested in the library (eBay). I’ve tried newer Tracfones but finding a data cable that would work is near impossible, find phones that use the headphone/mic jack for Tx/Rx/Grnd

  2. Use the phone.SendEmail() command to send by values to an email address

  3. Parse the email using Outlook VBA, I plan on switching to a server side script to make it automatic

  4. Insert the parsed values into MySQL using ODBC (Outlook) or PHP (Server Side)

So far this method has been 100% reliable, I can even charge the phone with the 5V output on the Arduino, This really simplifies power connections. I’m having a little trouble receiving info back from the phone which I hope to fix soon. It’s great and I suggest you look into using actual phones.

Cost:

Phone: $2.00 + $8 Shipping

Audio Plug: $3

Monthly Plan: $10 - 1000 Text Messages via AT&T goPhone (new SIM card was free!)

](http://forum.sparkfun.com/viewtopic.php?p=126920#p126920)

Hi,

I did finally get this damn thing working. I guess that your problem is that when using the at+sstrsend command, the scape character is ignored i.e. \r\n does not work. Therefore you have to use the at+sdatatsend command instead.

I leave you the code that worked for me here:

cell.println("AT+SDATATSEND=1,116");
    Serial.println("AT+SDATATSEND=1,116: "); //Be careful with the size...
    EsperamosOK("> ");  //This function waits until the string is returned by the module.
  
    cell.print("GET /save_data.php?user=test&temps="+String(tempc)+"&times=20121228170000 HTTP/1.1\r\n"); // SIZE: 69
    delay(100); //This is just a precaution, it may be unnecessary
    cell.print("Host: glownt.net78.net\r\n"); // SIZE: 24
    delay(100);
    cell.print("User-Agent: Arduino\r\n\r\n"); // SIZE: 23
    delay(100);
    cell.write(26); //Ctrl+z ends the input
    Serial.println("Sent!");
    if (EsperamosOK("STCPD")==0)
      Serial.println("Something received!");

I hope this helps.

Kind regards,

Adrián.