I’m having a problem connecting to the Blynk local server. The problem seems to be with my IP address which is 192.168.0.258) When the program uploads it shows trying to connect with 192.168.2 . It appears the format only wants 1 digit when my assigned IP address has 3 digits. When I look at the router settings it shows the raspberrypi server as DHCP-IP. Is there an easy way of fixing this without having to rework my router and effect other users?
That’s not possible. 254 is the highest IP address available for the 192.168.0 address range.
Pete.
As always, Pete, you are correct, the IP is 192.168.0.158. That’s what I get for sitting Everything works fine now.
Thanks
Jeff
Can we run Blynk public server/dedicated machine (without relying on local machine)? Secondly, My Local IP address is 192.168.1.26 which are reserved IP addresses as per https://whatismyip.live/ip/192.168.1.26 . Do we must use reserved IP address for using blynk platform? Sorry for my questions, I am very new to IP addresses.
Thanks.
My advice would be that if you don’t already know the answer to the second question you should probably steer clear of setting-up your own local Legacy server.
Setting-up, configuring and maintaining a local server isn’t a trivial task, and making that server available outside of your local network requires knowledge of DDNS and port-forwarding.
In addition, you won’t be able to send emails from your local server now that Google have blocked insecure applications from accessing Gmail, and as the local server code is no longer being supported or updated there is the risk of security vulnerabilities being found that won’t be addressed.
Things like Java versions becoming obsolete in the future and the Legacy apps no longer being available in the App/Play stores also makes life very difficult for local server users.
The Legacy local server code and documentation can be found here:
but I wouldn’t recommend using it.
Pete.
Thank you Pete, I will go through the documentation and decide. really appreciate your time.
Pete. FYI, you can still use Gmail by creating an app password. I use it all the time in my devices.
Rds.
I have my local server up and running. I’ve tested it with a simple blink program and it works… However I’m having trouble converting my well program for use on the local server. I suspect it’s how I’m addressing accessing the server IP. I’m getting a “conversion from ‘IP address’ to ‘const char’ is ambiguous”" error in line 80. I suspect it might have to do with the version of Blynk I’m using. Any suggestion about the correct way would be most appreciated. Here’s the complete sketch.
/*
For this example you'll need the following library:
* *
1) Arduino-LiquidCrystal-I2C-library: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
2) Blynk Library 0.6.1 (if usimg Legacy or latest if using IoT): https://github.com/blynkkk/blynk-library
Conncetions:
D0 (GPIO16) -> RST Pin on LoRa Rx module
D1 (GPIO5) -> LED on U3 connector?
D2 (GPIO4) -> DIO0 Pin on LoRa Rx Module
D3 (GPIO0) -> SDA Pin on OLED Display
D4 (GPIO2) -> SCL Pin on OLED Display
D5 (GPIO14) -> SCK pin on LoRA Rx module
D6 (GPIO12) -> MISO pin on LoRA Rx module
D7 (GPIO13) -> MOSI pin on LoRA Rx module
D8 (GPIO15) -> nSS pin on LoRA Rx module
*/
#include <LoRa.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define I2C_SDA 0 // GPIO0 = D3 - redefining I2C pins as D1 is needed by LoRa unit
#define I2C_SCL 2 // GPIO2 = D4
#define ss 15 // GPIO15 = D1
#define rst 16 // GPIO16 = D0
#define dio0 4 // GPIO4 = D2
int LEDPin=5; //Relay and LED pin
int adjustment;
int adjusted_reading;
int tank_to_read;
const int ledPin = 5; // GPIO5 = D1 - warning light that water has dropped beyond preset level
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"; //Enter the Auth code which was send by Blink
char ssid[] = "xxxxxxxxx"; //Enter your WIFI Name
char pass[] = "xxxxxxx"; //Enter your WIFI Password
int wifi_connect_count = 0; // Keep track of how many times we've tried to connect to the WiFi
int wifi_connect_max_retries = 20; // Specify how many attempts we will have at connecting to the WiFi
bool sync_completed = false; // Flag to track when BLYNK_WRITE(V1) has completed
BlynkTimer timer;
void setup()
{
pinMode(ledPin, OUTPUT);
Wire.begin(I2C_SDA, I2C_SCL); // Updated from deprecated wire.pins(sda,scl) command
Serial.begin(74880); // Native baud rate for the NodemCU
lcd.begin(); // iInit the LCD for 16 chars 2 lines
lcd.backlight(); // Turn on the backligt (try lcd.noBaklight() to turn it off)
delay (1000);
Serial.println("LoRa Receiver ");
LoRa.setPins(ss, rst, dio0);
if (!LoRa.begin(433E6))
{
Serial.println("Starting LoRa failed!");
delay(2000);
Serial.println("Restarting ESP...");
ESP.restart(); // Restart the ESP
}
Serial.println("LoRa Started");
lcd.clear();
lcd.print("Waiting");
LoRa.setSpreadingFactor(10);
LoRa.setSignalBandwidth(62.5E3);
LoRa.crc();
WiFi_Connect();
Blynk.begin(auth, IPAddress(192,168,0,158),8080);
send_to_blynk(); // Connect to Blynk then sync the segmented switch at startup
timer.setInterval( 1 * 1000L, take_a_reading); // Existing timer
timer.setInterval(1 * 60 * 1000L, check_connections); // Check that we have a WiFi connection every 1 minute
timer.setInterval(20 * 60 * 1000L, send_to_blynk); // send data to Blynk every 3 minutes (180,000 m/s)
}
void loop()
{
timer.run();
}
void take_a_reading()
{
int packetSize = LoRa.parsePacket();
int reading = LoRa.parseInt();
if (packetSize)
{
adjusted_reading = (reading - adjustment);
Serial.print("Selected tank = ");
Serial.println(tank_to_read);
Serial.print("Actual reading = ");
Serial.println(reading);
Serial.print("Adjustment factor = ");
Serial.println(adjustment);
Serial.print("Adjusted reading = ");
Serial.println(adjusted_reading);
lcd.setCursor(0, 0); //First line
lcd.print("water is down");
lcd.setCursor(0, 1); //Second line
lcd.print(adjusted_reading);
lcd.print(" inches");
}
if (adjusted_reading >=28 ) //ALARM
{
digitalWrite(LEDPin,HIGH); //ALARM
if(adjusted_reading >=28)
{
Blynk.notify("water level has dropped below 28 inches");
}
timer.setTimeout(1600L, [](){
// Blynk.email("jgroberm@shaw.ca", "water level has dropped below 28 inches");
});
}
else {
digitalWrite(LEDPin,LOW); // play tone of 400Hz for 500 ms
}
}
void send_to_blynk()
{
if (WiFi.status() == WL_CONNECTED)
{
Serial.println ("Connecting to Blynk");
Blynk.connect();
if (Blynk.connected())
{
Serial.println ("Connected");
sync_completed = false;
Blynk.syncVirtual(V1); // force the server to send the latest value for the segmented switch
while (!sync_completed) // Wait until BLYNK_WRITE(V1) has completed
{
Blynk.run();
}
take_a_reading(); // take a reading from the tank indicated by the segmented switch
Blynk.virtualWrite(V0, adjusted_reading); // To Display Widget
Blynk.run();
Blynk.disconnect();
Serial.println ("Blynk Disconnected");
}
else
{
Serial.println (">>>>>>>>>>>> Unable to connect to Blynk <<<<<<<<<<<<");
}
}
else
{
// we get here if we there is no WiFi connection
Serial.println (">>>>>>>>>>>> No WiFi Connection, so Blynk connection not attempted <<<<<<<<<<<<");
}
}
BLYNK_WRITE(V1) // Segmented switch to select tank
{
Serial.println("BLYNK_WRITE(V1) Executed");
tank_to_read = param.asInt();
switch (tank_to_read)
{
case 1:
{
adjustment = 0;
sync_completed = true;
break;
}
case 2:
{
adjustment = 13;
sync_completed = true;
break;
}
case 3:
{
adjustment = 15;
sync_completed = true;
break;
}
case 4:
{
adjustment = 12;
sync_completed = true;
break;
}
}
}
void check_connections()
{
if (WiFi.status() != WL_CONNECTED)
{
WiFi_Connect();
}
else
{
Serial.println(F(">>>> WiFi checked - all good <<<<"));
}
}
void WiFi_Connect() // New functon to handle the connectuon to the WiFi network
{
wifi_connect_count=0; // reset the counter
Serial.println(F("Connecting to WiFi"));
if (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass); // connect to the network
}
while (WiFi.status() != WL_CONNECTED && wifi_connect_count < wifi_connect_max_retries) // Loop until we've connected, or reached the maximum number of attemps allowed
{
delay(500);
wifi_connect_count++;
Serial.print(F("WiFi connection - attempt number "));
Serial.println(wifi_connect_count);
}
if (WiFi.status() == WL_CONNECTED)
{
WiFi.mode(WIFI_STA);
Serial.println(F("Wi-Fi CONNECTED"));
Serial.println();
}
else
{
Serial.println(F(">>>>>>>>>>>> Unable to connect to WiFi <<<<<<<<<<<<"));
}
}
The normal syntax for Blynk.begin is:
Blynk.begin(auth, ssid, pass, IPAddress(xxx,xxx,xxx,xxx), port);
As you’re managing your WiFi connection yourself you should probably use Blynk.config and Blynk.connect instead of Blynk.begin.
The Blynk.config syntax is:
Blynk.config(auth, IPAddress(xxx,xxx,xxx,xxx), port);
More info in the docs…
Pete.
As always, thanks Pete. That small change seems to have solved the problem. Have a great weekend.
Jeff