[Swansea Hackspace] Controlling my kettle with Wemos D1 mini ESP8266

David Davies-Day djdavies83 at hotmail.com
Tue Apr 18 11:12:57 BST 2017


Hi all, thanks to everyone that tried to help me with this last night and hello to anyone who has not seen this yet.


Early this morning I fitted a tiny phone charger in the lowest part of the kettle and ran the 5V wires up to the 5V pads of the WeMos and it works.......

I have a few small problems Though, if the web page "Kettle On" button is pressed multiple times it keeps "pressing" the start button of the kettle and if you're not stood next to the kettle it is not possible to see if the kettle has started boiling. It stores the number of web button presses and continues till it has done them all.

This is the kettle...
https://www.aldi.co.uk/ambiano-temperature-control-kettle/p/094446104766000
[https://cdn.aldi-digital.co.uk/Electronic-Kettle-A.jpg?o=LzPEI6aArydOJkpWV%24SNfN1WGpcj&V=r4Jo&w=250&h=140&r=4]<https://www.aldi.co.uk/ambiano-temperature-control-kettle/p/094446104766000>

Ambiano Temperature Control Kettle - ALDI UK<https://www.aldi.co.uk/ambiano-temperature-control-kettle/p/094446104766000>
www.aldi.co.uk
A premium 1.5 litre kettle electronic control, an illuminated water gauge and 7 preset temperature settings for the perfect brew.

Can anyone help please?

I would like to find a way to only allow the pin and opto isolator (this is bridging the on button to simulate the button being pressed when the ESP pin is HIGH) to only "press" the on button once till the kettle has boiled or the web page cancel button (//commented out in code, not yet used), has been pressed.

The WeMos D1 mini I am using has one analogue in pin, it would be nice to be read a thermistor and display the value on the web page.
If anyone can point me to any suitable tutorials for my issues or give me some snipits of code to try that would be awsome, I would like do this all myself but if anyone want to write a full code that would also be cool.

Opto isolator for the button is on pin 5 active HIGH resting LOW.
indicator LED is on pin 2, active HIGH resting LOW.
Might be possible to tap existing thermistor, if not I can add a dedicated one.

Please find attched .ino file or see code below.
All the best, Dave.





/*******************************************************************
Written by Marco Schwartz for Open Home Automation.
BSD license, all text above must be included in any redistribution
Based on the original sketches supplied with the ESP8266/Arduino
implementation written by Ivan Grokhotkov
Modified by bsp.embed at gmail.com.
Check our YouTube channel BSPEmbed\
******************************************************************/

/* Required libraries */
#include <ESP8266WiFi.h>

/* WiFi Parameters of Your Router */
const char* ssid = "SKY0****";
const char* password = "HHYX****";

/* Create an instance of the server */
WiFiServer server(80);

/* Port Pins */

int output_pin = 5;
int Indicator_pin = 2;


void setup() {
  Serial.begin(115200);
  delay(10);
  pinMode(output_pin, OUTPUT);
  pinMode(Indicator_pin, OUTPUT);
  digitalWrite(output_pin, 0);      /* just to be sure it does not start the kettle on BOOT*/
  Serial.println();                             /* For debug console */
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);       /* Connect to WiFi network */

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

  Serial.println("");
  Serial.println("WiFi connected");

  server.begin();                   /* Start the server */
  Serial.println("Server started");
  Serial.println(WiFi.localIP());  /* Print the IP address */
  digitalWrite(Indicator_pin, 0);  /* Indicate by LED */
  delay (500);
  digitalWrite(Indicator_pin, 1);  /* Indicate by LED off */

}


void loop() {

  WiFiClient client = server.available(); /* Check if a client has connected */

  if (!client)
    return;

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

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

  if (req.indexOf("/on") != -1)        /* check the request */
    {digitalWrite(output_pin, 1);    /* set high for opto to "press button" */
    digitalWrite(Indicator_pin, 0);  /* turn LED on to indicate action*/
    delay (500);                     /* wait half a second for "press button" to be seen by kettle*/
    digitalWrite(output_pin, 0);     /* set low to opto to release "button press" */
    digitalWrite(Indicator_pin, 1);  /* turn LED off again */
    }

  else if (req.indexOf("/off") != -1) /* remnant of original code */
    digitalWrite(output_pin, 1);      /* remnant of original code */

  client.flush();               /* Prepare the response */

  String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
  s += "<head>";
  s += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
  s += "<script src=\"https://code.jquery.com/jquery-2.1.3.min.js\"></script>";
  s += "<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css\">";
  s += "</head>";
  s += "<div class=\"container\">";
  s += "<h1>Kettle Control V1.1</h1>";
  s += "<div class=\"row\">";
  s += "<div class=\"col-md-2\"><input class=\"btn btn-block btn-lg btn-primary\" type=\"button\" value=\"Kettle On\" onclick=\"on()\"></div>";
 // s += "<div class=\"col-md-2\"><input class=\"btn btn-block btn-lg btn-danger\" type=\"button\" value=\"Cancel Boil\" onclick=\"off()\"></div>";
  s += "</div></div>";
  s += "<script>function on() {$.get(\"/on\");}</script>";
  s += "<script>function off() {$.get(\"/off\");}</script>";

  client.print(s);       /* Send the response to the client */
  delay(1);
  Serial.println("Client disconnected");

  /* The client will actually be disconnected */
  /* when the function returns and 'client' object is detroyed */
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://swansea.hackspace.org.uk/pipermail/hackspace/attachments/20170418/124d5a28/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Kettle_Control_V1-1.ino
Type: application/octet-stream
Size: 3737 bytes
Desc: Kettle_Control_V1-1.ino
URL: <http://swansea.hackspace.org.uk/pipermail/hackspace/attachments/20170418/124d5a28/attachment.obj>


More information about the Hackspace mailing list