Hello for everyone.

 

After many hours of work, I can show my umbrella project.

At begin I want thanks for my wife (for patient) for my friend Jonatan (for 3D printer ) for Daniel Defoe (for very fast realizing my orders),

for my young daughter (for permanently hidding device components   )

 

 

  1. Introduction ......................................................................
  2. Functionality ....................................................................
  3. How it works ...................................................................
  4. Software..........................................................................
  5. Hardware.........................................................................

        5.1  I/O's.........................................................................

        5.2 LCD..........................................................................

        5.3 GPS ...........................................................................

        5.4 Anemometr.................................................................

        5.5 Power Supply............................................................

        5.6 Close Mechanism......................................................

  6. Plot.ly.................................................................................

  7. Summary...........................................................................

 

 

 

1. Introdution


competition is ending

I learnt a lot, but finally I designed my iot_umbrella device

 

Full project include: anemometer, gps module, solar charger, umbrella controller

 

hardware-0.jpg


Umbrella controler is mounting on umbrella


intro-box.jpg

 

umbrella with mounted all components look like below


intro-umbro.jpg


 

2. Functionality

 

  1. weather forecast module (openweathermap.org)
  2. statistic update module (plot.ly)
  3. umbrella protection module (anemometer, wind strength detection)
  4. energy harvesting module (solar charger based on bg25504)

 

 

3. How it works

 

After start

  1. device is reading gps position (only if gps module is in usage – no connection yellow led on)
  2. device is checking access point connection ( no connection – red led is on)
  3. device is reading umbrella posiotion ( open close sensor )

 

Lcd is active and all device states are showing on screen.

 

During normal work

  1. device is checking switch SW1 on state (red switch on box)
  2. device is checking switch SW2 on state (green switch on box)
  3. device is checking switch SW3 on state (umbrella open/close sensor)

 

 

- if switch SW1 (red switch on box) is pushed and umbrella is open then umbrella close procedure is starting. Firstly emergency signal is generated (buzzer is working). After that umbrella is closing. Finally umbrella state is changed from open to close and statistic update task is activated. Umbrella closing ,,, mechanism is not ready yet. I am waiting for tools with will be printed using my friend 3d printer. In hardware section I described it in details.

 

 

- if switch SW2 (green switch on box) is pushed device is connecting into „openweathermap.org”. Using gps position (if gps module is in usage) or city name device reading weather forecast data. On Lcd is showing weather forecast for next 9 hours !

Weather forecast data are showing in packages. Each package of data including weather forecast for next 3 hours and is presented on 3 screens:

- weather icon  screen (sun, clouds, rain, tornado, hurricane, etc.)

- weather data  screen (wind speed, temperature, presure, humidity, clouds, fall )

- emoticon screen - good weather  ( smilling face ), bad weather   ( neutral face ), fatal weather ( sad face)

 

 

- if switch SW3 (open/close sensor) state on is activated (user manually opened the umbrella) then umbrella state is changed from open to close and statistic update task is activated.

 

Statistic update task working using plot.ly service After each umbrella state change (close -> open „user action”, open->close „user SW1 on” or open->close „anemometer wind protection action”) device connecting to SNTP server and read actual time. After that cc3200 send data into plotly service (umbrella state: 0-closed, 1-opened and time of event). In details I described plot.ly usage in point number 6.

 

If device is on then anemometer is working (device measures frequency from anemometer with frequency is calibrating on wind strength). If too strong wind is detected then umbrella close procedure is activated.

 

 

4. Software

 

Project is written in „C” language using IAR EW for ARM. In project I described lcd, gps, anemometer, buzzer, leds switches devices. I created two RTOS tasks (freeRTOS is used):

  • network task
  • protection task

In network task device checking acces point connection, reading weather forecast data, updating umbrella statistics. In protection task device closing umbrella ( anemometer event,,, to strong wind detection, or user pushed close umbrella button ) and checking umbrella open event ( user opened umbrella,,, umbrella state is changing form closed to opened).

 

 

