Show Posts
Pages: [1] 2 3
1  Using Arduino / Networking, Protocols, and Devices / Re: Cellular shield to google spreadsheet on: April 10, 2013, 09:03:03 am
Hi spatula,

Do you know how to implement that? to negotiate with TLS with using cellular shield (SM5100B, from sparkfun)

Many thanks.
2  Using Arduino / Networking, Protocols, and Devices / Cellular shield to google spreadsheet on: April 07, 2013, 11:38:03 am
Hi, currently I'm going to passing the data from cellular shield to google spreadsheet. But through the online tutorial, I found that the URL of google spreadsheet had change and think might this cause the code not working??(I tried but nothing update to the spreadsheet)

Does anyone know what's the code to solve this problem?

Code:
   String data;
    data+="";
    data+="entry.298674415=";
    data+="12345";
    data+="&entry.1341542147=";
    data+="67890";
    data+="&submit=Submit";

    cell.print("POST /forms/d/");
    cell.print(formkey);
    cell.print("formResponse?");
    cell.println(" HTTP/1.1");
    cell.println("Host: docs.google.com");
    cell.println("Content-Type: application/x-www-form-urlencoded");
    cell.print("Content-Length: ");
    cell.println(data.length());
    cell.println("");
    cell.print(data);
    cell.println("");
3  Using Arduino / Networking, Protocols, and Devices / Re: Connect to TCP server with cellular shield on: March 23, 2013, 10:30:39 am
I just found this example but I couldn't get the GSM connected.
I using the example "GsmCosmClient"
https://github.com/BlueVia/Official-Arduino

I only can see the serial monitor keep showing "not connected". I have no idea what if going on.
Please help.

(p/s: Now I try to use GSM connect to cosm.com and send the data to cosm.com)

Many thanks.
4  Using Arduino / Networking, Protocols, and Devices / Re: Connect to TCP server with cellular shield on: March 22, 2013, 01:32:00 am
Quote
Oops! Google Chrome could not connect to 172.194.38.151
Try this ip: 74.125.227.127
[/quote]

It give me the same result as before.
 smiley-cry
5  Using Arduino / Networking, Protocols, and Devices / Re: Connect to TCP server with cellular shield on: March 21, 2013, 01:24:09 am
You should start with some well-known public address (e.g., google.com), just to see if the rest of your code works as expected.

I tried to change the IP to the IP of www.google.com.sg, but I still get the same result as before.


RESPONSE: OK
Configuring TCP connection to server
COMMAND: AT+SDATACONF=1,"TCP","172.194.38.151"

RESPONSE:
+CME ERROR: 4
ERROR: Unknown
RESPONSE: +CME ERROR: 4

RESPONSE:
+CME ERROR: 28
ERROR: Unknown
RESPONSE: +CME ERROR: 28
 
This mean my code is not working?
6  Using Arduino / Networking, Protocols, and Devices / Re: Connect to TCP server with cellular shield on: March 20, 2013, 11:18:14 pm
You should try with the address of an external (public) host.

So the address of the external host is my laptop own IP address or the IPv4 Default Gateway adddress?

7  Using Arduino / Networking, Protocols, and Devices / Connect to TCP server with cellular shield on: March 20, 2013, 09:07:56 am
Hi, Now I'm trying to get the cellular shield to connect to a TCP server in order to transmit the data to it.
But I can't get the TCP server connect. May I know is the code below have problem or the problem is from the TCP server?

Code:
#include <PString.h>
#include <SoftwareSerial.h>

SoftwareSerial cell(2,3);

const int ERROR_GPS_UNAVAIL  = 0;
const int ERROR_GPS_STALE    = 1;
const int ERROR_SIM_UNAVAIL  = 2;
const int ERROR_GPRS_FAIL    = 3;
const int ERROR_NETWORK_FAIL = 4;
const int ERROR_HOST         = 5;
const int ERROR_GPRS_UNKNOWN = 6;
const int ERROR_GSM_FAIL     = 7;
const boolean DEBUG          = true;

#define BUFFSIZE 90
 
char at_buffer[BUFFSIZE];
char buffidx;
int firstTimeInLoop = 1;
int continueLoop = 0;

int GPRS_registered;
int GPRS_AT_ready;

