Things used in this project

Schematics

Iot Hexsense - Schematic

Code

Iot Hexsense - CodeC/C++
Add this code to MK64 Project
#include "main.h"

volatile uint8_t cloud_field1 = false;
volatile uint8_t cloud_field2 = false;
volatile uint8_t cloud_field3 = false;
volatile uint8_t cloud_connected = false;

uint8_t cloud_rx_enable = false;
volatile uint8_t cloud_field4[8]="00.00 C";
volatile uint8_t cloud_field5[8]="00.00 %";
volatile uint8_t cloud_field6[10]="00.00 kPa";

uint8_t cloud_rxbuffer[255];


osa_status_t CloudHostInterface_RxTaskDestroy();
osa_status_t CloudHostInterface_RxTaskCreate();
void CloudHostInterface_RxTask();
static CopyArray(uint8_t * src, uint8_t * des, uint8_t len);

void main()
{
  /** initialize the hardware */
  PE_low_level_init();

  /** disable write buffering end enable ARM exceptions */
  HEXIWEAR_EnableExceptions();

  /** initialize the startup task */
  HEXIWEAR_Init();

  /** start RTOS scheduler */
  HEXIWEAR_Start();



  while (1) {}
}




const gpio_output_pin_user_config_t Control_cfg[] = {
  {
    .pinName = Field2,
    .config.outputLogic = 0,
    .config.slewRate = kPortSlowSlewRate,
    .config.isOpenDrainEnabled = false,
    .config.driveStrength = kPortHighDriveStrength,
  },
  {
    .pinName = Field3,
    .config.outputLogic = 0,
    .config.slewRate = kPortSlowSlewRate,
    .config.isOpenDrainEnabled = false,
    .config.driveStrength = kPortHighDriveStrength,
  }

};


  Field2   = GPIO_MAKE_PIN(GPIOD_IDX, 8U);
  
  Field3   = GPIO_MAKE_PIN(GPIOD_IDX, 9U);
  
  
  
  
  
  
  
  
  
  
  /**
 * initialize RX tasks and queues
 * @return  task initialization status
 */
osa_status_t CloudHostInterface_RxTaskCreate()
{
  osa_status_t
    status;

  status = OSA_TaskCreate (
   	                            CloudHostInterface_RxTask,
   	                            (uint8_t*)"HostInterface_RxTask",
   	                            cloudHostInterfaceRxTaskStackSize_c,
   	                            NULL,
   								cloudHostInterfaceRxPriority_c,
   	                            (task_param_t)NULL,
   	                            false,
   	                            &cloud_rx_taskHandler
   	                          );


  return (osa_status_t)status;
}

osa_status_t CloudHostInterface_RxTaskDestroy()
{

	osa_status_t
	        status = OSA_TaskDestroy( cloud_rx_taskHandler );

	    if ( kStatus_OSA_Success != status )
	    {
	        catch( CATCH_INIT );
	    }


	    return (osa_status_t)status;

}



void CloudHostInterface_RxTask(){

	uint8_t remainingbytes=0;
	volatile uint32_t rxTimes = 0;
	uint8_t i;
	while(rxTimes==0){


		        UART_DRV_ReceiveData(HEXIWEAR_DEBUG_UART_INSTANCE, cloud_rxbuffer, 200u);

		// Wait until we receive a character
			   while (kStatus_UART_RxBusy == UART_DRV_GetReceiveStatus(HEXIWEAR_DEBUG_UART_INSTANCE,&remainingbytes)){


				   OSA_TaskYield();
			   }


			   rxTimes++;

	}

	cloud_connected = false;

	cloud_CreateTasks();

	for(i=0;i<200;i++){

		if((cloud_rxbuffer[i] == 'f') && (cloud_rxbuffer[i+1] == 'i')&&  (cloud_rxbuffer[i+2] == 'e') && (cloud_rxbuffer[i+3] == 'l') && (cloud_rxbuffer[i+4] == 'd')){

			cloud_connected = true;

//http://122.166.198.246/cgi-bin/webproc
//"entry_id":3,"field1":"001","field2":null,"field3":null,"field4":null,"field5":null,"field6":null,"field7":null,"field8":null}]}
			if(cloud_rxbuffer[i+5]=='2'){


				if(cloud_rxbuffer[i+9]=='1')
					cloud_field2 = true;
				else
					cloud_field2 = false;


			}

			if(cloud_rxbuffer[i+5]=='3'){

				if(cloud_rxbuffer[i+9]=='1')
					cloud_field3 = true;
				else
					cloud_field3 = false;


			}


		}



	}


	CloudHostInterface_RxTaskDestroy();




}

/**
 * create the app task
 * @param param optional parameter
 */
void cloud_CreateTasks( )
{
    osa_status_t
        status = OSA_TaskCreate (
        						  update_CloudTask,
                                  (uint8_t *) "flashlight task",
                                  CLOUD_STACK_SIZE,
                                  NULL,
                                  CLOUD_PRIO,
                                  (task_param_t)0,
                                  false,
                                  &cloud_write_taskHandler
                                );

    if ( kStatus_OSA_Success != status )
    {
        catch( CATCH_INIT );
    }
}




/**
 * create the app task
 * @param param optional parameter
 */
void cloud_read_CreateTasks( )
{
    osa_status_t
        status = OSA_TaskCreate (
        						  read_CloudTask,
                                  (uint8_t *) "flashlight task",
                                  CLOUD_STACK_SIZE,
                                  NULL,
                                  6,
                                  (task_param_t)0,
                                  false,
                                  &cloud_read_taskHandler
                                );

    if ( kStatus_OSA_Success != status )
    {
        catch( CATCH_INIT );
    }
}


/**
 * destroy the app task
 * @param param optional parameter
 */
void cloud_DestroyTasks( )
{
    osa_status_t
        status = OSA_TaskDestroy( cloud_write_taskHandler );

    if ( kStatus_OSA_Success != status )
    {
        catch( CATCH_INIT );
    }


}


/**
 * destroy the app task
 * @param param optional parameter
 */
void cloud_read_DestroyTasks( )
{
    osa_status_t
        status = OSA_TaskDestroy( cloud_read_taskHandler );

    if ( kStatus_OSA_Success != status )
    {
        catch( CATCH_INIT );
    }


}

static CopyArray(uint8_t *src, uint8_t *des, uint8_t len){

	while(len){

		*des++ = *src++;
		len--;

	};

Credits

Img 20170312 083955 zntgodaplu
Ashok R

Artist/Hobbyist /Engineer

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Smart Garden
Intermediate
  • 2,664
  • 21

Smart Garden is a plant environmental monitoring system.

WiFi Messenger
Intermediate
  • 1,495
  • 14

Protip

Calling my son from his room using 2 ESP8266 modules, instead of shouting.

IoT Thermometer Using Python
Intermediate
  • 1,230
  • 10

Full instructions

How to develop a simple but powerful IoT thermometer using a Zerynth-powered single-board MCU and the Zerynth App.

ESP8266 friend detector
Intermediate
  • 755
  • 9

Full instructions

Using a ESP8266 to detect when a friend is near.

WiDC: Wi-Fi-Controlled FPV Robot
Intermediate
  • 6,506
  • 42

Full instructions

What about using a Wi-Fi remote-controlled robot for exploring your surroundings, reaching inaccessible places, spying and take pictures?

Counting Pulses with Maxim DS1682
Intermediate
  • 86
  • 2

Protip

This project is interfacing the Energy Monitoring system with a pulse counter.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback