Hey Guys,
sorry for my bad English I´m from Germany and have a lot to learn back in the TechWorld
Ive made a “copy + paste” Sketch to send Sensor Data to HomeAssistant and also to LCD 1602A.
The Problem ist the Sensor Sends like: " 8.343.646.757.343.758" but I need “8.34” as Result.
But I´m too Stupid try now about four Hours to made it.
JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
JsonObject& root = jsonBuffer.createObject();
----> avgValue=0;
for(int i=2;i<8;i++)
avgValue+=buf[i];
float phValue=(float)avgValue*5.0/1024/6;
phValue=3.5*phValue;[/b] <---------------------
root["temperature0"] = dht0.readTemperature();
root["humidity0"] = dht0.readHumidity();
root["temperature1"] = dht1.readTemperature();
root["humidity1"] = dht1.readHumidity();
root["temperature2"] = dht2.readTemperature();
root["humidity2"] = dht2.readHumidity();
----> root["PH"] = phValue; <-------------
{
{
lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner
lcd.setCursor(1,0); // set the cursor to column 15, line 1
for (int positionCounter2 = 0; positionCounter2 < 16; positionCounter2++)
{
// lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.
lcd.print("Aktueller PH = "[positionCounter2]); // Print a message to the LCD.
delay(250); //wait for 250 microseconds
}
// lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.
lcd.setCursor(0,1); // set the cursor to column 15, line 0
for (int positionCounter1 = 0; positionCounter1 < 16; positionCounter1++)
{
---> lcd.print( (phValue,2 ) [positionCounter1]); // Print a message to the LCD. <-------------------
delay(250); //wait for 250 microseconds[/b]
}
lcd.setCursor(1,0); // set the cursor to column 15, line 1
for (int positionCounter3 = 0; positionCounter3 < 16; positionCounter3++)
{
lcd.print(" @ 00:00 Uhr "[positionCounter3]); // Print a message to the LCD.
delay(250); //wait for 250 microseconds
}
}
return root;
}
}
I have marked the Cells (I think there wrong) with an Arrow in the Code
The ERROR that Arduino IDE Gives:
/Volumes/SSD/Arduino/SpFo/SpFo.ino: In function 'ArduinoJson::JsonObject& prepareResponse(ArduinoJson::JsonBuffer&)':
SpFo:80: error: invalid types 'int[int]' for array subscript
lcd.print( (phValue,2) [positionCounter1]); // Print a message to the LCD.
^
Bibliothek ArduinoJson-5.13.0 in Version 5.13.0 im Ordner: /Volumes/SSD/Arduino/libraries/ArduinoJson-5.13.0 wird verwendet
Bibliothek DHT_sensor_library in Version 1.3.0 im Ordner: /Volumes/SSD/Arduino/libraries/DHT_sensor_library wird verwendet
Bibliothek LiquidCrystal in Version 1.0.7 im Ordner: /Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal wird verwendet
exit status 1
invalid types 'int[int]' for array subscript
Now i wont Give Up (Display is built in table already ) and ask here.
I think someone could help me.
Very big Thank you …
Best Greetings
Ned