Etherten + LCD - D4 contention

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
Post Reply
Joined:Thu Dec 01, 2011 7:57 pm
Etherten + LCD - D4 contention

Post by bobj » Thu Dec 01, 2011 8:32 pm

Hi there,
Working with Etherten and Freetronics LCD & Keypad shield for a network connected temp logger project and hit a snag.

Intent is to
- Powered via PoE
- Boot and get an IP via DHCP - if no DHCP IP provided, use a default IP
- Display IP on the LCD Line 1
- Monitor temp with a DS18B20 temp chip (will replace with your mounted DS18B20 or Temp/Humidity sensor later)
- Display current temp and last temp written to SD on Line 2 of LCD
- Track time via NTP
- log temp to SD card at (say) 10 minute intervals with an accompanying timestamp in CSV format
e.g. nnn.nn, YYYYMMDDmm - minute level precision is adequate
- Close log file at midnight and open another log
- Log files to named based on date, e.g. 20111202.csv, 20111203.csv, etc...
- Allow http access to SD card to view and collect log files.
Wish list
- Would be nice to be able to email these off to an address each day... :)
- Would be nice to allow the LCD keys to select a threshold temp at which the unit emails an alert once exceeded.

Quite a bit going on and not sure if I can code all of that in the memory space available, but I'm working thru piecing it together (slowly) now. But that's not the prime issue.
The issue is the Freetronics LCD and Etherten SD both use pin 4.

.......... code fragment (before void setup) .....................
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 ); //Pins for the freetronics 16x2 LCD shield. LCD: ( RS, E, LCD-D4, LCD-D5, LCD-D6, LCD-D7
String line1 = " ";
String line2 = " ";

const int chipSelect = 4;

Given both are using pin 4, when the SD code throughout the pde is commented out, the LCD temperature display works a treat. When the SD code is enabled, the LCD goes blank - expected result given the clash.

Is it possible to use both together? Maybe by somehow 'deselecting' 4 to allow the LCD to display, then reselecting it for an SD write cycle and so on, inside the void loop?

I'd rather have the local display (LCD) remain in the project, if possible.

I note in the Etherten Quick Start guide page ( ... tart-guide)
you indicate pin sharing is perfromed already.....Note that even though both the Ethernet chipset and the microSD card slot use pins D11, D12, and D13, you can still have both features operating at the same time because they can share those pins. You can therefore combine those features to do things like display a list of files on a microSD card in a web page.

But I cant see how or if the same 'sharing' arrangement is possible for the LCD.

Anyone have any idea or hints?

Joined:Sun Dec 04, 2011 6:00 am

Re: Etherten + LCD - D4 contention

Post by JollyJohn » Sun Dec 04, 2011 6:06 am

Not totally sure - but this combination is working for fine for me. The trick might be that I have a card in the slot and don't plan on removing it. I can R/W the SD card and the display works. Might be a bugger if you plan to remove the card and want to detect when it is available - but if you don't you may be fine. (Since I have to disassemble the project to remove the card and plan to dump the data over the network it's not a problem for me.)


Joined:Thu Dec 01, 2011 7:57 pm

Re: Etherten + LCD - D4 contention

Post by bobj » Sun Dec 04, 2011 9:00 pm

Thanks Jolly John,
Your success gives me confidence that I am on the right track.
Can you advise if your setup lines same as those I posted for the LCD and the ChipSelect? Any chace y might share some portions of your code to assist me further?


Joined:Sun Dec 04, 2011 6:00 am

Re: Etherten + LCD - D4 contention

Post by JollyJohn » Mon Dec 05, 2011 8:35 am

Certainly - here is an excerpt from the code. Hope it helps:

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

** SD card datalogger
** The circuit:
** analog sensors on analog ins 0, 1, and 2
** SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4

#include <SD.h>

// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 4;

** Now set up all the bits and pieces

void setup()
// set up the LCD
pinMode(LCDBACKLIGHT, OUTPUT); // LCD backlight
digitalWrite(LCDBACKLIGHT, HIGH); // Turn on the backlight

lcd.begin(16,2); // number of columns and rows:
lcd.clear(); // Clear the display
lcd.print("- Initialising -"); // Display startup message

Joined:Thu Nov 03, 2011 4:36 pm

Re: Etherten + LCD - D4 contention

Post by EpicTinker » Tue Dec 06, 2011 7:00 pm

Hey Bobj,

Since you are using an Etherten, have you considered using Pachube or to collect and graph/share your data? That way, you don't have to store the files on the SD card, and can just download them later from the website if you want to retain it longer. Both services are free, Pachube seems more mature, but Partcl is super simple to use.

Hope this helps.

Joined:Wed Jan 28, 2015 12:28 pm

Re: Etherten + LCD - D4 contention

Post by pinmikaa » Wed Jan 28, 2015 12:33 pm

From a code point of view the EtherTen is just like taking an Arduino Uno and an Ethernet Shield and squashing them together onto the same PCB, so example code such as the project referenced in your link *should* work just fine. 70-685
If you're running into problems it's likely to be related to the setup of the libraries, so don't worry, it's almost certainly something that can be sorted out!

Post Reply