All,
I used to had a sketch to grab the V_TEXT values from Domoticz controller and show on LCD.
All was good except, recently I wanted to change some of the text on LCD.
I only changed the text and when I tried to compile the sketch I get some error.
It does not like this line anymore:
void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
And I receive this set of errors in compiler (Arduino IDE):
LCD_Sketch:113: error: new declaration 'void request(uint8_t, uint8_t, uint8_t)'
void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
^
In file included from C:\Users\Saeid\Documents\Arduino\libraries\MySensors/MySensors.h:412:0,
from D:\WemosD1MiniPro-NodeMCU-LCD_Sketch\WemosD1MiniPro-NodeMCU-LCD_Sketch.ino:35:
C:\Users\Saeid\Documents\Arduino\libraries\MySensors/core/MySensorsCore.cpp:392:6: error: ambiguates old declaration 'bool request(uint8_t, uint8_t, uint8_t)'
bool request(const uint8_t childSensorId, const uint8_t variableType, const uint8_t destination)
^
exit status 1
new declaration 'void request(uint8_t, uint8_t, uint8_t)'
I commented the "void request" line and sketch compile just fine but I feel something is not right.
-
Would you please explain why my code does not compile the code?
-
Is alright to not having the Request line at all?
-
What is your suggestion to get this code improved/fixed as I see the device get restarted after a while on and off!!!
Here is the full code for my sketch:
// Enable debug prints to serial monitor
#define MY_DEBUG
//Fixed NodeID in Domoticz
#define MY_NODE_ID 2
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MySensors.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x3F, 20, 4);
//const byte nodeId = 66 ; // MySensors fixed node id
const byte LCD1_CHILD = 8 ; // LCD line 1
const byte LCD2_CHILD = 9 ; // LCD line 2
const byte LCD3_CHILD = 10 ; // LCD line 3
const byte LCD4_CHILD = 11 ; // LCD line 4
char lastLCD1[21] = "Line1 - first "; // define & init before first receive
char lastLCD2[21] = "Line2 - second ";
char lastLCD3[21] = "Line3 - third ";
char lastLCD4[21] = "Line4 - forth ";
// Initialize messages for sensor network
MyMessage textMsg( 0, V_TEXT );
void setup(){
//WiFi.persistent(false);
//ESP.flashEraseSector(0x3fe);
Wire.begin(D3, D4);
lcd.begin();
lcd.backlight(); // finish with backlight on
//-------- Write characters on the display ----------------
// NOTE: Cursor Position: CHAR, LINE) start at 0
lcd.setCursor(0,0); //Start at character 4 on line 0
lcd.print("Welcome to :");
delay(1000);
lcd.setCursor(4,1);
lcd.print("LCD Panel");
delay(2000);
lcd.setCursor(0,3);
lcd.print("Weather Station");
delay(2000);
lcd.clear();
// Initialize the serial port at a speed of 9600 baud
Serial.begin(115200);
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("LCD", "2.0");
present(LCD1_CHILD, S_INFO, "LCD_line1"); // new S_type 20150905 (not know by domoticz)
present(LCD2_CHILD, S_INFO, "LCD_line2");
present(LCD3_CHILD, S_INFO, "LCD_line3");
present(LCD4_CHILD, S_INFO, "LCD_line4");
send(textMsg.setSensor(LCD1_CHILD).set("-")); // initialize the V_TEXT at controller for sensor to none (trick for Domoticz)
send(textMsg.setSensor(LCD2_CHILD).set("-"));
send(textMsg.setSensor(LCD3_CHILD).set("-"));
send(textMsg.setSensor(LCD4_CHILD).set("-"));
//requestTime();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Inside (T):");
lcd.setCursor(0, 1);
lcd.print("Outside (T):");
lcd.setCursor(0, 2);
lcd.print("Bedroom (T):");
lcd.setCursor(0, 3);
lcd.print("Bedroom (H):");
}
void requestTime();
void request(uint8_t childSensorId, uint8_t variableType, uint8_t destination);
void loop(){
Serial.println(".");
//requestTime();
request(8,V_TEXT,0);
wait(50);
request(9,V_TEXT,0);
wait(50);
request(10,V_TEXT,0);
wait(50);
request(11,V_TEXT,0);
wait(50);
sleep(60000);
// If characters arrived over the serial port...
if (Serial.available()) {
// Wait a bit for the entire message to arrive
delay(100);
// Clear the screen
lcd.clear();
// Write all characters received with the serial port to the LCD.
while (Serial.available() > 0) {
lcd.write(Serial.read());
}
}
}
// This is called only if new time value was received by calling requestTime();
void receiveTime(unsigned long controllerTime) {
Serial.print("Time value received: ");
Serial.println(controllerTime);
//Hours = controllerTime / (1000*60*60)
//Minutes = (controllerTime % (1000*60*60)) / (1000*60)
//Seconds = ((controllerTime % (1000*60*60)) % (1000*60)) / 1000
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Current Time");
lcd.setCursor(0,1);
lcd.print(controllerTime); //seconds format ex. 45681238785
}
// This is called when a message is received
void receive(const MyMessage &message) {
// Write some debug info
Serial.print("Message: ");
Serial.print(message.sensor);
Serial.print(", Message: ");
Serial.println(message.getString());
lcd.setCursor(0, 0);
lcd.print("Inside (T):");
lcd.setCursor(0, 1);
lcd.print("Outside (T):");
lcd.setCursor(0, 2);
lcd.print("Bedroom (T):");
lcd.setCursor(0, 3);
lcd.print("Bedroom (H):");
if (message.type==V_TEXT) {
if (message.sensor == LCD1_CHILD ) {
//snprintf(lastLCD1, sizeof(lastLCD1), "%20s", message.getString()); // load text into LCD string
//lcd.setCursor(17, 1);
//lcd.print(lastLCD1);
lcd.setCursor(13, 0);
lcd.print(message.getString());
lcd.print((char)223);
lcd.print("C");
}
if (message.sensor == LCD2_CHILD ) {
lcd.setCursor(0, 1);
//lcd.print(lastLCD2);
lcd.setCursor(13, 1);
lcd.print(message.getString());
lcd.print((char)223);
lcd.print("C");
}
if (message.sensor == LCD3_CHILD ) {
lcd.setCursor(0, 2);
//lcd.print(lastLCD3);
lcd.setCursor(13, 2);
lcd.print(message.getString());
lcd.print((char)223);
lcd.print("C");
}
if (message.sensor == LCD4_CHILD ) {
lcd.setCursor(0, 3);
//lcd.print(lastLCD4);
lcd.setCursor(13, 3);
lcd.print(message.getString());
lcd.print("%");
}
}
}
P.S: I am using MySensor Library 2.3.0 hwever, by reverting it back to 2.2.0, problem still persist.
I am also using NodeMCU v1.0 for my microprocessor connected to LCD and NRF24 Radio.