WiFi power sockets for brewery controllers

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

clearwaterbrewer

Supporting Member
HBT Supporter
Joined
Aug 20, 2010
Messages
1,033
Reaction score
144
Location
Clearwater, FL
Is there a list of brands and models of wifi power sockets/strips out there that will accept http commands or otherwise can be directly controlled from a script, without having to use a hub or the cloud?
 
I don’t the answer to your question directly, but I am certain all the WiFi units have a protocol. Whether it is published or not, and whether the protocol uses http or not is of course the challenge.

Look at the Sonoff hacking resources - seems to be a relatively big community of knowledge out there.
 
I'd almost guarantee you any 'cloud connected' power strip is using an http based API (i.e. REST) just because that's the popular thing to do these days. It's almost certainly not intended for your direct use and probably would require you impersonating the cloud server.

Depending on your use case, some of the units can have quite a bit of delay from when you send a command to the outlet switching. If you need tight control, it'd probably be better to build your own from a RPi and relay shield or similar.
 
Sorry, really not what I am looking for... I can make it out of a Pi and already have, but would nice to have a one piece, proven reliability, pre-assembled, UL listed, off-the shelf, apply a small hack/patch, and it ties into your system...

I understand that they use API's, I would like to compile a list of those that have a known way of interfacing so that people can just go buy that model, do a couple things, and it does what you need... Ideally, it would be one of the newer models that is smaller and you can fit them side-by-side on a power strip and they have a button on them so you can override... two way communication would be a plus...
 
I’m pretty confident every WiFi switch will work locally. They often use a hub that communicates to a cloud server but each receives commands via local network. I guarantee there are a bunch. The protocol is the tricky part, as some won’t want to expose it.
 
if they have any decent crypto in them to prevent them from being part of a botnet, then whatever you control them with will have to have the crypto key, and they may limit that to their app or headend device like alexa...
 
I was thinking the same thing about the crypto aspect.
You'd actually want it there for security purposes - but then if you want to cut The Mother Ship out of the loop you're stuck with solving it...

Cheers!
 
So 7 posts in, I am back to my original question:

Is there a list of brands and models of wifi power sockets/strips out there that will accept http commands or otherwise can be directly controlled from a script, without having to use a hub or the cloud?

not trying to be mean or trying to be flame-bait, but please reply only if you find a specific model that you can document the ability for it to take commands from a non proprietary device that we could possibly replicate with an html script for brewery automation.
 
I use Wemo mini outlets to control my chuggers and they work great. I'm working on a Craftbeerpi plugin now and I'll post it here when I'm done.
 
so now I have the Sonoff S31's sitting on my desk, with pin header temporarily soldered on, and the usb-ttl connected, and I am still kinda lost as to what I am programming them with, (tool, firmware, etc...) do I need to install the "Arduino IDE?" Is there a simpler way to program the 'sketch' that I think I want than installing a complete IDE?
 
If you have the compiled code then you can use ESPYTOOL. If you have the uncompiled sketch the you need the IDE or a DE.

Can I program these to work with BruControl similar to how one would program a normal arduino? would I still need the IDE installed to write the sketch thing, or is that function and/or compiling something BC does?
 
We have put BC firmware on different Sonoff modules and have an application note on the website. Should be no reason you can’t do the same with the S31. I am not sure the I/O ports. But I will buy one and test it.
 
OK, I figured that out last night. Two new questions:
- Is there a way with the BC tools to copy or backup what is on the Sonoff device currently and put it back on?
- do I use one of the selections in the InterfaceSetup.bat , the two Sonoff ones look similar with the exception of the '-bm dio' argument
 
Yes and no! You do need a USB-serial module though since these boards do not have USB micros on board. But it looks like you have it and have soldered in the header above.

all set, including set to 3.3v so I don't fry it:
IMG_20180702_135045.jpg
 
OK, I figured that out last night. Two new questions:
- Is there a way with the BC tools to copy or backup what is on the Sonoff device currently and put it back on?
- do I use one of the selections in the InterfaceSetup.bat , the two Sonoff ones look similar with the exception of the '-bm dio' argument

The current firmware cannot be pulled off the board with any tools I am aware of.

It depends on the chip that the S31 uses. It probably doesn’t matter but I would try the one with the argument first.
 
OK, it took the 'c' program for the TH10/16... BruControl.43A.SonoffTH.W.bin

