Aula Jazmati
Published © MIT

Plant Monitoring and Watering System Using Hexabitz

Set up your Pi to automatically take care of your plant by reading a moisture & weight data from Hexabitz modules, and watering when needed.

IntermediateFull instructions provided2 hours1,246
Plant Monitoring and Watering System Using Hexabitz

Things used in this project

Story

Read more

Schematics

Schematic

Code

SPDT Mechanical DC Relay (H0FR1x) code

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

 File Name     : main.c
 Description   : Main program body.
 */
/* Includes ------------------------------------------------------------------*/
#include "BOS.h"
float x;
/* Private variables ---------------------------------------------------------*/
volatile int lock;
/* 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){
	ADCSelectChannel(2,"top");
	AddBOSvar(FMT_FLOAT , (uint32_t) &lock );
	while(1){
		ReadADCChannel(2,"top", &x);

						Delay_ms(10);
								if ( x > 3000.0 && x < 4060.0 && lock ==0)
								{
									Output_off ( );
								}
								else if (x < 2500.0 && lock ==0) {


									Output_on (20000);
									Delay_ms(100);
								}

	}
}

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

Load Cell Sensor (H26R0x) code **

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

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

/* Private variables ---------------------------------------------------------*/
//float x;
int lock = 0;
float Weight;
float timeout ;
/* 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){

	//ADCSelectChannel(2,"top");
	Calibration(20, 1.9242, 0.0094);
	ZeroCal(1);
	Delay_ms(10);
	AddBOSvar(FMT_FLOAT, (uint32_t) &lock );

	// put your code here, to run repeatedly.
	while(1){
		Weight = SampleGram(1);
		//ReadADCChannel(2,"top", &x);
		//Delay_ms(10);
		lock = 0;
				if (Weight < 120.0 && Weight > 50.0 && lock != 1)
				{
				lock = 1;
				timeout = 10000.0;
				memcpy(&messageParams[0], &timeout, 4);
				SendMessageToModule(2, CODE_H0FRx_ON, 4);
				Delay_ms(100);
				}

				else if (Weight >= 120.0 && Weight <150.0 && lock != 2)
				{
				lock = 2;
				timeout = 2000.0;
				memcpy(&messageParams[0], &timeout, 4);
				SendMessageToModule(2, CODE_H0FRx_ON, 4);
				Delay_ms(100);
				}
				else if ( Weight >150.0  && lock != 3 )
				{
				lock = 3;
				SendMessageToModule(2, CODE_H0FRx_OFF, 0);
				Delay_ms(100);
				}


				WriteRemote(2,(uint32_t) &lock, 1, FMT_FLOAT,0);


	}
}

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

Topology

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

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

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

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


#define __N	2				// Number of array modules

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


// Topology
static uint16_t array[__N][7] = {
{ _H26R0, 0, 0, _mod2|P5, 0, 0, 0},									        // Module 1
{ _H0FR1, 0, 0, 0, 0, _mod1|P3, 0},									        // Module 2
};

// Configurations for duplex serial ports
#if ( _module == 1 )
	#define	H26R0	1
	#define	_P1pol_normal	1
	#define	_P2pol_normal	1
	#define	_P3pol_reversed	1
	#define	_P4pol_normal	1
	#define	_P5pol_normal	1
	#define	_P6pol_normal	1
#endif
#if ( _module == 2 )
	#define	H0FR1	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


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


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

SPDT Mechanical DC Relay (H0FR1x) Firmware

Load Cell Sensor (H26R0x) Firmware

HF1R0x-Firmware 0.2.0

Credits

Aula Jazmati

Aula Jazmati

26 projects β€’ 82 followers
πŸ’‘

Comments