I'm working on making a headless music server. I am curious if it is in the realm of possibility to somehow connect one of these i2c LCD screens to linux or windows to display the local IP address of that machine. I'm willing to buy any hardware/equipment to turn this project into a success.
-I can find information on displaying IP from arduino ethernet shield.
-I cannot find any information on using arduino to display IP address from a Windows or linux maxhine.
Any help regarding this would be much appreciated. Thank you all for your time.
I've got a number of libraries installed on my IDE. I managed to write my own text to the i2c 20x4 lcd i have, However i have not been able to figure out how to display current network information from my PC.
That is not a question for Arduino forum.
You need to make programs running in Windows resp Linux, that send the required information. An Arduino can't suck that information out of a Pc or a Linux running device.
You could obtain the IP address of the Linux machine by capturing the output of something like the ifconfig command in a shell script and then sending that data via USB/serial to the Arduino controlling the display. The Arduino would need to capture the data from serial and send it to the display.
It ought also to be possible to write a Python script (or your favourite scripting language) to do that and maybe have it called at startup, login or from a cron job.
Python can use a built-in method of obtaining the IP address bound to the network card:
Something similar might be possible in other scripting languages.
In dos/Windows you could make batch file to get the IP address:
then pipe the result to the com of your Arduino port
@echo off
for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %ComputerName% ^| findstr [') do set NetworkIP=%%a
echo Network IP: %NetworkIP%
echo Network IP: %NetworkIP% >COM11
pause
On the Arduino you would need a sketch to read data from serial, there is an example in most LCD libraries to do that. Very often called "SerialDisplay".
I think im on the right track. I've been able to load the Serial.display example and i'm able to send stuff from Command prompt in windows to the LCD screen. However, it displays strange symbols and foreign characters rather than English text that i was getting from the Hello, World example.
Ummmm....
I did things like this 30 years ago in DOS but I am suspicious of Unicode being serially sent... Arduino may need to post-process that stream.
... maybe direct output to text-file and then send text file to serial...
a)
are the speed settings correct? I would assume the baudrate from the Windows device manager is relevant - NOT what you have set in the Arduino IDE Serial Monitor.
b) after checking the baud rates ... can you please make a picture of the garbish of you display so we can see what you actually get on the display?
I would expect that the output of
Network IP: 172.99.42.123
doesn't contain so much unicode/UTF-8 multi byte chararcters, only a trailing CR/LF - may be...
A) I did in fact have mismatching baudrates. Adjusting those fixed the issue mostly.
The batch script is working well, however, when i put it in the startup folder and restart my laptop the batch file will still open but the text on LCD is limited to those 4 horizontal lines stacked.
It seems like i have to reload my sketch and then run the batch script again to get it to display correctly after a restart.
Also, unplugging my mouse (an entirely different USB port) seems to cause the screen to go blank, show the 4 horizontal lines, and prevents the batch script from displaying on the LCD(besides the 4 lines)
I've learned so much in a few days.
you could shorten the leading text, just leave away "Network".
regarding the CR/LF you could try
void loop()
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
char c = Serial.read();
if (c >=' ') lcd.write(c); // only write printable characters, no CR, no LF
}
}
}
Thank you again to everyone who offered some advice.
I'd say this has been a success.
@echo off for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %computername% ^| findstr [') do set NetworkIP=%%a echo Network IP: %NetworkIP% echo %NetworkIP% >COM3 pause
That's the batch file im using.
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 20 chars and 4 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
lcd.begin();
lcd.backlight();
// Initialize the serial port at a speed of 115200 baud
Serial.begin(115200);
}
void loop() {
// Set the cursor position column, row
lcd.setCursor(0, 0);
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
char c = Serial.read();
if (c >= ' ') lcd.write(c); // only write printable characters, no CR, no LF
}
}
}
and that's the sketch i'm using.
Everything works as it should. I should be able to do this for python in linux as well.
My only issue is the USB Resetting problem but i think that has to do with the wiring or the esp8266 unit im using.