Network programming is proving to be a bit more difficult, I tried doing it right after the firmware, and after unplugging and plugging back in both without and with button pressed.... no method gives a response from sending %0&15; via termite...

I don't see anything regarding SonOff in the manual appendix, so treating it like a 8266
 
no, termite comes up, but is unresponsive...

(to verify I did not fry it, I wrote the firmware again...)
I am not sure if there are any nuggets of information in the code that people use for Blynk, but here is the link to it.

edit: - I also tried with HyperACCESS at 115200, 8N1, no response... I wouldn't put it past my usb-ttl converter being too cheap
 
Last edited:
Give it a minute or two after entering the code. If it doesn’t respond, this makes me think the FW is not working on that device. If you don’t mind waiting a few days, I will get one to test and validate it.
 
OK, so here is the dealio... I disassembled this bad boy. It is a neat little unit. BUT, I honestly do not not see much value is making this unit work, at least not for public consumption. Reasons:

1. Header termination requires soldering to pads. This renders the case useless if the header is left on, or would require removal of the header following each FW update/network edit/debug session. It would be possible to solder a ribbon cable I suppose, which is what I will do, but I don't see this being too practical for many users.
2. There is no easy way to attach any peripherals such as a temp probe. The other Sonoff's we implemented provided a sweet pathway to a fermentation controller allowing for two outputs and a temp probe. Just sayin'!

That said, I will flash it and see what happens for academic purposes. Stay tuned!
 
Yes, the Blynk article refers to using an 'over the air' OTA image and method of programming so the solder is used just one time.

Here is their OTA version:


Code:
/*************************************************************

  ITEAD Sonoff S31 - OTA version for the Blynk app.
 *************************************************************/

/* Comment this out to disable prints and save space */
//#define BLYNK_PRINT Serial

#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

int buttonPin = 0;              // Sonoff On/Off button
int relayPin = 12;              // Sonoff relay
int ledPin = 13;                // Sonoff green LED - always on
int relayStatus = 0;
// variables will change
int buttonState = LOW;          // variable for reading the pushbutton status
int lastButtonState = HIGH;     // previous state of the button
int relayState = LOW;
int ledState = LOW;
int volts = 0;

long lastTime = 0;              // the last time the output pin was toggled
long debounce = 200;            // the debounce time, increase if the output flickers

// Your WiFi credentials.
// Set password to "" for open networks.
const char* ssid     = "ssid";
const char* password = "passward";
char auth[] = "blynk authorization"; // Sonoff S31 "4M(3M SPIFFS)"

WidgetLED led1(V10); // Widget Relay LED

BLYNK_WRITE(V1) { // Widget relay button
  relayStatus = param.asInt();
  if (relayStatus == 1) {
    relayState = HIGH;
  }
  else {
    relayState = LOW;
  }
} // end - BLYNK_WRITE(V1)


void setup() {
  Serial.begin(115200);
  Serial.println("Booting");

  Blynk.begin(auth, ssid, password);
  while (Blynk.connect() == false) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  // ============ OTA =============
  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  // ============ OTA end =============

  pinMode(buttonPin, INPUT);  // on/off button
  pinMode(relayPin, OUTPUT);  // relay
  pinMode(ledPin, OUTPUT);    // led
  digitalWrite(ledPin, LOW);  // always on
}

void loop() {
  ArduinoOTA.handle();
  Blynk.run();
  pushButton();
  ledStatus();

}

void pushButton() {
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH && lastButtonState == LOW && millis() - lastTime > debounce) {
    if (relayState == HIGH) {
      relayState = LOW;
      Blynk.virtualWrite(V1, 0);
    }
    else {
      relayState = HIGH;
      Blynk.virtualWrite(V1, 1);
    }

    lastTime = millis();
  }

  digitalWrite(relayPin, relayState); // Relay open/close - digital pin 12
  lastButtonState = buttonState;
} //end - pushButton()


void ledStatus() { // Widget LED - relay status
  ledState = digitalRead(relayPin);
  if (ledState == HIGH)
    led1.on();
  else
    led1.off();
}
 
Still hoping that the form factor and cost of the S31, and maybe someday the energy consumption ability can be utilized by something like BruControl.