Device configuration is defined in „configure.h” file located in system folder. In this file user can set network connection parameters ( AP name, password), weather forecast settings (state wind, temperature, location city name), plot.ly configuration data (user account name, user account password), sntp server name and gtm time zone.

 

software-iar.jpg


User can compile project in one of two options: with gps module usage (project->options->C/C++ Compiler -> Preprocessor -> Defined symbols-> and add GPS_IN_USE) or without gps module usage (project->options->C/C++ Compiler -> Preprocessor -> Defined symbols-> and remove GPS_IN_USE).

 

 

5. Hardware

 

In my umbrella project I designed:

1. anemometer

2. gps module

3. solar charger

4. umbrella controller

 

all devices are shown  below in progress is umbrella close mechanism I described it in section number 5.6

 

hardware-1.JPG

 

solar charger and cc3200 devboard are mounted in controller box, additionally in box i  mounted one  buzzer, two switches and two leds and connection wires

 

hardware-box.JPG

 

5.1. I/O's


 

In project are used:

  • two switches (red – umbrella close, green – weather forecast)
  • two leds (red – AP initialization error, yellow – GPS reading error)
  • one buzzer (emergency alarm before umbrella close)
  • one open umbrella sensor (based on switch). Schematic below.

 

io-schematic.jpg

 


5.2. LCD


In project I used lcd from nokia 5110 (PCD8544 driver), It is monochrome graphic lcd with resolution 84x48 pixels.

 

I used ready devboard

lcd-modlcd.jpg



lcd-schematic.jpg


Communication with lcd is done via SPI ( in one side mc->lcd ) I wrote software spi algorithm (code below )

 

void LcdSpiInit()
{
    // Configure PIN_05 for GPIOOutput (SPI_CLK)
    MAP_PinTypeGPIO(PIN_05, PIN_MODE_0, false);
    MAP_GPIODirModeSet(SPI_CLK_PORT, SPI_CLK_PIN, GPIO_DIR_MODE_OUT);

    // Configure PIN_02 for GPIOOutput (SPI_MOSI)
    MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    MAP_GPIODirModeSet(SPI_MOSI_PORT, SPI_MOSI_PIN, GPIO_DIR_MODE_OUT);

    GPIOPinWrite(SPI_CLK_PORT,  SPI_CLK_PIN, SPI_CLK_PIN);
}

void SpiWriteByte(uInt8 data)
{
    uInt8 idx, l_data;

    l_data = data;

    for(idx=0; idx<8; idx ++)
    {
        GPIOPinWrite(SPI_CLK_PORT,  SPI_CLK_PIN, 0x00);

        if((l_data & 0x80) == 0x80)
           GPIOPinWrite(SPI_MOSI_PORT,  SPI_MOSI_PIN, SPI_MOSI_PIN);
        else
           GPIOPinWrite(SPI_MOSI_PORT,  SPI_MOSI_PIN, 0x00);

        MAP_UtilsDelay(DELAY_CLK_1_US);
        GPIOPinWrite(SPI_CLK_PORT,  SPI_CLK_PIN, SPI_CLK_PIN);
        MAP_UtilsDelay(DELAY_CLK_1_US);

        l_data = l_data << 1;
    }

}

















 

In project I use lcd in text mode but mostly in graphic mode

I am printing: system init screens, weather icons, and weather forecast emoticons.

 

lcd-1initIcons.bmp

lcd-2weatherIcons.bmp

lcd-3stateIcon.bmp

Bitmaps are designed in freeware software: micro LCD

 

lcd-microlcd.jpg

 

 

5.3. GPS


In my umbrella project I used gps module. After start  device turn on gps module and waiting for geographic position . Latitude and longitude values are used in weather forecast algorithm.

 

gps-gps_box.jpg

 

gps-schematic.jpg

 

 

If user dont have gps module, then he can turn off gps positioning function in umbrella code (c/c++ compiler -> options -> proprocessor -> defined symbols ,,, and remove GPS_IN_USE ). After that user must set name of city where umbrella is located (definition in configure.h file). When gps module is turn off, weather forecast alghoritm working using city name.

 

 

