element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sudden Impact Wearables Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Sudden Impact Wearables Design Challenge
  • More
  • Cancel
Sudden Impact Wearables Design Challenge
Blog [real_time_monitor] Real Time Player Monitoring System Post#2 : Playing with CC3200 for UDP communication
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ravi_butani
  • Date Created: 17 Dec 2014 7:35 AM Date Created
  • Views 304 views
  • Likes 2 likes
  • Comments 1 comment
  • analog_devices_inc
  • tektronix
  • sudden_impact
  • real_time_monitor
  • cc3200_launchpad
  • electrolube
Related
Recommended

[real_time_monitor] Real Time Player Monitoring System Post#2 : Playing with CC3200 for UDP communication

ravi_butani
ravi_butani
17 Dec 2014

Table of Contents

<< Previous

Next >>


In my previous post I have discussed myproject proposal....

I have selected WiFi with UDP protocol for communication, and selected CC3200 for main processing and commnication Part at sensor node...

 

So meanwhile parts for this challenge arrive... I have started to work with what I have now (CC3200 Launchpad)..


In this Post I am sharing my work for communicate CC3200 with PC/ Android cell phone using UDP.

I am using Energia IDE for CC3200 application development.

and I am using Processing for developing PC / Andoid app for remot monitoring station...

 

I have used these opensource platform by keeping in mind that all the codes are in opensource for future use.

 

Here is code for CC3200 for UDP sensor node... I am using BMA222 Accelerometer library for this demo. Which is available here https://github.com/energia/Energia/tree/master/hardware/cc3200/libraries/BMA222 ..

 

/*============================================================================
Sudden Impact Wearable Design Challenge
Real Time Player monitoring System

Energia Sketch (Running on CC3200 Launchpad)

Test Code for WiFi UDP connection between
Sensor node(CC3200 LaunchPad)and monitoring Station(Android cell phone / PC)

UDP Sender/Receiver Application used for Android cell phone
Processing application for use with PC (Linux/MacOS/Windows)

BMA222 Library used for CC3200 Launchpad on board Accelerometer interface
created 13 December 2014
by Ravi Butani


e-mail: ravi_butani@yahoo.com

Attribute : Noah Luskey for his UDP library
Code Released under CC-SA 2014 license

===========================================================================*/


#ifndef __CC3200R1M1RGC__
// Do not include SPI for CC3200 LaunchPad
#include <SPI.h>
#endif
#include <WiFi.h>
#include <Wire.h>
#include <BMA222.h>


BMA222 mySensor;
// your network name also called SSID
char ssid[] = "ravi1";
// your network password
char password[] = "11223344";


unsigned int localPort = 2390;      // local port to listen on


char packetBuffer[255]; //buffer to hold incoming packet
char ReplyBuffer[5];    // a string to send back
String str;
WiFiUDP Udp;


void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(115200);

  // attempt to connect to Wifi network:
  Serial.println("====Sudden Impact Wearable Design Challenge====");
  Serial.println("=======Real Time Player Monitoring System======");
  Serial.println("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");
  printWifiStatus();
  mySensor.begin();
  uint8_t chipID = mySensor.chipID();
  Serial.print("chipID: ");
  Serial.println(chipID);
  Serial.println("\nWaiting for a connection from a remote monitoring Station...");
  Udp.begin(localPort);
}


void loop() {
  int8_t datax,datay,dataz;

  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remoteIp = Udp.remoteIP();
    Serial.print(remoteIp);
    Serial.print(", port ");
    Serial.println(Udp.remotePort());


    // read the packet into packetBufffer
    int len = Udp.read(packetBuffer, 255);
    if (len > 0) packetBuffer[len] = 0;
    Serial.println("Contents:");
    Serial.println(packetBuffer);
    // once connected with remote monitoring station send accelerometer data continuously
    while(1)
    {
      datax = mySensor.readXData();
      datay = mySensor.readYData();
      dataz = mySensor.readZData();
      Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
      str=String(datax); //converting integer into a string
      str.toCharArray(ReplyBuffer,5);
      Udp.write("X=");
      Udp.write(ReplyBuffer);
      str=String(datay); //converting integer into a string
      str.toCharArray(ReplyBuffer,5);
      Udp.write("\tY=");
      Udp.write(ReplyBuffer);
      str=String(dataz); //converting integer into a string
      str.toCharArray(ReplyBuffer,5);
      Udp.write("\tZ=");
      Udp.write(ReplyBuffer);
      Udp.endPacket();
      delay(200); // just to visulize readings on serial port
    }
  }
}




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");
}

 

Once above energia sketch loaded on CC3200... I have Used my cell phone as hot spot to connect CC3200 sensor node and PC/Android cell phone(Remote monitoring Station)..

 

For testing received Data on Android phone I have used UDP Sender/Receiver android application available on google play store https://play.google.com/store/apps/details?id=com.jca.udpsendreceive&hl=en

Here is snapshot of received UDP packets on my android cell phone...

image

 

This is processing sketch for test UDP packets on PC running on (Linux/MAC/Windows)

 

/*============================================================================
Sudden Impact Wearable Design Challenge
Real Time Player monitoring System

Processing Sketch (running on PC)

Test Code for Wifi UDP connection between
Sensor node(CC3200 LaunchPad)and monitoring Station(Android cell phone / PC)

UDP Sender/Receiver Application used for Android cell phone
Processing application for use with PC (Linux/MacOS/Windows)

BMA222 Library used for CC3200 Launchpad on board Accelerometer interface
created 13 December 2014
by Ravi Butani

 e-mail: ravi_butani@yahoo.com

Attribute : Cousot stephane for The Atelier Hypermedia
            http://hypermedia.loeil.org/processing/

Code released under CC-SA  2014 license
===========================================================================*/





// import UDP library
import hypermedia.ne.*;




UDP udp;  // define the UDP object


/**
* init
*/
void setup() {


  // create a new datagram connection on port 6000
  // and wait for incomming message
  udp = new UDP( this, 2390 );
  udp.listen( true );
}


//process events
void draw() {
    String message  = "hii";  // the message to send
    String ip      = "192.168.43.134";  // the remote IP address
    int port        = 2390;    // the destination port

    // formats the message for Pd
    message = message+";\n";
    // send the message
    udp.send( message, ip, port );
    while(true)
    {;}
}


/**
* To perform any action on datagram reception, you need to implement this
* handler in your code. This method will be automatically called by the UDP
* object each time he receive a nonnull message.
* By default, this method have just one argument (the received message as
* byte[] array), but in addition, two arguments (representing in order the
* sender IP address and his port) can be set like below.
*/
// void receive( byte[] data ) { // <-- default handler
void receive( byte[] data, String ip, int port ) { // <-- extended handler


  // get the "real" message =
  // forget the ";\n" at the end <-- !!! only for a communication with Pd !!!
  data = subset(data, 0, data.length);
  String message = new String( data );

  // print the result

println( "UDP Rx: "+message+"\t from "+ip+"\t on port "+port );
}

 

and here is the result of received UDP Packets on my PC...

image

Next : Interfacing ADXL345 and ADXL377 (Free Samples from ADI) Accelerometer with CC3200 and Designing some GUI application for remote monitoring station both for PC and Android phone...

 

Thanks

Ravi

  • Sign in to reply
  • DAB
    DAB over 10 years ago

    Nice detailed update.

     

    Well done.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube