Hi..
This is my 1st attempts to "play" with arduino.
I'm using a 16x2 LCD with I2c interface connected to a mini pro arduino.
My goal is connect it via serial to a linksys router wrt54gs v1.0 with dd-wrt firmware ( 8 flash ram, with 3.5mg free for scripting and other stuff ) and get some info from it: wan IP, Load average, time and uptime, if any client is connected to it, if internet is up, etc
At this point, searching around, especially over this forum, i succeed to get these infos from the linksys and display it on LCD nicely. I pushed the goal with an new info, internal temperature reading, with a LM35, and success, I got it displayed on the LCD.
I'm not a code guy, i understand what I see on code, but it's hard to me to do it from scratch. So i have an issue, it 4 readings from the serial: wan IP, UPtime, Load Average, Number of clients and if connected to internet. and a separated one analog read from a LM35 temp sensor. The issue, on display I want it by this order, 4 serial data, an at the end temperature.
I tried with delay, while and counter, but never got success, all time i got wrong order for temperature, it will show on 2 or 3 place.
Here the code i used:
/*
* Displays text sent over the serial port (e.g. from the Serial Monitor) on
* an attached LCD.
* DFRobot.com
*Compatible with the Arduino IDE 1.0
*Library version:1.1
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
float raw;
const int inPin = 0;
int vx;
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
Serial.begin(9600);
}
void loop()
{
vx = 0;
while(vx < 4){
int charcount;
boolean secondline;
if (Serial.available()) {
delay(200);
lcd.clear();
charcount = 0;
secondline = false;
while (Serial.available() > 0) {
if (charcount > 15 && secondline == false ) {
lcd.setCursor(0,1);
secondline = true;
}
lcd.write(Serial.read());
charcount++;
}
}
vx++;
delay(3500);
}
int value = analogRead(inPin);
lcd.setCursor(0, 1);
float millivolts = (value / 1024.0) * 5000;
float celsius = millivolts / 10;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TEMP");
lcd.setCursor(0,1);
lcd.print(celsius);
lcd.print(" Celsius");
delay(2000);
vx=0;
}
to send value fron linksys: echo -ne "$NC client" > /dev/tts/1 , simple but working.
Any help is welcome, to guide me to get it working.
Some pics of my linksys and arduino: