Ibrahim Zaeiter
Published

Hexabitz Infrared thermometer

This project is about building a monitoring and control system for water heating with Hexabitz modules.

IntermediateFull instructions provided2 hours258
Hexabitz Infrared thermometer

Things used in this project

Story

Read more

Schematics

MIT APP INVENTOR project

the used project to create the android application

Modules Firmware files

Code

topology.h

C/C++
/*
 BitzOS (BOS) V0.2.6 - Copyright (C) 2017-2022 Hexabitz
 All rights reserved

 File Name     : topology.h
 Description   : Array topology definition.

 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __topology_H
#define __topology_H
#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_hal.h"

#define __N	3		//3			// Number of array modules

// Array modules
#define _mod1	1<<3
#define _mod2	2<<3
#define _mod3	3<<3

// Topology
static uint16_t array[__N ][7] ={
	{_H09R9, _mod2 | P4, 0, 0, _mod3 | P1, 0, 0}, 	 // Module 1 
	{_H0FR6, 0, 0, 0, _mod1 | P1, 0, 0},			     // Module 2
	{_H23R1, _mod1 | P4, 0, 0, 0, 0, 0},					     // Module 3
};

// Configurations for duplex serial ports
#if ( _module == 1 )
	#define	H09R9	1
	#define	_P1pol_normal	1
	#define	_P2pol_normal	1
	#define	_P3pol_normal	1
	#define	_P4pol_normal	1
	#define	_P5pol_normal	1
	#define	_P6pol_normal	1
#endif

#if ( _module == 2 )
	#define	H0FR6	1
	#define	_P1pol_normal	1
	#define	_P2pol_normal	1
	#define	_P3pol_normal	1
	#define	_P4pol_reversed	1
	#define	_P5pol_normal	1
	#define	_P6pol_normal	1

#endif

#if ( _module == 3 )
	#define	H23R1	1
	#define	_P1pol_reversed	1
	#define	_P2pol_normal	1
	#define	_P3pol_normal	1
	#define	_P4pol_normal	1
	#define	_P5pol_normal	1
	#define	_P6pol_normal	1

#endif

#ifdef __cplusplus
}
#endif
#endif /*__ topology_H */

/************************ (C) COPYRIGHT HEXABITZ *****END OF FILE****/

H09R9 main.c

C/C++
/*
 BitzOS (BOS) V0.2.6 - Copyright (C) 2017-2022 Hexabitz
 All rights reserved

 File Name     : main.c
 Description   : Main program body.
 */
/* Includes ------------------------------------------------------------------*/
#include "BOS.h"

/* Private variables ---------------------------------------------------------*/
float	temp_s;
/* Private function prototypes -----------------------------------------------*/

/* Main function ------------------------------------------------------------*/

int main(void){

	Module_Init();		//Initialize Module &  BitzOS

	//Don't place your code here.
	for(;;){}
}

/*-----------------------------------------------------------*/

/* User Task */
void UserTask(void *argument){
	BOSMessaging.trace = TRACE_NONE ;
	AddBOSvar(FMT_FLOAT,(uint32_t) &temp_s );

	while(1){
		SampleTemperature(&temp_s);
		WriteRemote(3, (uint32_t) &temp_s, 1, FMT_FLOAT, 0);
	}
}

/*-----------------------------------------------------------*/

H23R0 main.c

C/C++
/*
 BitzOS (BOS) V0.2.6 - Copyright (C) 2017-2022 Hexabitz
 All rights reserved

 File Name     : main.c
 Description   : Main program body.
 */
/* Includes ------------------------------------------------------------------*/
#include "BOS.h"

/* Private variables ---------------------------------------------------------*/
volatile float temp_s;
int temp_u;
uint8_t buf[4];
uint8_t MESG_T[4];
uint8_t MESG_U[3] ;
float	timeout	=	60000;
int Relay = 0;
/* Private function prototypes -----------------------------------------------*/

/* Main function ------------------------------------------------------------*/

int main(void){

	Module_Init();		//Initialize Module &  BitzOS

	//Don't place your code here.(uint32_t) 0xFFFFFFFF
	for(;;){}
}

/*-----------------------------------------------------------*/

/* User Task */
void UserTask(void *argument){
	 BT_Set_Discoverable();
	 BT_Set_Name(&("H23R1"), 5);
	AddBOSvar(FMT_FLOAT, (uint32_t)&temp_s);

	// put your code here, to run repeatedly.
	while(1){

		BT_Receive_Data(buf,3);

		if(buf[0]=='1'&&buf[1]=='s')
		Relay = 1;

		else if (buf[0]=='0'&&buf[1]=='s')
		Relay = 0;

		else if (buf[0]=='g')
		{	sprintf(MESG_T, "%f",temp_s);
			BT_Send_Data(MESG_T, 4);
		}

		else if (buf[0]=='t')
		{	MESG_U[0]=buf[1];
			MESG_U[1]=buf[2];
			MESG_U[2]=buf[3];
			temp_u = atoi(MESG_U);}


		if((temp_u > temp_s)&&(Relay == 1) ){
			memcpy(&messageParams[0], &timeout, 4);
			SendMessageToModule(2, CODE_H0FRx_ON, 4);}

		else if ((Relay == 0) || (temp_u < temp_s) )
		{ SendMessageToModule(2, CODE_H0FRx_OFF, 0);}

	}
}

/*-----------------------------------------------------------*/

Credits

Ibrahim Zaeiter
2 projects • 12 followers
Electronic Systems Engineer

Comments