Esp32 section control

Configuration in ago, see

In machine.ino:
You have to define the GPIO Pin for each channel which are wired to your relay board:

see line 50:

I have modified the code as you instructed for the following GPIO: 15, 2, 4, 16, 17, 5, 18, 19.
As far as I know, when I configure the machine board, it should turn green, but this does not happen.
The relays keep clicking continuously.
Here are some videos and pictures of it
https://drive.google.com/drive/folders/1Xa1T6lodRSiidMeaFf9aScccqTKc7oos?usp=sharing

It seems like your ESP32 is restarting every little bit. Can you watch on the serial monitor to verify?

Edit: which code base are you using? The official code from aghardware, or MTZ8302 code? I might take a look when I get back to the computer.

I use this code

Why not use the MTZ8302 code? I did run the Arduino_USB_v5 code, the ESP is resetting every second or so, due to a watchdog timer.

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc

But the MTZ code was made to run on an esp, so it would be better to just use it. Note that you must install the esp32 library version 2, not v3.

May you have problems caused from using a bootstrap pin.

First check out via serial monitor if esp32 reboots all the time.

Disconnect all relay channels and try one by one. For the first test, define only one channel in firmware and test it together with the relayboard. First try non Bootstrap pins like GPIO 4,15,17,18,19

Without following changes esp32 would not save configuration data in eeprom:

For ESP32 eeprom handling you have to add EEPROM.commit(); in the following lines:

image

image

edit
I forgot,
Instead using resetFunc() add esp_restart();

I did some test and figured out that connecting GPIO 2 to relay board causes such malfunction.

So use 15,4,16,17,5,18,19,23

Here you can find the adapted firmware for usb (GPIOs: 15,4,16,17,5,18,19,23):
Machine_USB_ESPv5.zip (3,5 KB)

Don’t forget to connect your machine usb port in AGIO !!!
image

https://drive.google.com/drive/folders/1Xa1T6lodRSiidMeaFf9aScccqTKc7oos
Its workiiiiiing
Thank you soo much​:partying_face::partying_face::partying_face:

1 Like

Hello
Can I use switches for manual control in this code?

No, if there is need for it, better use MTZ8302 code. It’s easily configurable, I’m using it for years without problems.

Hint there is also another ESP version based on MTZ8302 code, maybe it suits better for you:
(There you can also find a nice wiring example for your ESP setup)

GitHub - gg1212/AgOpenGPS_SectionControl_ESP32: AgOpenGPS WiFi UDP Section Control running on ESP32 - v5.7.2 ready

see topic:
Mueller SprayControl section control - Hardware / Section Control - AgOpenGPS

1 Like

What needs to be edited in the code if I don’t have a main switch, only 5 switches for the 5 sections?
Because there is a problem that when I turn on the automatic section control, it immediately turns off.

I don´t know about the code, but make sure you are inside the field boundary, else auto can´t turn on.

invert relay??

I changed it, but the problem is the same.

Yes, a field is open, and if I remove the ESP32, it works, but when it connects again, it immediately turns off.

Which AOG version and at what speed du you drive

Because the switch PGN contains the main switch data. You’d have to modify the Arduino code to show the master on when one of the section switches is on.

Set SectMainSWType = 0;

1 Like

Thank you!

I am trying to compile the MTZ8302 code in ARDUINO IDE but I can’t get rid of the following errors.

I have selected ESP32 DEV MODULE
ESP32 library version 2

1

ERROR;
C:\Users\AD\OneDrive\Escritorio\DANI\08 - AOG Section Control for MTZ8302\AOG_SectionControl_ESP32-master\AOG_SectionControl_ESP32\zAOG_SC_Network.ino: In function ‘void WiFi_STA_connect_network()’:
C:\Users\AD\OneDrive\Escritorio\DANI\08 - AOG Section Control for MTZ8302\AOG_SectionControl_ESP32-master\AOG_SectionControl_ESP32\zAOG_SC_Network.ino:347:54: error: conversion from ‘unsigned int’ to ‘IPAddress’ is ambiguous
347 | if (WiFi_STA_connect_call_nr == 0) { WiFi.config(0U, 0U, 0U); Serial.println(“enable DHCP for WiFi”); WiFi_STA_connect_call_nr++; }
| ^~
In file included from C:\Users\AD\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/Arduino.h:199,
from C:\Users\AD\AppData\Local\arduino\sketches\65D23C6FE0479FD4DF8BA2E7D664436E\sketch\AOG_SectionControl_ESP32.ino.cpp:1:
C:\Users\AD\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/IPAddress.h:116:3: note: candidate: ‘IPAddress::IPAddress(const ip_addr_t*)’
116 | IPAddress(const ip_addr_t addr);
| ^~~~~~~~~
C:\Users\AD\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/IPAddress.h:73:3: note: candidate: 'IPAddress::IPAddress(const char
)’
73 | IPAddress(const char address);
| ^~~~~~~~~
C:\Users\AD\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/IPAddress.h:70:3: note: candidate: 'IPAddress::IPAddress(const uint8_t
)’
70 | IPAddress(const uint8_t *address);
| ^~~~~~~~~
C:\Users\AD\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/IPAddress.h:68:3: note: candidate: ‘IPAddress::IPAddress(uint32_t)’
68 | IPAddress(uint32_t address);
| ^~~~~~~~~
In file included from C:\Users\AD\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFi.h:34,
from C:\Users\AD\OneDrive\Escritorio\DANI\08 - AOG Section Control for MTZ8302\AOG_SectionControl_ESP32-master\AOG_SectionControl_ESP32\AOG_SectionControl_ESP32.ino:192:
C:\Users\AD\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiSTA.h:140:25: note: initializing argument 1 of ‘bool WiFiSTAClass::config(IPAddress, IPAddress, IPAddress, IPAddress, IPAddress)’
140 | bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000);
| ^~
C:\Users\AD\OneDrive\Escritorio\DANI\08 - AOG Section Control for MTZ8302\AOG_SectionControl_ESP32-master\AOG_SectionControl_ESP32\zAOG_SC_Network.ino: In function ‘void WiFi_Start_AP()’:
C:\Users\AD\OneDrive\Escritorio\DANI\08 - AOG Section Control for MTZ8302\AOG_SectionControl_ESP32-master\AOG_SectionControl_ESP32\zAOG_SC_Network.ino:358:13: error: ‘SYSTEM_EVENT_AP_START’ was not declared in this scope; did you mean ‘WIFI_EVENT_AP_START’?
358 | while (!SYSTEM_EVENT_AP_START) // wait until AP has started
| ^
~~~~~~~~~~~~~~~~
| WIFI_EVENT_AP_START
exit status 1

Compilation error: conversion from ‘unsigned int’ to ‘IPAddress’ is ambiguous

can anyone help me?