Jump to content
43oh

Sana95

Members
  • Content Count

    7
  • Joined

  • Last visited

Posts posted by Sana95

  1. I haven't yet included the ping function of the sensors yet. once the database accepts these dummy values i can incorporate the function into the code as well. as of now, the cc3200 connects periodically to the server, but as i mentioned, the server returns only an error message. i am trying to update the value of a particular variable in the database.

  2. Hi, I'm using heroku to host my server which is coded using ruby on rails. the server returns an error message. code 500 and the logs state that the template isn't found.

     

    Yeah, I just used the example as a base to build my own application as i'm just starting off with the cc3200. 
    The current code is:

    #ifndef __CC3200R1M1RGC__
    // Do not include SPI for CC3200 LaunchPad
    #include <SPI.h>
    #endif
    #include <WiFi.h>
     
     
    const int pingPin = 1;
    // your network name also called SSID
    char ssid[] = "samiya";
    // your network password
    char password[] = "samiya95";
     
    // Initialize the Wifi client library
    WiFiClient client;
     
    // server address:
    char server[] = "autosewage.herokuapp.com";
    //IPAddress server(50,62,217,1);
     
    unsigned long lastConnectionTime = 0;            // last time you connected to the server, in milliseconds
    const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
    long cm=50;
     
     
    void setup() {
      //Initialize serial and wait for port to open:
      Serial.begin(115200);
     
      // attempt to connect to Wifi network:
      Serial.print("Attempting to connect to Network named: ");
      // print the network name (SSID);
      Serial.println(ssid); 
      // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
      WiFi.begin(ssid, password);
      while ( WiFi.status() != WL_CONNECTED) {
        // print dots while we wait to connect
        Serial.print(".");
        delay(300);
      }
      
      Serial.println("\nYou're connected to the network");
      Serial.println("Waiting for an ip address");
      
      while (WiFi.localIP() == INADDR_NONE) {
        // print dots while we wait for an ip addresss
        Serial.print(".");
        delay(300);
      }
     
      Serial.println("\nIP Address obtained");
      // We are connected and have an IP address.
      // Print the WiFi status.
      printWifiStatus();
    }
     
    void loop() {
      // if there's incoming data from the net connection.
      // send it out the serial port.  This is for debugging
      // purposes only:
      while (client.available()) {
        char c = client.read();
        Serial.write©;
      }
     
      // if ten seconds have passed since your last connection,
      // then connect again and send data:
      if (millis() - lastConnectionTime > postingInterval) {
        httpRequest();
      }
     
    }
     
    // this method makes a HTTP connection to the server:
    void httpRequest() {
      // close any connection before send a new request.
      // This will free the socket on the WiFi shield
      client.stop();
     
      // if there's a successful connection:
      if (client.connect(server, 80)) {
        Serial.println("connecting...");
        // send the HTTP PUT request:
        client.println("PUT /treatment_plants HTTP/1.1");
        client.println("Host: autosewage.herokuapp.com");
        //client.println("User-Agent: Energia/1.1");
        client.print("Content-Length: ");
     
        // calculate the length of the sensor reading in bytes:
        // 8 bytes for "sensor1," + number of digits of the data:
        int thisLength = 4;
        client.println(thisLength);
     
        // last pieces of the HTTP PUT request:
        client.println("Accept :text/plain");
        client.println("Content-Type: text/csv");
        client.println("Connection: close");
        client.println();
        
         client.print(pingPin);
        client.print(",");
        client.println(cm);
      
      
      
        // note the time that the connection was made:
        lastConnectionTime = millis();
      }
      else {
        // if you couldn't make a connection:
        Serial.println("connection failed");
      }
    }
     
     
    void printWifiStatus() {
      // print the SSID of the network you're attached to:
      Serial.print("SSID: ");
      Serial.println(WiFi.SSID());
     
      // print your WiFi IP address:
      IPAddress ip = WiFi.localIP();
      Serial.print("IP Address: ");
      Serial.println(ip);
     
      // print the received signal strength:
      long rssi = WiFi.RSSI();
      Serial.print("signal strength (RSSI):");
      Serial.print(rssi);
      Serial.println(" dBm");
    }
  3. Hi, 
    I'm trying to read in data from my sensor and then send it to my server over Wifi. I am not very sure about the best format to send numerical data. the CC3200 is the client that periodically sends values to the server. The server is being built using Ruby on Rails with HTTP and TCP.
    There also seems to be some ambiguity about the usage of the GET method. Is the PUT method a better choice? if so, what would be the correct format to send the data??

    The code I'm working with:
     

    #ifndef __CC3200R1M1RGC__
    // Do not include SPI for CC3200 LaunchPad
    #include <SPI.h>
    #endif
    #include <WiFi.h>
     
    const int pingPin = 7;
     
    // your network name also called SSID
    char ssid[] = "energia";
    // your network password
    char password[] = "launchpad";
     
    // Initialize the Wifi client library
    WiFiClient client;
     
    // server address:
    char server[] = "energia.nu";
    //IPAddress server(50,62,217,1);
     
    unsigned long lastConnectionTime = 0;            // last time you connected to the server, in milliseconds
    const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
      long duration, cm;
     
     
    void setup() {
      //Initialize serial and wait for port to open:
      Serial.begin(115200);
        
     
      // attempt to connect to Wifi network:
      Serial.print("Attempting to connect to Network named: ");
      // print the network name (SSID);
      Serial.println(ssid); 
      // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
      WiFi.begin(ssid, password);
      while ( WiFi.status() != WL_CONNECTED) {
        // print dots while we wait to connect
        Serial.print(".");
        delay(300);
      }
      
      Serial.println("\nYou're connected to the network");
      Serial.println("Waiting for an ip address");
      
      while (WiFi.localIP() == INADDR_NONE) {
        // print dots while we wait for an ip addresss
        Serial.print(".");
        delay(300);
      }
     
      Serial.println("\nIP Address obtained");
      // We are connected and have an IP address.
      // Print the WiFi status.
      printWifiStatus();
     
     
      Serial.begin(9600);
    }
     
    void loop() {
      // if there's incoming data from the net connection.
      // send it out the serial port.  This is for debugging
      // purposes only:
      while (client.available()) {
        char c = client.read();
        Serial.write
  4. http://processors.wiki.ti.com/index.php/CC32xx_Quick_Start_Guide?DCMP=cc3100cc3200&HQS=cc3200launchpadstart
    I found this link to be pretty useful regarding the cc3200 when i started.
     

    Sample code for the startSmartConfig: taken from a forum example

     

    #include <SPI.h>
    #include <WiFi.h>

    void setup()
    {
    Serial.begin(115200);

    Serial.println("Starting WiFi SmartConfig");
    WiFi.startSmartConfig();

    Serial.print("Connected to SSID: ");
    Serial.println(WiFi.SSID());

    while (WiFi.localIP() == INADDR_NONE) {
    // print dots while we wait for an ip addresss
    Serial.print(".");
    delay(300);
    }

    Serial.println("\nIP Address obtained");
    Serial.print("IP Address: ");
    Serial.println(WiFi.localIP());
    }

    void loop()
    {
    // Noting to do
    }

  5. I am essentially trying to connect an External LED and execute the Blink example pre loaded in Energia on it instead of the inbuilt LED.
    This is the code I was trying to use. I also used the internal LED to check if the code was working or not.

    With regard to the connections, i connected the LED, to a resistor and then connected it to PIN_50. the circuit was completed by connecting the other end of the LED, to the Gnd.

    #define L GREEN_LED
    
    
    void setup()
    {
      // put your setup code here, to run once:
      pinMode(PIN_50, OUTPUT);
      pinMode(L, OUTPUT);
      //digitalWrite(PIN_50, LOW);
    }
    
    
    void loop()
    {
      // put your main code here, to run repeatedly:
      digitalWrite(L,HIGH);
     digitalWrite(PIN_50, HIGH);
      delay(200);
      digitalWrite(L,LOW);
     digitalWrite(PIN_50, LOW);
      delay(200); 
      
    }
  6. Hi,

    I am just getting started with CC3200 and Energia for my very first project. I wanted to know if it's possible to use pinmux to configure pins of the cc3200 on Energia? if yes/no, what is the procedure/alternative? 

×
×
  • Create New...