Things used in this project

Hardware components:
Hexiwear docking bd
NXP Hexiwear
×1
Esp01
Everything ESP ESP8266 ESP-01
×1
09590 01
LED (generic)
×2
Software apps and online services:
Hackster
ThingSpeak API

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

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

Mqtt + esp8266 + bmp180 + tsl2561 + Cayenne
Intermediate
  • 29
  • 1

Read data from two of most popular sensors out there. Temperature, pressure, and luminosity.

JuicyBoard: Modular Robotics Platform
Intermediate
  • 571
  • 4

Open source hardware that makes it flexible to build 3D printers, CNC, routers and more.

Alexa Trigger ESP8266
Intermediate
  • 1,418
  • 13

Work in progress

Use Alexa to voice control a relay connected to the Internet via ESP8266-01.

Solar power meter
Intermediate
  • 424
  • 3

Solar power meter measures the voltage, current and power of my 40W solar panel.

Moisty - Orchid & Plant IoT w/ Blynk
Intermediate
  • 370
  • 4

Full instructions

A simple 4 channel design/program for monitoring orchid & plant media moisture levels.

Your Wife is Hot!
Intermediate
  • 558
  • 6

Full instructions

Not hot like she looked at your browser history, hot as in temperature hot! This can be avoided with an A/C Condensate Monitoring System.

Your Wife is Hot!

Team Is it Summer Yet?

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback