HomeHome AutomationHacking ESP8285 GeekCreit 4 Way relay controller

Hacking ESP8285 GeekCreit 4 Way relay controller

Got 4 relays, let's control it with ESP8285 and custom firmware

What an adventure it was. For the first time, I started the livestream not knowing what’s ahead. Determined and armed with Google, I started the livestream and proceeded with taking the case of the ESP8285 GeekCreit 4 Way relay controller apart. It’s was a good learning experience, I’m glad some of you were there to cheer, help and keep my company! This is how you can hack the ESP8285 GeekCreit 4 Way relay controller.

ESP8285 GeekCreit 4 Way relay controller

The controller has been given to me by a hackspace friend. A rather unknown board after some Googling turned out to be the ESP8285 GeekCreit 4 Way relay, controller. Armed with this knowledge, I found a rather confusing product sheet. Confusing, as images are mirrored and everything is written in Chinese.

I’m not the one to give up quick, so I started to try things out. For the sake of your time, I have created the complete pinout for you. If you want to refer to the original datasheet be my guest.

ESP8285 pinout

The pinout itself on the pictures was confusing so I took the liberty of redesigning it.

ESP8285 PSF-B04 Pinout

PINNAMEFUNCTION
1ANTAntenna
2ADCInterface, Input Range: 0 – 1V
3CH_ENChip Enable High: Active; Low: Off. Note: External pull-up 1~10K resistor, connect 100nF capacitor to ground
4GPIO16 
5GPIO145S Enter configuration mode”}”>Channel 4 switch pin, active low APP configuration pin, low level >5S Enter configuration mode
6GPIO12Channel 1 relay switch, active high Note: as a switch button, on The electric moment will be high for a period of time, need to pull down (1~4.7K) resistor to ground
7GPIO13Wi-Fi status indicator, connect LED series current limiting resistor to VCC
8GPIO15channel 4 relay switch, Active high: Chip configuration pin, need pull-down (1~4.7K) resistor to ground
9GPIO02can be used as flash memory UART1_TX
10GPIO005S Enter configuration mode”}”>channel 1 switch pin, active low APP configuration Pin, low level>5S Enter configuration mode
11GPIO4Channel 3 relay switch, active high 1
12GND 
13GPIO095S Enter configuration mode”}”>Channel 2 switch pin, active low APP configuration pin, low level >5S Enter configuration mode
14GPIO105S Enter configuration mode”}”>Channel 3 switch pin, active low APP configuration pin, low level >5S Enter configuration mode
15GPIO11 
16GPIO06 
17GPIO07 
18GPIO08 
19GPIO05Channel 2 relay switches, high active
20GND 
21RXwhen used for programming Flash UART_RX
22TXat programming Flash UART_TX
233.3V (VCC)external power supply
24RSTreset signals: active low

Having the ESP8285 pinout is one thing, but mapping this to an existing board is another. While the AFE Firmware I’m going to use have most of the mapping done, knowing what’s what is crucial when it comes to writing custom code. This is the board and the connections:

ESP8285 GeekCreit 4 Way relay controller Pinout

GPIOFUNCTION
GPIO00connect to GND on boot to enter flash mode
GPIO04control relay 03
GPIO05control relay 02
GPIO12control relay 01
GPIO14control pairing button
GPIO15control relay 04
TXconnect to RX of the programmer
RXconnect to TX of the programmer
GNDconnect to GND
3.3Vconnect to power

To flash a ready bin file or your own Arduino IDE code, you have to back up, wipe the flash and upload the new bin file or the Arduino code. The procedure is described in detail here.

Please note, this board has to be powered via serial adapter AND the USB power supply when flashing the bin files.

I’m going to cover the AFE Firmware, which is pretty easy to use, if you want to push your own code, just open the Arduino IDE and flash it using the ESP8285 module in the board manager.

Before you get irritated, the ESP8285 GeekCreit 4 Way relay controller has a function button which drives the board modes. There is only one mode in which the board will function properly so circle the mode couple of times and try it out.

AFF Firmware on ESP8285 GeekCreit 4 Way relay controller

If you are feeling lazy, Adrian Czabanowski created the firmware for this (and other) controllers. You can find his firmware on the website www.smartnydom.pl but a lot of it is in Polish.

Fortunately, you have me, and I’m here to make it easy – and download the Firmware for your board with up to 4 relays (T4). There is a version for ESP8266 and ESP8285 so make sure you get the right one. Flash the firmware (rename it to something simple) so you don’t have to type all that in the PowerShell.

