Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
Aula πŸ’‘πŸ•ŠοΈ
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,952
Plant Monitoring and Watering System Using Hexabitz

Things used in this project

Hardware components

4-Pin USB-Serial Prototype Cable
Hexabitz 4-Pin USB-Serial Prototype Cable
×1
BitzClamp
Hexabitz BitzClamp
×1
Raspberry Pi Interface Module (HF1R0x)
Hexabitz Raspberry Pi Interface Module (HF1R0x)
×1
Load Cell (Strain Gauge) Sensor Module (H26R00)
Hexabitz Load Cell (Strain Gauge) Sensor Module (H26R00)
×1
STLINK-V3MODS Programmer (H40Rx)
Hexabitz STLINK-V3MODS Programmer (H40Rx)
×1
SPDT Mechanical DC Relay (H0FR1x)
Hexabitz SPDT Mechanical DC Relay (H0FR1x)
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Rechargeable Battery, Lithium Ion
Rechargeable Battery, Lithium Ion
×1
Adafruit 6-12 V DC water pump
×1
Gravity: Analog Soil Moisture Sensor For Arduino
DFRobot Gravity: Analog Soil Moisture Sensor For Arduino
×1
Elecrow Skip to the end of the images gallery Skip to the beginning of the images gallery Multi 3 in 1 keychain USB cable Micro Usb Type C iOS Port Charging Cables
×1

Software apps and online services

STM32CUBEPROG
STMicroelectronics STM32CUBEPROG

Hand tools and fabrication machines

5V / 8W Portable USB Soldering Iron
Hexabitz 5V / 8W Portable USB Soldering Iron
E-Z-Hook Programming Kit
Hexabitz E-Z-Hook Programming Kit
Solder Wire, Lead Free
Solder Wire, Lead Free

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 πŸ’‘πŸ•ŠοΈ

Aula πŸ’‘πŸ•ŠοΈ

55 projects β€’ 216 followers
Electronic Engineering

Comments