Saw this INKBIRD C919 Wi-Fi Digital Smart 110V 1500W Temperature Controller today, a bit pricey, but might have possibilities... but might not be 'open' to being controlled without the IOS app :-( if anyone has one already and can give us information, it would be appreciated.
 
Last edited by a moderator:
I'm using craftbeerpi3 and the HTTP actor plugin. Easy and cheap. Can control relays and ssrs through an esp8266 or esp32.
 
per original post, what brand/model of wifi power socket are you using... and how(specifically, not just 'arduino IDE' ) did you program it? pics?


Ah sorry yes you are right. It is not entirely linked to the original post sorry and information lacking. I made my own small setup with esp8266 chip and the small generic 10A relays. The esp8266 controls two relays.

The craftbeerpi3 plugin has information on the settings to apply when setting up an 'http actor'. This is run on a raspberry pi.


I used Arduino IDE updated with board manager to use esp8266. Then used following code adapted from an example found on the internet. The server_ip being that of the esp8266


/*
* This sketch demonstrates how to set up a simple HTTP-like server and uses the GPIOs 0 and 2 to control a fermentation fridge
* The server will set a GPIO pin depending on the request
* http://server_ip/gpio/0 will set the GPIO0 low, which is my chiller within craftbeerpi3
* http://server_ip/gpio/1 will set the GPIO0 high, which is my chiller within craftbeerpi3
* http://server_ip/gpio/0 will set the GPIO2 low, which is my heater within craftbeerpi3
* http://server_ip/gpio/1 will set the GPIO2 high, which is my heater within craftbeerpi3
* server_ip is the IP address of the ESP8266 Arduino module, will be
* printed to Serial when the module is connected.
*/

#include <ESP8266WiFi.h>

const char* ssid = "your wifi router here";
const char* password = "your password here";

// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);

void setup() {

// prepare GPIO0 and GPIO2
pinMode(0, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(0, 1);
digitalWrite(2, 1);

Serial.begin(115200);
delay(10);

// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Start the server
server.begin();
Serial.println("Server started");

// Print the IP address
Serial.println(WiFi.localIP());
}

void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}

// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}

// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();


// Match the request of gpio0
int val0;
int val2;
if (req.indexOf("/gpio0/0") != -1)
val0 = 1;
else if (req.indexOf("/gpio0/1") != -1)
val0 = 0;
else if (req.indexOf("/gpio2/0") != -1)
val2 = 1;
else if (req.indexOf("/gpio2/1") != -1)
val2 = 0;
else {
Serial.println("invalid request");
client.stop();
return;

}


// Set GPIO0 according to the request
digitalWrite(0, val0);


// Set GPIO2 according to the request
digitalWrite(2, val2);

// client.flush();


}




p.s. Will start work on some pictures and a youtube video of the operation if this information is of use to anyone?


p.p.s The more I think of this it might be hard to follow what I'm writing here. I can start work on a step to step guide if of interest to anyone.
 
Last edited:
yes, a step by step would be awesome, from there I can try to make it work on the S31, which is 8266 based, but needs OTA programming there are guides out there for some stuff, like the Blynk one in post #11, but they seem to leave out just enough specific to us that I am not sure I am going to brick it...
 
Ive attached some pictures to let you know the current state. I am in prototype mode but it all works. 2 x esp8266 wifi chips. One controls heat and chill relays through the craftbeerpi3 software on raspberry pi through wifi. Other sends 3 x ds18b20 temperature sensors to raspberry pi to be used by craftbeerpi3. The raspberry pi also picks up my tilt hydrometer SG and sends it into craftbeerpi3. As you will see from the pictures i just need a wee bit of time to go back through what I have done and write it in a logical manner for others to understand, so bear with me on this :)

Also. When programming these esp8266 chips you must pull pin gpio0 low to allow to program.

https://ibb.co/m3M1xU
https://ibb.co/gwF5P9
https://ibb.co/i21OBp
https://ibb.co/f4nwWp
https://ibb.co/goqTcU


m3M1xU

gwF5P9

i21OBp

f4nwWp

goqTcU
 
OK, finally got these S31's working, Programmed with Tasmota using a Pi running esptool, and they even have the energy monitoring in place...

The CBPi3 MQTTplugin that i am controlling them is not exactly robust or simple to set up, however, The Tasmota-MQTT part seems rock solid..

A step by step write-up to come... here is the direct web page the device provides...

SonOff Tasmota S31.png

IMG_20181027_141222.jpg
 

Latest posts

Back
Top