The described project reads feed data on Pachube and shows them on LCD. The project is quite simple. I've used following HW:
- DFRobot X-Board v2 (DFR0162)
- DFRobot FTDI Basic Breakout (DFR0065) for uploading the sketch code to X-Board
- LCD2004 display
- i2c / SPI character LCD backpack by Adafruit (www.adafruit.com/products/292)
- DFRobot USB Power adapter (FIT0107)
- USB cable for power, Ethernet cable to connect it to router/internet
The connection between X-Board and LCD is serial using four wires only. Of course, you may use also the parallel connection without Adafruit (or other) adapter but it uses much more X-Board pins. Information on wiring you may find here: http://www.ladyada.net/products/i2cspilcdbackpack/
So we have the hardware, now it is time for software. To compile your code you need:
- Arduino IDE, the latest version is 0023 now
- Pachube library ERxPachube available here: http://code.google.com/p/pachubelibrary/ (note: please download and install library version compatible with your IDE, i.e. for IDE 0023 is the latest version ERxPachube-I-2.5.zip)
- LCD LiquidTWI library by FalconFour can be found on http://hostfile.org/LiquidTWI.rar, the forum topic http://forums.adafruit.com/viewtopic.php?f=19&t=21586&p=113177
The sketch code:
I recover all 5 values from Pachube: Outer and inner temperature, atmospheric pressure and trend of its changes, and LiPO accumulator voltage. My Pachube feed is 25574, so you may check it on Pachube's site.
The sketch is very simple. The ways how to display the values on LCD is endless so take my layout as an idea only. If you have any questions don't hesitate to contact me either here or on synekvl AT gmail DOT com
Have a nice day
Vladimir
- DFRobot X-Board v2 (DFR0162)
- DFRobot FTDI Basic Breakout (DFR0065) for uploading the sketch code to X-Board
- LCD2004 display
- i2c / SPI character LCD backpack by Adafruit (www.adafruit.com/products/292)
- DFRobot USB Power adapter (FIT0107)
- USB cable for power, Ethernet cable to connect it to router/internet
The connection between X-Board and LCD is serial using four wires only. Of course, you may use also the parallel connection without Adafruit (or other) adapter but it uses much more X-Board pins. Information on wiring you may find here: http://www.ladyada.net/products/i2cspilcdbackpack/
So we have the hardware, now it is time for software. To compile your code you need:
- Arduino IDE, the latest version is 0023 now
- Pachube library ERxPachube available here: http://code.google.com/p/pachubelibrary/ (note: please download and install library version compatible with your IDE, i.e. for IDE 0023 is the latest version ERxPachube-I-2.5.zip)
- LCD LiquidTWI library by FalconFour can be found on http://hostfile.org/LiquidTWI.rar, the forum topic http://forums.adafruit.com/viewtopic.php?f=19&t=21586&p=113177
The sketch code:
Code: [Select]
/*
Demonstration sketch for X-Board by DFRobot ( http://www.dfrobot.com/index.php?route=product/product&filter_name=dfr0162&product_id=564 ) and Adafruit i2c/SPI LCD backpack
using MCP23008 I2C expander( http://www.ladyada.net/products/i2cspilcdbackpack/index.html )
The circuit:
* 5V to X-Board 5V pin
* GND to X-Board GND pin
* CLK to X-Board #5
* DAT to X-Board #4
*/
// include the library code:
#include <ERxPachube.h>
#include <Ethernet.h>
#include <LiquidTWI.h>
#include <SPI.h>
#include <Wire.h>
#define PACHUBE_API_KEY ".............." // fill in your API key PACHUBE_API_KEY
#define PACHUBE_FEED_ID ..... // fill in your PACHUBE_FEED_ID
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
const int postingInterval = 29500; // delay in [ms] between updates from Pachube.com
String data[5]; // My sketch is for 5 streams. Enter YOUR number of datastreams you will be recovering from Pachube.
// Standard ERxPachube library is set for 4 streams only. If you need more go to the file ERxPachube.h
// and change #define MAX_DATASTREAM_NUM x to meet your requirements
byte mac[] = { 0xCC, 0xAC, 0xBE, 0xEF, 0xFE, 0x91 }; // make sure this is unique on your network
byte ip[] = { 192, 168, 2, 9 }; // set your own IP address
ERxPachubeDataIn datain( PACHUBE_API_KEY, PACHUBE_FEED_ID );
LiquidTWI lcd( 0 ); // Connect via i2c, default address #0 (A0-A2 not jumpered)
void setup(){
// set up the LCD's number of rows and columns:
lcd.begin( 20, 4 ); // depends on your LCD type, I use 2004 LCD
Ethernet.begin( mac, ip );
delay( 100 );
lastConnectionTime = postingInterval;
}
void loop(){
if( millis()-lastConnectionTime > postingInterval ){
int status = datain.syncPachube();
String stat = char(status);
GetDataStream( datain );
lcd.clear();
if( status != 200 ){
lcd.setCursor( 20 - stat.length(), 0 ); // if connection to Pachube is NOT OK then status "number" is shown in upper right corner
lcd.print(status);
}
else {
lcd.setCursor( 19, 0 );
lcd.print("."); // if connection to Pachube is OK (status code=200) then "." is shown in upper right corner
}
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor( 0, 0 ); // FIRST row - Outer temperature
lcd.print("Outer:");
lcd.setCursor( 13 - data[3].length(), 0 );
lcd.print(data[3]);
lcd.setCursor( 13, 0 );lcd.print(char(223));lcd.print("C");
lcd.setCursor( 0, 1 ); // SECOND row - Inner temperature
lcd.print("Inner:");
lcd.setCursor( 8, 1 ) ;
lcd.print(data[0]);
lcd.setCursor( 13, 1 );lcd.print(char(223));lcd.print("C");
lcd.setCursor( 0, 2 ); // THIRD row - Names of another three values
lcd.print("Press");
lcd.setCursor( 9, 2 );
lcd.print("Trend");
lcd.setCursor( 16, 2 );
lcd.print("Accu");
lcd.setCursor( 0, 3 ) ; // FOURTH row - atm.pressure, trend and accu voltage values
lcd.print(data[1]);
lcd.setCursor( 11 - data[2].length()/2, 3 ) ;
lcd.print(data[2]);
lcd.setCursor( 17, 3 ) ;
lcd.print(data[4]);
lastConnectionTime = millis();
}
if( millis()-lastConnectionTime > postingInterval/2 ){ // in the half of posting period the Units are shown in THIRD row instead on value's names
lcd.setCursor( 0, 2 );
lcd.print(" hPa Pa/Hr mV");
}
}
void GetDataStream( const ERxPachube& pachube ){
unsigned int count = pachube.countDatastreams();
for( unsigned int i = 0; i < count; i++ ){
data[i] = ( pachube.getValueByIndex(i) );
}
}
I recover all 5 values from Pachube: Outer and inner temperature, atmospheric pressure and trend of its changes, and LiPO accumulator voltage. My Pachube feed is 25574, so you may check it on Pachube's site.
The sketch is very simple. The ways how to display the values on LCD is endless so take my layout as an idea only. If you have any questions don't hesitate to contact me either here or on synekvl AT gmail DOT com
Have a nice day
Vladimir




Logged

and let me know whether you can compile it in IDE 1.0 (maybe I have something wrong here).