In project I used Quectell L80 GPS module with an embedded patch antena, but umbrella software is compatible with every gps module working in NMEA 0183 standard.


gps-l80.jpg


CC3200 communicate with L80 via UART (9600bps, 8N1).

The L80 module supports 2 protocols:

- NMEA – positioning data ( output )

- PMTK – gps module configuration ( input )

  In umbrella project I dont  use PMTK protocol. L80 working with default configuration.


On the  L80 NMEA output are avalible GPRMC, GPVTG, GPGSA, GPGSV, GPGLL GPTXT  commands. In umbrella software I analize one command: GPRMC. 


gps-gprmc.jpg

I wrote simple state machine. In  am checking L80 output NMEA chars and I am wait for „$GPRMC” string. If I found this string I am checking gps state (A-active, V-inactive). If gps position is active ( A state) then I am waiting form end of gprmc command. Then I check command CRC. If CRC code is corected then I finishign gps positioning procedure and I read latiotude and longitude values.

 

uInt8 GpsRmcFrame()
{
    uInt8 l_byte;


    l_byte =   UartA0Get();
                                    
    switch(g_level)   
    {
        case 0:
                  if(l_byte == '$')
                  {
                      g_level    = 1;
                      g_index    = 0;
                      g_buffor[g_index++] = l_byte;
                  }
                  break;
   
        case 1:
                  g_level = 0;
                  if(l_byte == 'G')
                  {      
                      g_crc     = l_byte;
                      g_level   = 2;
                      g_buffor[g_index ++] = l_byte;
                  }
                  break;
   
        case 2:
                  g_level = 0;
                  if(l_byte == 'P')
                  {      
                      g_crc ^= l_byte;
                      g_level   = 3;
                      g_buffor[g_index ++] = l_byte;
                  }
                  break;
   
        case 3:
                  g_level = 0;
                  if(l_byte == 'R')
                  {      
                      g_crc ^= l_byte;
                      g_level   = 4;
                      g_buffor[g_index ++] = l_byte;
                  }
                  break;
   
        case 4:
                  g_level = 0;
                  if(l_byte == 'M')
                  {      
                      g_crc ^= l_byte;
                      g_level   = 5;
                      g_buffor[g_index ++] = l_byte;
                  }
                  break;
   
        case 5:
                  g_level = 0;
                  if(l_byte == 'C')
                  {      
                      g_crc ^= l_byte;
                      g_level   = 6;
                      g_buffor[g_index ++] = l_byte;
                  }
                  break;
   
        case 6:
                  g_crc ^= l_byte;
                  g_buffor[g_index ++] = l_byte;

                  if(g_index == 19)
                  {
                    if(l_byte == 'A')
                       g_level = 7;
                    else
                       g_level = 0;
                  }
                  break;
   
        case 7:

                g_crc ^= l_byte;
                g_buffor[g_index ++] = l_byte;

                if(g_index ==  82)
                                      g_level = 0;
                if(l_byte  == '*')
                                      g_level = 8;
                break;

        case 8:

                g_level = 0;
                g_crc  ^= '*';
                g_buffor[g_index ++] = l_byte;

                if(l_byte >= 'A' && l_byte <= 'F')                      
                l_byte = l_byte - 'A' + 10;

                if(l_byte >= '0' && l_byte <= '9')
                l_byte = l_byte - '0';

                if( (g_crc >> 4) == l_byte )
                                      g_level = 9;
                break;

        case 9:
                g_level = 0;
                g_buffor[g_index ++] = l_byte;

                if(l_byte >= 'A' && l_byte <= 'F')                      
                l_byte = l_byte - 'A' + 10;

                if(l_byte >= '0' && l_byte <= '9')
                l_byte = l_byte - '0';

                if( (g_crc &= 0x0f) == l_byte )
                                     g_level = 10;
                break;                                              

        case 10:
                  g_level = 0;
                  g_buffor[g_index ++] = l_byte;
    
                  if(l_byte == 0x0D)
                                    g_level  = 11;
                  break;
   
        case 11:
                  g_level = 0;
                  g_buffor[g_index ++] = l_byte;
    
                  if(l_byte == 0x0A)
                  {
                     return 1;                  // is complete rmc frame
                  }   
                  break;

        default:
                  g_level = 0;
                  break;
    }

    return 0;
}
















 

 