static void error(const int errorCode) {
  int flashTimes = 0;
  int i = 0;
  boolean severity = true;

  switch(errorCode) {
    case ERROR_GPS_UNAVAIL:
      Serial.println("ERROR: GPS Unavailable");
      // This error is not severe enough to break the main loop
      severity = false;
      break;
    case ERROR_SIM_UNAVAIL:
      Serial.println("ERROR: SIM Unavailable");
      break;
    case ERROR_GPRS_FAIL:
      Serial.println("ERROR: Connection to network failed");
      break;
    case ERROR_NETWORK_FAIL:
      Serial.println("ERROR: Could not connect to network");
      break;
    case ERROR_HOST:
      Serial.println("ERROR: Could not connect to host");
      break;
    case ERROR_GPRS_UNKNOWN:
      Serial.println("ERROR: Unknown");
      break;
    case ERROR_GSM_FAIL:
      Serial.println("ERROR: GSM Timeout");
      break; 
  }
}
 
void setup()
{
  //Initialize serial ports for communication.
Serial.begin(9600);
cell.begin(9600);
Serial.println("Starting SM5100B Communication...");
}

void loop() {
  if (firstTimeInLoop) {
    firstTimeInLoop = false;
    Serial.println("Establishing Connection");
    establishNetwork();

  }

  bool newdata = false;
  unsigned long start = millis();

  // Send data to cell network
  sendData("12345");

  delay(1000);
}

/*
 * store the serial string in a buffer until we receive a newline
 */
void readATString(boolean watchTimeout = false) {
  char c;
  char buffidx = 0;
  int time = millis();

  while (1) {
    int newTime = millis();

    if (watchTimeout) {
      // Time out if we never receive a response   
      if (newTime - time > 30000) error(ERROR_GSM_FAIL);
    }

    if (cell.available() > 0) {
      c = cell.read();
      if (c == -1) {
        at_buffer[buffidx] = '\0';
        return;
      }

      if (c == '\n') {
        continue;
      }

      if ((buffidx == BUFFSIZE - 1) || c == '\r') {
        at_buffer[buffidx] = '\0';
        return;
      }

      at_buffer[buffidx++] = c;
    }
  }
}

/**
 * Send an AT command to the cell interface
 */
static void sendATCommand(const char* ATCom) {
  cell.println(ATCom);
  Serial.print("COMMAND: ");
  Serial.println(ATCom);

  while (continueLoop) {
    readATString();
    ProcessATString();
    Serial.print("RESPONSE: ");
    Serial.println(at_buffer);
  }

  continueLoop = true;
  delay(500);
}

/*
 * Handle response codes
 */
static void ProcessATString() {

  if (DEBUG) {
    Serial.println(at_buffer);
  }

  if (strstr(at_buffer, "+SIND: 1" ) != 0) {
    firstTimeInLoop = true;
    GPRS_registered = false;
    GPRS_AT_ready = false;

    // GPS unit pulls enough current to keep the GSM shield from starting
    // So we wait until it's initialized and then power it via a digital pin
 //   digitalWrite(GPS_RELAY, HIGH);
  }

  if (strstr(at_buffer, "+SIND: 10,\"SM\",0,\"FD\",0,\"LD\",0,\"MC\",0,\"RC\",0,\"ME\",0") != 0
    || strstr(at_buffer, "+SIND: 0") != 0) {
    error(ERROR_SIM_UNAVAIL);
  }

  if (strstr(at_buffer, "+SIND: 10,\"SM\",1,\"FD\",1,\"LD\",1,\"MC\",1,\"RC\",1,\"ME\",1") != 0) {
    Serial.println("SIM card Detected");
//    successLED();
  }

  if (strstr(at_buffer, "+SIND: 7") != 0) {
    error(ERROR_NETWORK_FAIL); 
  }

  if (strstr(at_buffer, "+SIND: 8") != 0) {
    GPRS_registered = false;
    error(ERROR_GPRS_FAIL);
  }

  if (strstr(at_buffer, "+SIND: 11") != 0) {
    GPRS_registered = true;
    Serial.println("GPRS Registered");
 //   successLED();
  }

  if (strstr(at_buffer, "+SIND: 4") != 0) {
     GPRS_AT_ready = true;
     Serial.println("GPRS AT Ready");
//     successLED();
  }

  if (strstr(at_buffer, "+SOCKSTATUS:  1,0") != 0) {
     error(ERROR_HOST);
  }

  if (strstr(at_buffer, "+CME ERROR: 29") != 0) {
    continueLoop = false;
    return;
  }

  if (strstr(at_buffer, "+CME ERROR") != 0) {
    error(ERROR_GPRS_UNKNOWN);
  }

  if (strstr(at_buffer, "OK") != 0 || strstr(at_buffer, "NO CARRIER") != 0) {
    continueLoop = false;
 //   successLED();
  }

  if (strstr(at_buffer, "+SOCKSTATUS:  1,1") != 0) {
    continueLoop = false;
  }
}

