Hi there,
i’m doing this project to control a coffee machine with arduino uno+esp8266+Blynk and most of it i could do by my self, now let’s go to the questions, as you can see i’m not a profesional programmer, i’m learning, so i have this DS18B20 which i could connect to the arduino and send temp’s to Blynk easily following some posts on this forum.
1- But now i’m having some trouble, i can connect to the esp8266 with the app but connection just starts after i start serial monitor on ArDUINO IDE if i don’t start serial monitor it looks like the ESP8266 does not connect to the WIFI any reason why?
2- I have 2 relays one connected to pin 5 which will power the machine on/off and that is very easy to do without code, just using widgets on the app i could even add a temperature condition to prevent the coffee machine from overheating.
And the second relçay is connected to pin 4 which will take the coffee, if i press Virtual button 1 on the app it will take a short coffee (16 seconds long) if i press Virtual button 2 it will take a long coffee (32 seconds long)
this is a 4 relays module that change their state when you give GND on their pins so when is HIGH relays are not energized and when is LOW they change state, the thing is everytime i restart arduino power pin 4 (or arduino) stays low for a while and just changes state to HIGH after i login on Blynk app and start playing with the buttons, after this it works perfectly fine… any tips about this??
My code in here:
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
WARNING!
It's very tricky to get it working. Please read this article:
http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware
You’ll need:
- Blynk App (download from AppStore or Google Play)
- Arduino Uno board
- Decide how to connect to Blynk
(USB, Ethernet, Wi-Fi, Bluetooth, ...)
There is a bunch of great example sketches included to show you how to get
started. Think of them as LEGO bricks and combine them as you wish.
For example, take the Ethernet Shield sketch and combine it with the
Servo example, or choose a USB sketch and add a code from SendData
example.
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SimpleTimer.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "70bafab20f6f48d58b22223d6fe9cf27";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "MatosDurkinhousehold";
char pass[] = "MatosDurkin2017";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial
SimpleTimer timer;
#define Pin 2// pin DATA ds18b20
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
OneWire ourWire(Pin);
DallasTemperature sensors(&ourWire);
////////////////////////////////////////////////////////////////////////////////////////////////relay 1 Short coffee
BLYNK_WRITE(V1) // Virtual button on Vx to activate action
{
int BTN = param.asInt();
if (BTN == 1) {
digitalWrite(4, LOW); // Set pin high
timer.setTimeout(16000, ActionOFF); // Run ActionOFF function in 16 seconds
}
}
void ActionOFF()
{
digitalWrite(4, HIGH); // Set pin Low
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Relay 1 Long Coffee
BLYNK_WRITE(V2) // Virtual button on Vx to activate action
{
int BTN = param.asInt();
if (BTN == 1) {
digitalWrite(4, LOW); // Set pin high
timer.setTimeout(32000, ActionOFF2); // Run ActionOFF function in 32 seconds
}
}
void ActionOFF2()
{
digitalWrite(4, HIGH); // Set pin Low
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
// Debug console
Serial.begin(115200);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
sensors.begin();
delay(10);
//pinmodes
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
Blynk.begin(auth, wifi, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8442);
}
void loop()
{
sensors.requestTemperatures();
Serial.println("");
Serial.print(sensors.getTempCByIndex(0));
Blynk.virtualWrite(0, sensors.getTempCByIndex(0));
Blynk.run();
timer.run();
}