Programming

There are many firmwares supported with the Smart Garden V1 (almost any supporting the ESP-32). Some of the tested working are:
  • ESPHome

  • Tasmota

  • Arduino

In any case scenario, and regardless you are using the USB port or the Serial port for programming it, you will first need to enter the board into flashing mode. For that, press and hold the Flash pushbutton while you reset the board (pressing once the Reset pushbutton).

Caution

When flashing the board, make sure its only powered by the USB/Serial port.

Note

It is possible that after flashing your board and while rebooting, the ESP-32 has some issues to boot. This is due to a higher demmand of power while

ESPHome

ESPHome is a well known platform for programming ESP-based devices with a very little effort. It is configured via YAML files and supports a wide range of functionalities and sensors.

Important

For using ESPHome, and all its funcionalities, you need to have a Home Assistant instance running in the same network as your Smart Garden V1.

_images/captive_portal-ui.png

The Smart Garden V1 already comes with an embeded version of ESPHome, that would only require an OTA update to get it ready to work in your network:

  1. Power the board, and let it run for 1-2 minutes. When the board cannot connect to a WiFi network, it will create a fallback hotspot.

  2. Use a smartphone or tablet and go to the WiFi settings, connect to the recently created Smart-Garden hotspot with the password smartgarden.

  3. Access to the captive portal and open the browser if doesn’t pop up automatically.

  4. Enter your network setttings and press Save.

Now, your ESPHome device is ready to be found by Home Assistant in your network. Add it from the ESPHome section to add and edit a customized configuration file.

As an example of such configuration file (and the one flashed on the factory settings of the Smart Garden V1) with all the I/O:

 1substitutions:
 2  device_name: "smart-garden"
 3  friendly_name: "Smart Garden"
 4  project_name: "smart.garden"
 5  project_version: "1.0"
 6  ap_ssid: "Smart-Garden"
 7  ap_pwd: "smartgarden"
 8
 9esphome:
10  name: "${device_name}"
11  name_add_mac_suffix: true
12  project:
13    name: "${project_name}"
14    version: "${project_version}"
15
16esp32:
17  board: esp32dev
18  framework:
19    type: arduino
20
21# Enable logging
22logger:
23
24# Enable Home Assistant API
25api:
26
27# Enable Over The Air updates
28ota:
29
30#Public location of this yaml file
31dashboard_import:
32  package_import_url: github://JGAguado/Smart_Garden/docs/source/files/configuration.yaml
33  import_full_config: false
34
35# Enable fallback hotspot (captive portal) in case wifi connection fails
36captive_portal:
37
38esp32_improv:
39  authorizer: none
40
41improv_serial:
42
43wifi:
44  ap:
45    ssid: "${ap_ssid}"
46    password: "${ap_pwd}"
47
48# These relays will automatically turn off after 2 minutes
49switch:
50  - platform: gpio
51    pin: 16
52    id: relay_1
53    name: "Zone 1"
54    icon: "mdi:sprinkler-variant"
55    on_turn_on:
56    - delay: 120s
57    - switch.turn_off: relay_1    
58    
59  - platform: gpio
60    pin: 17
61    id: relay_2
62    name: "Zone 2"
63    icon: "mdi:sprinkler-variant"
64    on_turn_on:
65      - delay: 120s
66      - switch.turn_off: relay_2
67    
68  - platform: gpio
69    pin: 18
70    id: relay_3
71    name: "Zone 3"
72    icon: "mdi:sprinkler-variant"
73    on_turn_on:
74      - delay: 120s
75      - switch.turn_off: relay_3      
76    
77  - platform: gpio
78    pin: 19
79    id: relay_4
80    name: "Zone 4"
81    icon: "mdi:sprinkler-variant"
82    on_turn_on:
83      - delay: 120s
84      - switch.turn_off: relay_4  
85
86sensor:
87  - platform: adc
88    pin: A4
89    name: "VCC"
90    update_interval: 60s
91    filters:
92      - calibrate_linear:
93          - 0 -> 0
94          - 0.55 -> 5

Tasmota

As an alternative easy-to-use and still powerfull, you can flash Tasmota into the Smart Garden V1 directly. This option is higly recommendable if you want to want to have an Alexa compatible device (based on a Hue emulated bridge) without the need of a full Home Assistant setup.

_images/tasmota.png

The easiest process of flashing Tasmota into your Smart Garden V1 goes as follows:

  1. Plug the Smart Garden V1 into your computer’s USB.

  2. Go to the Tasmota Web Installer

  3. Follow the process selecting ESP32 as device and select the correct port (remember to enter the board into flashing mode).

  4. After the process is completed, press the reset button.

  5. Once rebooted, the Smart Garden V1 will create a wifi hotspot containing the name Tasmota. Connect and enter your WLAN setup on the captive portal.

  6. Get the IP assigned to the board (check your router’s connected devices) and enter it into your browser for accessing to the Tasmota’s WebUI.

Now you can customize your board as you want. Let’s first assign the output class ‘Relay’ to the corresponding outputs 16, 17, 18 and 19.

In addition, some of these other commands can be entered through the Console (Consoles -> Console):

  • Timed output: With the command PulseTime3 300 you can make that the output 3 turns off after 5 minutes (300s). This option is highly indicated as a safety feature to prevent your home to get floaded.

  • Interlocks: With the command interlock on you can make that ONLY one of the 4 outputs can become active at the same time. For selecting the group of the for relays just use the command interlock 1,2,3,4. This mode can become usefull when your home’s water pressure is not high enough for holding more than one watering zone at the same time.

In any case, you can find these and much more commands to customize your Tamota’s flashed Smart Garden V1 on the official Tasmota documentation

And, by the way…

If you want Alexa to directly recognize your Smart Garden V1 to directly controle each output through voice controls, go to COnfiguration -> Configure Other and select the option ‘Hue Bridge multi device’ emulation.

Arduino

If you are still interested in programming directly with the Arduino IDE, the procedure is no different than with any other ESP32 devices:

  1. Open the Arduino IDE and go to File -> Preferences option.

  2. Add to the Additional Boards Manager URSLs the url:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  1. Close the preferences and open in the menu Tools -> Board -> Boards Manager

  2. Search for esp32 and install it. This might take some time

  3. Now you can select the board ESP32 Dev Module as the target board. Leave the rest of parameters by default.

  4. Select the correct port and remember to enter the board into flashing mode before uploading the sketch.