Translate

Sunday, July 9, 2023

Huzzah32 - fHelper




Time ago I did work on a fun project to control the soil of a plant in the office, the fHelper project.



However the project had some problems.





First of all the soil sensor used was crappy and thus I decided to abandon it totally.
Second the platform used was overkill and basically unusable (and expensive).
In order to decently use the Raspberry a very complex power management was requested, because you have to avoid to have a Raspberry turn off unexpected and the needed current implied to have a mechanism to shut down the system if the battery was running down and then turn it on automatically when the battery was charged (via solar or other means).
Also the Groove system was far to be perfect.
Nice maybe to experiment, but over-expensive , slow and complicated for a real solution.

I decided to redesign the fHelper this time around the Huzzah32, that has WiFi and BLE capabilities.
This should simplify the power management, no need for complex algorithm for the shutdown and restart, very small footprint and less current needed.

Shopping list


So we have few basic modules to use :




The Huzzah32










A capacitive soil sensor
This sensor doesn't use two electrodes with a running current but it measure the capacity between them, thus no corrosion on the electrodes and thus no electrophoresis, cause of the corrosion but also potentially cause of altering the soil composition.





A battery






The system

The idea is to have the Huzzah32 reading the soil sensor and then send a message (email/slack/something) when the system measure some levels.
Or maybe host a webserver showing the real time status.

An app will basically connect with the module in BLE for settings and WiFi for normal work.
The BLE will allow to assign WiFi settings and email/slack/other services.

In future maybe can be integrated for the solar panel and chargers.
This a very simple block schematic.
For development/test a Oled display can be used, however the final version would not use any local display if not maybe few LED to indicate the status.
This because the need to keep a small footprint of the code (the space on the Huzzah 32 is not much).

Interfacing the sensor


The first step is to be able to read the soil sensor.

The soil sensor used is a capacitive one.
It means that it translate the humidity level as capacity value.
This allows to avoid corrosion on the PCB traces. The traces are actually protected by the PCB coloring.
The sensor returns a value inversely proportional to the humidity level, i.e. more high the returned value, more dry is the soil.
The maximum value should be around 3500 (totally dry) and the minimum value 0 would indicate the sensor immersed in water.

The Huzzah32 has some limitations about the analog pins.
There are two ADC and one (the first one) is active only after the WiFi is enabled.
The second one doesn't have the limitations, so the sensor is connected to the ADC 2 Channel 2 (A2 - pin 34)

The ADC returns a value between 0 and 3500.
Where 0 is indicating totally wet and 3500 totally dry.

Calibration

In order to avoid to assign fixed values and considering the unstable precise measurement, the best approach is to have a calibration procedure to set up the system.
The code has to assume two values :
  • Dry
  • Wet
Initially Dry is set around 3000. Everything over 3000 indicate the need to add water (too dry).
The Wet value initially is set around 900. Everything below 900 indicate too much water.
Any value between the two indicate that the plant has enough water.

The calibration procedure allows to assign different values to Dry and Wet (and thus Normal that is the middle).
  • put the sensor in the soil when it is dry
  • start the calibration
    • 20 measurements are done 
    • the average is calculated and the value is assigned as Dry
  • Calibration waits
  • Add water to the plant until overflow
  • Continue calibration
    • 20 measurements are done
    • the average is calculated and the value is assigned as Wet
  • The Normal is considered any value between Dry and Wet

LED indicator


A LED indicator can be added to indicate locally the status of the system.
A single RED LED can indicate the conditions :

  • Off - normal - enough water on the plant
  • On - water the plant
  • Flashing - too much water

Timing

The reading of the sensor should be done once every minute.
Is useless to have more reading since the process measured is a slow one.
Even one reading every 5 minutes should be OK.
To do so a timer is implemented in order to trigger a reading every "n seconds".

Footprint

One of the challenge to use Huzzah is the limited space available for the code (using Arduino at least).
Approx 130k are available for the code and using BLE, adds a lot of extra code.
Also WiFi and the display can take quite some space depending what they have to do.

BLE for it's nature should be used only to set up WiFi and thus using WiFi to send out the notifications/data but because the amount of memory required can be tricky to use.

First release


As first release the system is wired for the WiFi in the office and is monitoring the humidity using the default settings.
The goal is to send a message on slack when the plant requires water.

System configuration - hardware


For this application we'll have the basic Huzzah32, with a battery as backup, power from a USB charger, the display and the sensor.

System configuration - software

As for the software side, the system will use the SSD1306 display library and the WiFi support library.
The sensor is read via analog, by default already present.



Referrals







No comments:

Post a Comment