5.4. Anemometr


Umbrella should be protected against damage. What can damage umbrella  ... of course strong wind ! So II am start developing wind sensor (anemometer)


aneno-schematic.jpg


aneno-dev.jpg


Anemometer based on encoder and frequency measurement algorithm ( timerA in capture mode )

In code I implemented software and hardware frequency filters

 

Hardware LF filter  ( 200Hz Fc ) was created by: http://sim.okawa-denshi.jp/en/CRtool.php

 

aneno-filter1.jpg

 


5.5.Power supply


For umbrella project I build my own power supply system.

 

  • solar panel (3V, 80mA)
  • storage/battery element (LiPo rechargeable battery from Fuel Tank BoosterPack)
  • my own universal solar charger device (based on TI bq255040 )
  • TI TLV70433 LDO (3,3V, 150mA)


power-prj.jpg


Designed by my universal solar charger is based on TI bq25504


power-bq25504.jpg

power-schematic.jpg

power-pcb.jpg

power-charger.jpg


Solar charger parameters are configured by resistors.

  •    battery over voltage protection value (ROV1, ROV2)
  •    battery under voltage protection value (RUV1, RUV2)
  •    battery ok value and battery ok hysteresis value (ROK1, ROK2, ROK3)

Maximum power point tracking value is set on 80%. Battery thermal shutdown protection value is set on 65”C.

 

In my solution I configured values:

  •     over voltage: 4,2V (ROV1=4,5 M ROV2=5,5 M)
  •     under voltate: 2,8V (RUV1=4,5 M, RUV2= 5,5 M)
  •     battery ok.: 3,3 V battery ok hysteresis 3,7V (ROK1= 3,4 M, ROK2= 5,5 M, ROK3= 1,1 M)

Bq25504 working like on shematic below:


power-work.jpg


During choosing rezistors paremeters very  helpfull is TI spreadsheet:  bq25504_Design_Help_V1_2.ods I used it in my work.


power-calculator.jpg


5.6.Close mechanism

 

 

Umbrella is opened always by user ! User manually opening umbrella - using knob.

Umbrella could be closed when user pushed SW1 (red switch – umbrella close) or when anemometr detecting too strong wind. When umbrella is closing – close mechanism is using. I designed this mechanism but actually I don’t have it. Mechanism must be printing on 3d printer. My friend Jonatan have 3d printer (foto below) and he want print spares (sprocket and latch) for me.

 

close-3d.jpg

 

 

I designed sprocket and latch.

 

close-prj.jpg

 

How it will be works ? When user opening umbrella line is rolling, mechanism is automatic blocked (look on foto below).

 

close-work-open.jpg

 

For unlock mechanism I will be user servo. Servo will move latch after that line will be unrolled and umbrella will be closed (look on foto below).

 

close-work-open.jpg

 

 

Close mechanism (when spares will be ready) I will be mounted here:

 

close-mnt.jpg

 

 

6. Plot.ly

 

In project I used plotly for displaying umbrella statistics.

Device cc3200 monitoring two events:

  1. open umbrella (user can manually open umbrella)
  2. close umbrella (user can close umbrella (SW1 red button) or protection task can close umbrella,,, when too strong wind is detected )

 

 

When event occurs cc3200 will connect to SNTP server and read actual time. After that cc3200 send data into plotly service (umbrella state: 0-closed, 1-opened and time of event).

My testing plot is showing below. On next picuure I am showing plot data.

 

plotly-plot.jpg

plotly-data.jpg


 

How I done it .

 

  1. I created account: „iot_umbrella” on plot.ly (registration is for free)
  2. I readed my user KEY: „nhvng7txac”
  3. I started codding. Usefull was arduino examples, and plot.ly args documentation.

plotly-name-key-0.jpg

plotly-name-key-1.jpg

 