Once the firmware is flashed, hold the pairing button for about 10 sec. You will see the board’s LED blinking fast. The ESP8285 GeekGerit 4 Way relay controller will go into the AP mode. Check the SSIDs on your phone and you will see the AFE Device – connect to it and note the gateway IP – usually, it’s something like:

192.168.5.1

And connect to it. Don’t bother with setting up everything on your mobile, unless you don’t have a PC around. Just update the Network details and finish the configuration. Once this is done, the ESP8285 GeekCreit 4 Way relay controller will get a new IP assigned by your router.

Load the device page and enter settings again. From here you will be able to configure the device to your needs. Select the number of relays (4 – GPIO12,04,05,15), switches (1 – GPIO14) and LEDs (1 – GPIO13)

Enable the MQTT and HTTP protocols and check the general configuration. Make notes of anything you don’t think you can remember as we will need this to use the MQTT and HTTP protocols.

MQTT and HTTP

There are 2 protocols that can be used to interact with the ESP8285 GeekCreit 4 Way relay controller. Both have their own advantages and I will show you how to link these to a NodeRED server. If you want to learn more about MQTT and HTTP in NodeRED I have a fantastic tutorial for you.

MQTT

The ESP8285 GeekCreit 4 Way relay controller comes with 4 relays that we can toggle. The MQTT broker allows you to specify the topic for the device, but to control each of the relays we have to modify that topic more.

Let’s say I use the topic name /esp8285/ this means that to control the relays, I will have to add the name of each relay (from the config page) to the topic.

/esp8285/switch1/
/esp8285/switch2/
/esp8285/switch3/
/esp8285/switch4/

To issue the commands I have to modify the topic further:

MQTT commands
TOPIC Message Result
/ESP8285/cmd reboot Reboot ESP8285
/ESP8285/cmd configurationMode Open config mode
/ESP8285/state connected publish on connected (only firmware T0,T1,T2)
/ESP8285/state disconnected publish on disconnected (only firmware T0,T1,T2)
/ESP8285/switch1/cmd on turn on “switch1”
/ESP8285/switch1/cmd off turn off “switch1”
/ESP8285/switch1/cmd toggle toggle “switch1”
/ESP8285/switch1/cmd get get status of the “switch1”
/ESP8285/switch1/get defaultState set “switch1” to default state (see config settings)
/ESP8285/switch1/state on OR off “switch1” sens this message back each time it changes the state
/ESP8285/configuration/api/http/cmd on OR off enable/disable HTTP API
/ESP8285/configuration/api/domoticz/cmd on OR off enable/disable Domoticz API
/ESP8285/configuration/api/mqtt/cmd off disable MQTT API

As you can see, this is fairly straight forward, and the control of each relay is done by modifying the topic and setting a correct payload.

HTTP requests

Another way of controlling the ESP8285 GeekCreit 4 Way relay controller is through the HTTP requests. Most of the time, you will be composing the URL which has embedded commands that will be issued to the board.

To build a valid URL you will need:

https://IP_Address/?device=relay&name=RelayName&command=command

Make sure to reserve the static IP address. The fields in my example are as follow:

command = on/off/get/toggle
RelayName = switch1/switch2/switch3/switch4

The responses given are sent in a JSON format. If you not sure how to handle JSON I have the tutorial explaining all you need to know here.

Here are a couple of JSON samples:

{ „device”:”ESP8285”, „name”:”switch1”, „command”:”on”, „value”:”on”, „status”:”success” }
{ „device”:”ESP8285”, „name”:”switch1”, „command”:”get”, „value”:”off”, „status”:”success” }
{ „command”:”reboot”, „status”:”success” }

Lastly, to control the MQTT, HTTP and other APIs links look like:

https://IP_Address/?device=DeviceName&name=ApiName&command=command

Where Apis names are: mqtt, http, domoticz.

Conclusion

The AFE Firmware is a cool solution if you don’t want to code the HTTP and MQTT protocols yourself. It’s robust enough to link it with the Alexa and Google Home skills. I’d love to see support for HTTPS and other integrations, but for now, this is a quick and easy way to integrate the ESP8285 and ESP8266 switches into your NodeRED environment. I wrote a very basic NodeRED flow to control and display the status of the relays on the dashboard. You can grab these files from below.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.