static void establishNetwork() {
  while (GPRS_registered == false || GPRS_AT_ready == false) {
    readATString(true);
    ProcessATString();
  }
}

static void sendData(const char* data) {
//  digitalWrite(LED_STATUS, HIGH);

  Serial.println("Setting up PDP Context");
  sendATCommand("AT+CGDCONT=1,\"IP\",\"wap.cingular\"");

  Serial.println("Configure APN");
  sendATCommand("AT+CGPCO=0,\"\",\"\", 1");

  Serial.println("Activate PDP Context");
  sendATCommand("AT+CGACT=1,1");

  // Change 0.0.0.0 to reflect the server you want to connect to
  Serial.println("Configuring TCP connection to server");
  sendATCommand("AT+SDATACONF=1,\"TCP\",\"127.0.0.1\",1234");

  Serial.println("Starting TCP Connection");
  sendATCommand("AT+SDATASTART=1,1");

  delay(1000);

  //Serial.println("Getting status");
  //sendATCommand("AT+SDATASTATUS=1");

  Serial.println("Sending data");
  sendATCommand(data);

  //Serial.println("Getting status");
  //sendATCommand("AT+SDATASTATUS=1");

  Serial.println("Close connection");
  sendATCommand("AT+SDATASTART=1,0");

  Serial.println("Disable PDP Context");
  sendATCommand("AT+CGACT=0,1");

}

Below is the result I obtain from serial monitor.
Starting SM5100B Communication...
Establishing Connection
   
+SIND: 1

+SIND: 10,"SM",1,"FD",1,"LD",1,"MC",1,"RC",1,"ME",1
SIM card Detected

+SIND: 3

+SIND: 11
GPRS Registered

+SIND: 4
GPRS AT Ready
Setting up PDP Context
COMMAND: AT+CGDCONT=1,"IP","wap.cingular"
Configure APN
COMMAND: AT+CGPCO=0,"","", 1

RESPONSE:
OK
RESPONSE: OK
Activate PDP Context
COMMAND: AT+CGACT=1,1

RESPONSE:
OK
RESPONSE: OK
Configuring TCP connection to server
COMMAND: AT+SDATACONF=1,"TCP","127.0.0.1",1234

RESPONSE:
OK
RESPONSE: OK
Starting TCP Connection
COMMAND: AT+SDATASTART=1,1

RESPONSE:
+CME ERROR: 28
ERROR: Unknown
RESPONSE: +CME ERROR: 28

RESPONSE:
OK
RESPONSE: OK
Sending data
COMMAND: 12345

RESPONSE:
+CME ERROR: 4
ERROR: Unknown
RESPONSE: +CME ERROR: 4

Thanks for the help.
8  Using Arduino / Project Guidance / New project with GPS on: December 18, 2012, 01:57:11 am
Hi,

Now I starting my FYP project which is using GPS technology to help in tracking the position of dementia people at the outdoor and guide them back to their living place. Now I am confuse by choosing which GPS receiver/ transmitter? I would like to have real-time tracking purpose for the system. Hope someone can help. Thanks.

Regards,
Hong
9  Using Arduino / Programming Questions / Re: Speed up arduino on: April 19, 2012, 05:00:47 am

Sorry for the typo.      smiley-eek-blue

10  Using Arduino / Programming Questions / Re: Speed up arduino on: April 19, 2012, 04:11:01 am
Sorry for the misleading.