Data into plot are sending by HTTP using POST method in SetPlotLyData(int iSockID, uInt16 value); procedure (code below)

 

void  SetPlotLyData(int iSockID, uInt16 value)
{
    int aux;
    int iTXStatus;
    int iRXDataStatus;
    uInt16     l_contentLen;
    char*      pcBufLocation;
                                                                        
    const char prefBuf1[]  = "POST /clientresp HTTP/1.1\r\nHost: 107.21.214.199\r\nContent-Length: ";
    const char prefBuf2[]  = "\r\n\r\n"; // calculate and set content length

    const char postBuf1[]  = "version=2.3&origin=plot&platform=cc3200";
    const char postBuf2[]  = "&un=";               // set user name
    const char postBuf3[]  = "&key=";              // set user key
    const char postBuf4[]  = "&args=[{\"x\": [\""; // set value x ( data )
    const char postBuf5[]  = "\"], \"y\": [";      // set value y ( state )
    const char postBuf6[]  = "], \"mode\": \"lines+markers\", \"name\": \"open close\",  \"line\": {\"shape\": \"hv\",\"color\":\"green\",\"size\":2}, \"marker\": {  \"color\": \"blue\",  \"size\": 16} , \"type\": \"scatter\"} ]";
    const char postBuf7[]  = "&kwargs={\"filename\": \"cc-3200\", \"fileopt\": \"extend\",\"world_readable\": true,\"layout\":{\"title\": \"umbrella open close statistics\", \"xaxis\": {\"title\": \"date\"}, \"yaxis\": {\"title\": \"state\" }}}\r\n";

    l_contentLen = 0;
    memset(acRecvbuff, 0, sizeof(acRecvbuff));


    // calculate content length

    l_contentLen  = strlen(postBuf1) + strlen(postBuf2) + strlen(postBuf3) + strlen(postBuf4) + strlen(postBuf5) + strlen(postBuf6) + strlen(postBuf7);
    l_contentLen += strlen(PLOTLY_USER_NAME);
    l_contentLen += strlen(PLOTLY_USER_KEY);
    l_contentLen += 19; // date  x=1,
    l_contentLen += 1;  // state y=1


    // Puts together the HTTP POST string

    pcBufLocation = acSendBuff;

    // prefix
    aux = sprintf(pcBufLocation,"%s%d%s",prefBuf1,l_contentLen,prefBuf2);
    pcBufLocation += aux;

    // postfix
    aux = sprintf(pcBufLocation,"%s%s%s%s%s",postBuf1,postBuf2,PLOTLY_USER_NAME,postBuf3,PLOTLY_USER_KEY);
    pcBufLocation += aux;

    aux = sprintf(pcBufLocation,"%s%s%s%d",postBuf4,g_sAppData.acTimeStore,postBuf5,value);
    pcBufLocation += aux;

    aux = sprintf(pcBufLocation,"%s%s",postBuf6,postBuf7);
    pcBufLocation += aux;

    //
    // Send the HTTP POST string to the open TCP/IP socket.
    //
    DBG_PRINT("Sent HTTP POST request. \n\r");
    iTXStatus = sl_Send(iSockID, acSendBuff, strlen(acSendBuff), 0);
    MAP_UtilsDelay(DELAY_CLK_1_SEK *2);
    DBG_PRINT("Return value: %d \n\r", iTXStatus);

    //
    // Store the reply from the server in buffer.
    //
    DBG_PRINT("Received HTTP GET response data. \n\r");
    iRXDataStatus = sl_Recv(iSockID, &acRecvbuff[0], sizeof(acRecvbuff), 0);
    DBG_PRINT("Return value: %d \n\r", iRXDataStatus);
    acRecvbuff[sizeof(acRecvbuff) - 1] = 0;

    DBG_PRINT(acRecvbuff);
}























 

Firstly I’m prepare prefix string:

 

   const char prefBuf1[] = "POST /clientresp HTTP/1.1\r\nHost: 107.21.214.199\r\nContent-Length: "; 

   const char prefBuf2[] = "\r\n\r\n"; // calculate and set content length  

 

