I am attempting to make a sunlight logger for my garden to figure out what spots gets how much sun.
Build #1 - Used Arduino Uno with LCD keypad Shield in conjunction with BH1750 light sensor. Works fine until I plug on the Data Logger shield, at that point, no output to LCD, and light readings are pegged out. The data log works and records to Excel, but the reading is being interfered with. (I2C two different addresses verified.)
Since the Data Logger is also using A4 A5, I figured I could circumvent the issue:
Build #2 - Used Arduino Uno with a photoresistor, no LCD, works fine outputted to serial. Connect Data Logger, false or no readings again.
What could this Data Logger be doing that is interfering with both setups? been searching for days with no luck. Battery installed, SD card installed, pre-assembled.
Build #2 - Used Arduino Uno with a photoresistor, no LCD, works fine outputted to serial. Connect Data Logger, false or no readings again.
Post a schematic and the code that you tried, please.
Build #1 - Used Arduino Uno with LCD keypad Shield in conjunction with BH1750 light sensor. Works fine until I plug on the Data Logger shield, at that point, no output to LCD, and light readings are pegged out. The data log works and records to Excel, but the reading is being interfered with. (I2C two different addresses verified.)
From my research and assuming the LCD keypad shield, I have found that the SD card uses pins 13, 12, 11, 10 and the LCD pins 8, 9, 4, 5, 6, 7 and pin 10 is backlight control. So pin 10 us used on both, but that should not prevent the LCD from working. You can change the SD card chip select pin.
if (!SD.begin(2)) { // SD CS to pin 2
What does the I2C scanner return with the LCD keypad shield and the data logger shield all connected?
// I2C scanner by Nick Gammon. Thanks Nick.
#include <Wire.h>
void setup() {
Serial.begin (115200); //***** make sure serial monitor baud matches *****
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 1; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}
When I have the Uno, Data shield, LCD keypad shield and Light sensor connected and run the scanner, I get
⸮5⸮5
This is the schematic I was using for the Photosensor test (not really wanting to use it though)
and the testing code....
#include <SPI.h>
#include <SD.h>
/* Sensor test sketch
for more information see http://www.ladyada.net/make/logshield/lighttemp.html
*/
#define aref_voltage 3.3 // we tie 3.3V to ARef and measure it with a multimeter!
int photocellPin = 0; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the analog resistor divider
//TMP36 Pin Variables
int tempPin = 1; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int tempReading; // the analog reading from the sensor
void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
// If you want to set the aref to something other than 5v
analogReference(EXTERNAL);
}
void loop(void) {
photocellReading = analogRead(photocellPin);
Serial.print("Light reading = ");
Serial.print(photocellReading); // the raw analog reading
// We'll have a few threshholds, qualitatively determined
if (photocellReading < 10) {
Serial.println(" - Dark");
} else if (photocellReading < 200) {
Serial.println(" - Dim");
} else if (photocellReading < 500) {
Serial.println(" - Light");
} else if (photocellReading < 800) {
Serial.println(" - Bright");
} else {
Serial.println(" - Very bright");
}
tempReading = analogRead(tempPin);
Serial.print("Temp reading = ");
Serial.print(tempReading); // the raw analog reading
// converting that reading to voltage, which is based off the reference voltage
float voltage = tempReading * aref_voltage / 1024;
// print out the voltage
Serial.print(" - ");
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((volatge - 500mV) times 100)
Serial.print(temperatureC); Serial.println(" degrees C");
// now convert to Fahrenheight
float temperatureF = (temperatureC * 9 / 5) + 32;
Serial.print(temperatureF); Serial.println(" degrees F");
delay(1000);
}
This is odd. Using the code from my original post, the backlight gives a slight blink in between loops.
However, changing the SD pin to 2 stops the LCD from even lighting. When the both use 10, the LCD at least lights up.
By looking at the physical circuit, from what I can tell, the digital pins used are:
LCD 4-8
SD 11, 13
Thanks
Thanks for your patience. Let me reorganize this please.
Let's take the LCD out of the equation for now and I will just use the serial monitor to view values.
With just Uno and Light sensor:
Light Sensor BH1750 Pinout:
VCC to Arduino 5v or 3.3V
Gnd to Gnd
SCL to Arduino A5
SDA to Arduino A4
ADDR to Gnd
That code produces accurate readings to the serial monitor.
When I add the Data Logger on, I get only max value readings around 65,000. Data logging works correctly, only the values read are in error using the following code:
and plug in the data logger shield. Do you get good light data in serial monitor? I am trying to see if it is hardware or software causing the problem.
So with the shield on and that code I am getting a 65,535 result only.
Here are some more details:
I removed the shield and then rebooted the Arduino, no serial response. I had to reupload code. Then, works correctly again. Add the shield, doesn't work even with reset, reupload same code again, it works, but with the pegged out value.
The I2C scanner reports the right I2C addresses for the DS1307 and light sensor with the data logging shield installed, but the light sensor will not work with the data logging shield installed, is that right?
Can you try a DS1307 (RTC) library example and see if the DS1307 will work.
I am kind of grasping at straws here cause I can't see any reason that the light sensor will not work.