Hi,
Got simple LCD to work, but when switching to Advanced, it doesn’t work.
Board is NodeMCU 12E, App on iOS.
Created some test code based on example. Gauge on V6 works well so connected.
I’m getting compile errors when using Ethernet.h and/or BlynkSimpleEthernet.h
Using BlynkSimpleEsp8266.h - Is advanced not included in that library?
Thank you!
Code:
/************************************************************** * 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 * Blynk community: http://community.blynk.cc * Social networks: http://www.fb.com/blynkapp * http://twitter.com/blynk_app * * Blynk library is licensed under MIT license * This example code is in public domain. * ************************************************************** * Output any data on LCD widget! * * App project setup: * LCD widget, switch to ADVANCED mode, select pin V1 * **************************************************************/ #define BLYNK_PRINT Serial #include <SPI.h> //#include <Ethernet.h> <<---- When included, compile errors out on NodeMCU //#include <BlynkSimpleEthernet.h> <<---- When included, compile errors out on NodeMCU #include <BlynkSimpleEsp8266.h> #include <ESP8266mDNS.h>
// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "*****";
const char WiFiAPPSK = “";
const char ssid[] = ""; // your network SSID (name)
const char pass[] = "***”; // your network password
WiFiServer server(80);
int i;
WidgetLCD lcd(V1);
void setup()
{
initHardware();Serial.begin(9600);
connectWiFi(); // Connect to WiFi
setupWiFi();
server.begin();
Blynk.config(auth);
// Blynk.begin(auth);
lcd.clear(); //Use it to clear the LCD Widget
lcd.print(4, 0, “Hello”); // use: (position X: 0-15, position Y: 0-1, “Message you want to print”)
lcd.print(4, 1, “World”);
// Please use timed events when LCD printintg in void loop to avoid sending too many commands
// It will cause a FLOOD Error, and connection will be dropped
}
void loop()
{
Blynk.run();
Serial.print(“i = “); Serial.print(i); Serial.println(” Hello”);
i = i+1;
if(i>200){
i = 1;
}
}
BLYNK_READ(V6){ // Write the Temp
Blynk.virtualWrite(V6, i);
}
void connectWiFi()
{
byte ledStatus = LOW;
Serial.println();
Serial.println("Connecting to: " + String(ssid));
WiFi.mode(WIFI_AP_STA); // Set WiFi mode to station and Access Point (as opposed to AP or STA)
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) // Use the WiFi.status() function to check if the ESP8266 is connected to a WiFi network.
{
// Blink the LED
delay(100); // Delays allow the ESP8266 to perform critical tasks defined outside of the sketch. These tasks include setting up, and maintaining, a WiFi connection.
}
Serial.println(“WiFi connected”);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void setupMDNS()
{
// Call MDNS.begin() to set up mDNS to point to
// “.local”
if (!MDNS.begin(“thing”))
{
Serial.println(“Error setting up MDNS responder!”);
while(1) {
delay(1000);
}
}
Serial.println(“mDNS responder started”);
}
/////////////////////////////////////////////////////////
//////////////////// setup AP ////////////////////////
/////////////////////////////////////////////////////////
void setupWiFi()
{
WiFi.mode(WIFI_AP_STA);
// Do a little work to get a unique-ish name. Append the
// last two bytes of the MAC (HEX’d) to “ThingDev-”:
uint8_t mac[WL_MAC_ADDR_LENGTH];
WiFi.softAPmacAddress(mac);
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
macID.toUpperCase();
String AP_NameString = “HoekBoard” + macID;
char AP_NameChar[AP_NameString.length() + 1];
memset(AP_NameChar, 0, AP_NameString.length() + 1);
for (int i=0; i<AP_NameString.length(); i++)
AP_NameChar[i] = AP_NameString.charAt(i);
WiFi.softAP(AP_NameChar, WiFiAPPSK);
}
void initHardware()
{
Serial.begin(9600);
delay(100);
}