Content-Length must be set by user. So I wrote code calcuating this value ( it is sum of length of all postBuf data (from 1 to 7) plus value x:state plus value y:data ).

 

 

Secondly I’m prepare postfix string:

 

   const char postBuf1[] = "version=2.3&origin=plot&platform=cc3200";

   const char postBuf2[] = "&un="; // set user name

   const char postBuf3[] = "&key="; // set user key  

   const char postBuf4[] = "&args=[{\"x\": [\""; // set value x ( data )

   const char postBuf5[] = "\"], \"y\": ["; // set value y ( state ) 

   const char postBuf6[] = "], \"mode\": \"lines+markers\", \"name\": \"open close\", \"line\": {\"shape\": \"hv\",\"color\":\"green\",\"size\":2}, \"marker\": { \"color\": \"blue\", \"size\": 16} , \"type\": \"scatter\"} ]";

   const char postBuf7[] = "&kwargs={\"filename\": \"cc-test\", \"fileopt\": \"extend\",\"world_readable\": true,\"layout\":{\"title\": \"umbrella open close statistics\", \"xaxis\": {\"title\": \"date\"}, \"yaxis\": {\"title\": \"state\" }}}\r\n";

 

 

In postfix string I’m setting: user name and user key (parameters defined by user in configuration.h file). Also I’m setting x:data and y:state values. I’m setting plot args:

 

  • plot type: scatter, plot mode: lines+makers, line shape:hv
  • plot line color: green, plot line size:2
  • maker color:blue, marker size:16
  • plot title:umbrella open close statistics
  • xaxis title: date, yaxis title:state

 

 

Connected together (prefix and postfix) strings are send into plot.ly service. In response server return plot adress. My plot adress is: http://107.21.214.199/~iot_umbrella/16 ( Full response from server device printing on debug uart canal (9600 8N1), here user can found plot adress and use it in aplication)

 

// after start
//

//------------------------------------
//         CHECK ACCESS POINT
//-----------------------------------

Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: LG-E610_8464 , BSSID: c4:43:8f:d3:71:52

Device has connected to LG-E610_8464
Device IP Address is 192.168.43.72

connected to LG-E610_8464 APSL Disconnect...
[WLAN EVENT]Device disconnected from the AP: LG-E610_8464, BSSID: c4:43:8f:d3:71:52 on application's request
Check AP Complete

//------------------------------------
//          STATISTIC UPDATE (1)
//-----------------------------------


// read sntp time (2014-10-18 18:34:00)

Statistic Update
Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: LG-E610_8464 , BSSID: c4:43:8f:d3:71:52

Device has connected to LG-E610_8464
Device IP Address is 192.168.43.72

connected to LG-E610_8464 APGet Host IP succeeded.
Host: ntp.inode.at IP: 195.58.160.5

response from server: ntp.inode.at
2014-10-18 18:34:00


Socket SNTP closed


// write data to plot.ly (state=0, date=2014-10-18 18:34:00)


Get Host IP succeeded.
Host: plot.ly IP: 107.21.214.199

Socket Id: 17 was created.Sent HTTP POST request.
Return value: 541
Received HTTP GET response data.
Return value: 444
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Sat, 18 Oct 2014 17:34:29 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Vary: Accept-Encoding
Vary: Cookie, Host
Set-Cookie: csrftoken=PWInV9dVF55AkzSus2sXYVrWnX2wFLor; expires=Sat, 17-Oct-2015 17:34:29 GMT; Max-Age=31449600; Path=/

73
{"url": "http://107.21.214.199/~iot_umbrella/16", "message": "", "warning": "", "filename": "cc-test", "error": ""}
0


Socket PLOT.LY closed
SL Disconnect...
[WLAN EVENT]Device disconnected from the AP: LG-E610_8464, BSSID: c4:43:8f:d3:71:52 on application's request
Statistic Complete

//------------------------------------
//          STATISTIC UPDATE (2)
//-----------------------------------

// read sntp time (2014-10-18 18:34:09)

Statistic Update
Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: LG-E610_8464 , BSSID: c4:43:8f:d3:71:52