My whole project is building an automated system with realtime feedback from the force sensors and hall sensor.
The system is build in matlab simulink already and now I am code it into arduino. It's important to have the feedback from the force sensor as fast as possible to allow the system to responce immediately. By the time, the sampling rate have to be high to avoid of lost counting from tha hall sensor. The position feedback is a main criteria of the system as well.

Now I'm trying with the code from Nick Gammon and Fletcher to combine with the main code of my system.



Many thanks for the help =)
11  Using Arduino / Programming Questions / Re: Speed up arduino on: April 18, 2012, 05:59:43 am
Quote
when without signal read in, the sampling rate is 888Hz, with the signal read in the sampling rate drop to 780Hz.

I had change the baud rate to 115200, and take out all delay and serial.print and come up with the frequency as above.
12  Using Arduino / Programming Questions / Re: Speed up arduino on: April 18, 2012, 05:15:12 am
Quote
Now as PaulS suggested, do all your calculations on the computer (not the Arduino) so you don't slow down the sampling rate. You can see that you would have a maximum of about 66 uS to do calculations before you started to slow it down.

I'm just using arduino to deal with the calculation without computer help


I had combine some code form ethernet shield and add in the code from AWOL from another discussion(http://arduino.cc/forum/index.php/topic,101718.msg763256.html#msg763256),  when without signal read in, the sampling rate is 888Hz, with the signal read in the sampling rate drop to 780Hz.

So if I use another ADC to deal with the analog signal and using only the digitalRead() of the arduino, this will increase the sampling rate right?
(but I'm not familiar on how to give the clock input for the ADC)



Many thanks~~~
13  Using Arduino / Programming Questions / Re: Speed up arduino on: April 18, 2012, 04:09:58 am
Hi Nick Gammon,

Sorry that I'm not understand about the code

Here is my original code,
Code:
int fsrPin = 0;     // the FSR and 10K pulldown are connected to a0
int fsrReading;     // the analog reading from the FSR resistor divider
int fsrVoltage;     // the analog reading converted to voltage
unsigned long fsrResistance;  // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance;
long fsrForce;       // Finally, the resistance converted to force
 
void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
}
 
void loop(void) {
  fsrReading = analogRead(fsrPin); 
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
 
  // analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
  fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
  Serial.print("Voltage reading in mV = ");
  Serial.println(fsrVoltage); 
 
  if (fsrVoltage == 0) {
    Serial.println("No pressure"); 
  } else {
    // The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
    // so FSR = ((Vcc - V) * R) / V        yay math!
    fsrResistance = 5000 - fsrVoltage;     // fsrVoltage is in millivolts so 5V = 5000mV
    fsrResistance *= 10000;                // 10K resistor
    fsrResistance /= fsrVoltage;
    Serial.print("FSR resistance in ohms = ");
    Serial.println(fsrResistance);
 
    fsrConductance = 1000000 / fsrResistance;           // we measure in micromhos so
    Serial.print("Conductance in microMhos: ");
    Serial.println(fsrConductance);
 
    // Use the two FSR guide graphs to approximate the force
    if (fsrConductance <= 100)                  //range 0-2N
    {
      fsrForce = fsrConductance / 20;
      Serial.print("Force in Newtons: ");
      Serial.println(fsrForce);     
    }
   
    else
    {
      fsrForce = fsrConductance / 50;                //range 80N-100N
      Serial.print("Force in Newtons: ");
      Serial.println(fsrForce);           
    }
   
 
  }
  Serial.println("--------------------");
  delay(1000);
}

How can I combine the code as given by you?
14  Using Arduino / Programming Questions / Re: Speed up arduino on: April 17, 2012, 06:44:14 am
Thanks a lot for the information.

Now I have frequency of 1.2kHz with three analog input and two digital input.

In before I notice that just 120Hz is because I had put "Serial.print" in the program. After take out the serial print to the serial monitor, it getting faster.

In the other case, I have to connect an ethernet shield to my mega 2560, with that I worry that in the end the sampling rate for the system will go below 1kHz.This is the reason I would like to use ADC in my project.
15  Using Arduino / Project Guidance / Re: Use of A/D converter on: April 17, 2012, 06:26:58 am
What are you trying to minimise - the latency in getting the value, or the wasted processing time if your sketch waits while the conversion occurs?

I would like to minimise the latency in getting the value.
Pages: [1] 2 3