Firstly, I would like to thank Pete Knight for his help on helping me move forward with this issue. After a lot of reading and tinkering I think I have come to grips with what you are able to do/not do with the Free Investigating facility on Blynk . So here are some of the things I have found, which I hope will help others if they land on this post looking for answers
- The Quickstart Device is very limited, but it does show you how to connect to wi-fi
- Don’t bother trying to modify your Quickstart device template as it is very limited
- DO create a NEW template and tryout the different Virtual Datastreams (max of 5 i.e V0 to V4)
- You can create 2 new devices so try out different configurations
- If you have tried one out, delete it and try another one to explore the widgets etc.
- There is a limit to what Widgets are available, but still enough to get a feel of whats going on
- I have created 2 new devices (deleted the Quickstart device to make room)
- First device has 3 leds which and be switched on individually, or all at one. Also I have an Ultrasound distance sensor which brings in the distance as a string and displays it. I will attach the code etc below for information
- Second device has the Ultrasound Distance plus two Temperature probes on a serial polling line and display the values in a Temp gauge and also on a graph showing historical data. Happy to post code if someone is interested.
- The Graphs however are configured by the Web Dashboard, which I found a bit messy, as the screen for Web display is limited due to multiple command boxes - would benefit from being able to address the Wed View independently so this can be made mode presentable
ok - here is the code fro first device - may not be pretty but it works
This code sets up NodeMCU ESP8266 bard for wi-fi using Blynk library
Comminicates over wi-fi to Phone - on Blynk app
Controls 3 LEDs connected to GPIO2 (RED),GPIO4 (YELLOW), GPIO5 (GREEN)
These map to actual pins GPIO2=D9,GPIO4=D14,GPIO5=D15 0n AZ D1 board
Also takes a Distance value from WiFi board provided by Ultrasound
These inputs are on GPIO13 (Trigger) and GPIO12 (Echo)
These map to actual pins GPIO13=D11 and GPIO14=D12
Uses 5 virtual pins from Blynk Library
V0 = Control Switch RED LED on/off
V1 = Control Switch YELLOW LED on/off
V2 = Control Switch GREEN LED on/off
V3 = Control Switch ALL THREE LED on/off
V4 = String, Distance value
*************************************************************/
/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL5t8WOh8wn"
#define BLYNK_TEMPLATE_NAME "Tom new template"
#define BLYNK_AUTH_TOKEN "i9rGJqEJgN5EtPgnaZfGe5U1QqvwGC7m"
// ultrasound distance definitions
#include "SR04.h" // Ultrasonic library
#define TRIG_PIN 13 // Ultrasonic pin definintion pins changed so can run LCD screen as well
#define ECHO_PIN 12 // note GPIO13 = D11 and GPIO12 = D12 on Arduino WiFi Board
// Ultasonic setup and definition
int calibration = 1; //calibration value if needed
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Wifi Setup parameters
char ssid[] = "xxxxxxxx"; //My WiFi Network and Password
char pass[] = "yyyyyyyy";
BlynkTimer timer;
// *********************************************************************************
// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
// Change Web Link Button message to "Congratulations!"
Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
Blynk.setProperty(V3, "onImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}
// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
Blynk.virtualWrite(V4, a," cm"); // Writing distance (a cm) to app
}
//*****************************
void setup()
{
Serial.begin(9600); //Initialization of Serial Port for Ultrasonic reporting on Serial Monitor in ICE
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, myTimerEvent); // Setup a function to be called every second
pinMode(2,OUTPUT);// Initialise digital pin GPIO02 as an output RED LED
pinMode(4,OUTPUT); // Initialise digital pin GPIO04 as an output YELLOW LED
pinMode(5,OUTPUT); // Initialise digital pin GPIO05 as an output GREEN LED
}
// ****************************************************************
void loop()
{
Blynk.run();
timer.run();
// this is code to get didtance reading and then print with CR to Serial Monitor for checking
a=sr04.Distance(); // reading the distance from Ultrasonic
a = a + calibration; //calibration if needed
Serial.print(a); // printing to Serial Monitor
Serial.println("cm");//The difference between "Serial.print" and "Serial.println"
//is that "Serial.println" can change lines.
delay(250); // delay set to 250 ms to speed reading
}
// here is code to switch RED 0n ***************************************************
BLYNK_WRITE(V0) // Executes when the value of virtual pin 0 changes
{
if(param.asInt() == 1)
{
digitalWrite(2,HIGH); // Set digital pin 2 HIGH // execute this code if the switch widget is now ON
}
else
{
digitalWrite(2,LOW); // Set digital pin 2 LOW - note this physically appears on D4
}
}
// here is code to switch Yellow 0n **************************************************************88
BLYNK_WRITE(V1) // Executes when the value of virtual pin 1 changes
{
if(param.asInt() == 1)
{
digitalWrite(4,HIGH); // Set digital pin red_led_pin (D4)HIGH // execute this code if the switch widget is now ON
}
else
{
digitalWrite(4,LOW); // Set digital pin red_led_pin LOW - note this physically appears on D4
}
}
// here is code to switch GREEN 0n *****************************
BLYNK_WRITE(V2) // Executes when the value of virtual pin 2 changes
{
if(param.asInt() == 1){
digitalWrite(5,HIGH); } // Set digital pin 5 (D1)HIGH // execute this code if the switch widget is now ON
else {
digitalWrite(5,LOW); } // Set digital pin 5 LOW - note this physically appears on D1
}
// here is code to switch all 3 LEDs on *******************************
BLYNK_WRITE(V3) { // Executes when the value of virtual pin 3 changes
if(param.asInt() == 1) {
digitalWrite(2,HIGH); // Set digital pin 2 (D4)HIGH // execute this code if the switch widget is now ON
digitalWrite(4,HIGH); // Set digital pin 4 (D2)HIGH // execute this code if the switch widget is now ON
digitalWrite(5,HIGH);} // Set digital pin 5 (D1)HIGH // execute this code if the switch widget is now ON
else {
digitalWrite(2,LOW); // Set digital pin 2 LOW - note this physically appears on D4
digitalWrite(4,LOW); // Set digital pin 4 (D2)LOW // execute this code if the switch widget is now OFF
digitalWrite(5,LOW);} // Set digital pin 5 (D1)LOW // execute this code if the switch widget is now OFF
} // missing closing curly bracket added by Pete Knight```