Device has connected to LG-E610_8464
Device IP Address is 192.168.43.72

connected to LG-E610_8464 APGet Host IP succeeded.
Host: ntp.inode.at IP: 195.58.160.5

response from server: ntp.inode.at
2014-10-18 18:34:09


Socket SNTP closed

// write data to plot.ly (state=1, date=2014-10-18 18:34:09)


Get Host IP succeeded.
Host: plot.ly IP: 107.21.214.199

Socket Id: 17 was created.Sent HTTP POST request.
Return value: 541
Received HTTP GET response data.
Return value: 444
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Sat, 18 Oct 2014 17:34:38 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Vary: Accept-Encoding
Vary: Cookie, Host
Set-Cookie: csrftoken=wTBzrsRzWlM1mKT7u94xQfQuDbasRe5I; expires=Sat, 17-Oct-2015 17:34:38 GMT; Max-Age=31449600; Path=/

73
{"url": "http://107.21.214.199/~iot_umbrella/16", "message": "", "warning": "", "filename": "cc-test", "error": ""}
0


Socket PLOT.LY closed
SL Disconnect...
[WLAN EVENT]Device disconnected from the AP: LG-E610_8464, BSSID: c4:43:8f:d3:71:52 on application's request
Statistic Complete


//------------------------------------
//          STATISTIC UPDATE (3)
//-----------------------------------


// read sntp time (2014-10-18 18:34:17)

Statistic Update
Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: LG-E610_8464 , BSSID: c4:43:8f:d3:71:52

Device has connected to LG-E610_8464
Device IP Address is 192.168.43.72

connected to LG-E610_8464 APGet Host IP succeeded.
Host: ntp.inode.at IP: 195.58.160.5

response from server: ntp.inode.at
2014-10-18 18:34:17


Socket SNTP closed


// write data to plot.ly (state=0, date=2014-10-18 18:34:17)

Get Host IP succeeded.
Host: plot.ly IP: 107.21.214.199

Socket Id: 17 was created.Sent HTTP POST request.
Return value: 541
Received HTTP GET response data.
Return value: 444
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Sat, 18 Oct 2014 17:34:46 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Vary: Accept-Encoding
Vary: Cookie, Host
Set-Cookie: csrftoken=bveH7hB7PpzpKgCdre92U7c9yV8Rvldr; expires=Sat, 17-Oct-2015 17:34:46 GMT; Max-Age=31449600; Path=/

73
{"url": "http://107.21.214.199/~iot_umbrella/16", "message": "", "warning": "", "filename": "cc-test", "error": ""}
0


Socket PLOT.LY closed
SL Disconnect...
[WLAN EVENT]Device disconnected from the AP: LG-E610_8464, BSSID: c4:43:8f:d3:71:52 on application's request
Statistic Complete


//------------------------------------
//          STATISTIC UPDATE (4)
//-----------------------------------


// read sntp time (2014-10-18 18:34:25)

Statistic Update
Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: LG-E610_8464 , BSSID: c4:43:8f:d3:71:52

Device has connected to LG-E610_8464
Device IP Address is 192.168.43.72

connected to LG-E610_8464 APGet Host IP succeeded.
Host: ntp.inode.at IP: 195.58.160.5

response from server: ntp.inode.at
2014-10-18 18:34:25


Socket SNTP closed

// write data to plot.ly (state=1, date=2014-10-18 18:34:25)

Get Host IP succeeded.
Host: plot.ly IP: 107.21.214.199

Socket Id: 17 was created.Sent HTTP POST request.
Return value: 541
Received HTTP GET response data.
Return value: 444
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Sat, 18 Oct 2014 17:34:53 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Vary: Accept-Encoding
Vary: Cookie, Host
Set-Cookie: csrftoken=pKKupatpFBxvnvzZefE1PkswIBiZLvys; expires=Sat, 17-Oct-2015 17:34:53 GMT; Max-Age=31449600; Path=/

73
{"url": "http://107.21.214.199/~iot_umbrella/16", "message": "", "warning": "", "filename": "cc-test", "error": ""}
0


Socket PLOT.LY closed
SL Disconnect...
[WLAN EVENT]Device disconnected from the AP: LG-E610_8464, BSSID: c4:43:8f:d3:71:52 on application's request
Statistic Complete


//------------------------------------
//          STATISTIC UPDATE (5)
//-----------------------------------


// read sntp time (2014-10-18 18:34:32)


Statistic Update
Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Started SimpleLink Device: STA Mode
[WLAN EVENT] STA Connected to the AP: LG-E610_8464 , BSSID: c4:43:8f:d3:71:52

Device has connected to LG-E610_8464
Device IP Address is 192.168.43.72

connected to LG-E610_8464 APGet Host IP succeeded.
Host: ntp.inode.at IP: 195.58.160.5

response from server: ntp.inode.at
2014-10-18 18:34:32

// write data to plot.ly (state=0, date=2014-10-18 18:34:32)

Socket SNTP closed
Get Host IP succeeded.
Host: plot.ly IP: 107.21.214.199

Socket Id: 17 was created.Sent HTTP POST request.























 

All network connections are realized in StatisticUpdateTask().

 

  1. Device is connecting with defined ACCESS POINT.
  2. Device is connecting with SNTP server and reading actual time value.
  3. Device is connecting with PLOT.LY server and sending plot data (x: date,,, time from sntp server and y:state,,, umbrella state 0-closed 1-opened )

 

 

Code of StatisticUpdateTask() I am showing below.

 

void StatisticUpdateTask()
{
    int     iSocketDesc;
    sInt16 apConnection;

    g_statisticTrigger = 0;
    DBG_PRINT("Statistic Update \n\r");

    while(1)
    {
        /********************* Connect to specific AP ********************************/
        apConnection = Connect2AccesPoint();

        if(apConnection < 0)
        {
            DBG_PRINT("can't connect to %s AP",SSID_NAME);
            break;
        }
        else
        {
            DBG_PRINT("connected to %s AP",SSID_NAME);
        }

        /********************* GET SNTP Time ***************************************/

        // Get the serverhost IP address using the DNS lookup
        g_sAppData.ulDestinationIP = Network_IF_GetHostIP((char*)SNTP_SERVER_NAME);
        if(g_sAppData.ulDestinationIP == 0)
        {
            DBG_PRINT("NTP DNS lookup failed. \n\r");
            break;
        }

        //
        // Create UDP socket
        iSocketDesc = sl_Socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
        if(iSocketDesc < 0)
        {
            UART_PRINT("Socket create failed\n\r");
            break;
        }

        GetSNTPTime();

        // Close the socket
        close(iSocketDesc);
        DBG_PRINT("\n\rSocket SNTP closed\n\r");

        /********************* SET PLOTLY DATA *************************************/

        // Get the serverhost IP address using the DNS lookup
        g_sAppData.ulDestinationIP = Network_IF_GetHostIP((char*)PLOTLY_SERVER_NAME);
        if(g_sAppData.ulDestinationIP == 0)
        {
            DBG_PRINT("PLOT.LY DNS lookup failed. \n\r");
            break;
        }

        // Create a TCP connection to the server
        iSocketDesc = CreateConnection( g_sAppData.ulDestinationIP );
        if(iSocketDesc < 0)
        {
            DBG_PRINT("Socket creation failed.\n\r");
            break ;
        }



        // get event state
        SetPlotLyData(iSocketDesc,g_systemUmbrellaState);

        // Close the socket
        close(iSocketDesc);
        DBG_PRINT("\n\rSocket PLOT.LY closed\n\r");
        break;
    }

    // Stop the driver
    Network_IF_DeInitDriver();
    DBG_PRINT("Statistic Complete\n\r");

}























 

In my opinion plotly is great. It is for free and easy in use. I had many fun with working with this platform. I am going to use plotly in future ! So see you later plotly !

 

7. Summary


Iot backyard challenge was hard but very interesting form me.

Now I have knowledge about c3200 and plotly.

I am sure that in future I will be use cc3200 and plot.ly  in my projects

 

 

best regards

Lukasz, Poland