I assembled a wind speed sensor using Adafruit’s Anemometer Wind Speed Sensor w/Analog Voltage Output, an Arduino Uno and a 16x2 LCD display and it works just fine. I decided to log the data and added Adafruit’s Data logger and now I have problems. The LCD display works but the A0 input used for data input just reads a constant value no matter what the wind speed is. Remove the Data Logger and everything is fine. I checked the wiring and solder connections and don’t see any problems.
Any suggestions on how to proceed?
Tom,
Need some help with the Data Logger Shield
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Need some help with the Data Logger Shield
What is the constant value that it reads?
Please post some clear photos showing your soldering and connections.
Please post some clear photos showing your soldering and connections.
- tsans99
- Posts: 12
- Joined: Thu Nov 18, 2021 4:17 pm
Re: Need some help with the Data Logger Shield
Attached are 2 images. The first is a screen shot of the Serial Monitor displaying the input value of A0. It settles down to about 339 in an hour or so. The second is an image of the solder joints on the shield. It looks a bit messy after I had to move the wires out of the way to get a clear image. The 2 solder "blobs" are Gnd and +5V.
Any help would be appreciated.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Need some help with the Data Logger Shield
I see a lot of wires, but the photo does not show where they all go, Please post photos showing all your connections. Also please post the code you are using.
- tsans99
- Posts: 12
- Joined: Thu Nov 18, 2021 4:17 pm
Re: Need some help with the Data Logger Shield
Code: Select all
Pic 1 shows the wiring on the breadboard as shown in the Fritzing file attached. Pic 2 shows the Data Logger attached and pic 3 is just a side view of the 3 boards attached,
The Sketch “Test_wo_Logger_Code” is a simple one to take the inputs of the anemometer and display the results on an LCD. It works as expected with and without the Data Logger attached. The Sketch “Test_with_Logger_Code” is the same Sketch but with a few lines added to see if the SD card could be initialized and written to. The test works just fine with only the Data Logger attached to the Arduino but fails to initialize when all 3 components are connected.
My conclusion is that the Arduino and Data Logger communicate as expected and nothing is wrong with either so there must be something in my design or construction of the breadboard circuit that is causing the problem.
Any ideas? Any help would be appreciated.
Tom
/*
Test wo Logger Code
*/
//Initialise LCD display
#include <LiquidCrystal.h>
LiquidCrystal lcd(4, 6, 9, 11, 12, 13);
//Setup Variables
const int sensorPin = A1; //Defines the pin that the anemometer output is connected
float sensorInput; // Raw data fron sensor input
float sensorvalue;
int numbercount = 10; //Number of inputs to average
float inputsum = 0; //sum of inputs during count cycle
float avginput =0; // average input value for (numbercount) inputs
int mapval = 0; //Value of avginput mapped to 0 to 72
int delaysec = 10000; // Time for delay in updating reading
int chipSelect = 10; // chipselect pin for the SD card reader
void setup()
{
//Setup LCD display with welcome screen
lcd.begin(16, 2);
lcd.print("TAS 11-28-21");
lcd.setCursor(0, 1);
lcd.print("Windspeed Sensor");
lcd.setCursor(0, 0);
Serial.begin(9600); //Start the serial connection
}
void loop()
{
sensorInput = analogRead(sensorPin); //Get a value between 0 and 1023 from the analog pin connected to the anemometer
sensorvalue = sensorInput;
inputsum=0;
for (int i = 1; i <= numbercount; i++) //Count number of cycles taken for average
{
inputsum = inputsum + sensorvalue; //Accumulate readings for average
}
avginput=inputsum/numbercount; // compute average input value for (numbercount) inputs
Serial.print("avginput: ");
Serial.println(avginput);
mapval=avginput;
mapval = map(mapval,87,1023, 0,72); // mmap averag value to wind speed
if(mapval <0) { mapval=0;}
Serial.print("mapval: ");
Serial.println(mapval);
lcd.setCursor(0, 0);
lcd.print("Wind MPH = ");
lcd.print( mapval);
delay (delaysec); // Delay so reading updates every x seconds
}
====================================================================
/*
Test with Logger Code
*/
//Initialise LCD display
#include <LiquidCrystal.h>
#include <SPI.h> // Include SPI library (needed for the SD card)
#include <SD.h> // Include SD library
LiquidCrystal lcd(4, 6, 9, 11, 12, 13);
//Setup Variables
const int sensorPin = A1; //Defines the pin that the anemometer output is connected
float sensorInput; // Raw data fron sensor input
float sensorvalue;
int numbercount = 10; //Number of inputs to average
float inputsum = 0; //sum of inputs during count cycle
float avginput =0; // average input value for (numbercount) inputs
int mapval = 0; //Value of avginput mapped to 0 to 72
int delaysec = 10000; // Time for delay in updating reading
int chipSelect = 10; // chipselect pin for the SD card reader
void setup()
{
//Setup LCD display with welcome screen
lcd.begin(16, 2);
lcd.print("TAS 11-28-21");
lcd.setCursor(0, 1);
lcd.print("Windspeed Sensor");
lcd.setCursor(0, 0);
Serial.begin(9600); //Start the serial connection
while (!Serial) {; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin()) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
}
void loop()
{
sensorInput = analogRead(sensorPin); //Get a value between 0 and 1023 from the analog pin connected to the anemometer
sensorvalue = sensorInput;
inputsum=0;
for (int i = 1; i <= numbercount; i++) //Count number of cycles taken for average
{
inputsum = inputsum + sensorvalue; //Accumulate readings for average
}
avginput=inputsum/numbercount; // compute average input value for (numbercount) inputs
Serial.print("avginput: ");
Serial.println(avginput);
mapval=avginput;
mapval = map(mapval,87,1023, 0,72); // mmap averag value to wind speed
if(mapval <0) { mapval=0;}
Serial.print("mapval: ");
Serial.println(mapval);
lcd.setCursor(0, 0);
lcd.print("Wind MPH = ");
lcd.print( mapval);
delay (delaysec); // Delay so reading updates every x seconds
}
- tsans99
- Posts: 12
- Joined: Thu Nov 18, 2021 4:17 pm
Re: Need some help with the Data Logger Shield
Sorry, I forgot to add the Fritzing image.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Need some help with the Data Logger Shield
the issue is here:
On an Arduino UNO, pins 11, 12 and 13 are part of the SPI bus - which is used to communicate with the SD card.
It looks like you have a few free pins in your Fritzing diagram. So you should be able to re-configure the LCD to avoid the SPI bus.
Code: Select all
LiquidCrystal lcd(4, 6, 9, 11, 12, 13);
It looks like you have a few free pins in your Fritzing diagram. So you should be able to re-configure the LCD to avoid the SPI bus.
- tsans99
- Posts: 12
- Joined: Thu Nov 18, 2021 4:17 pm
Re: Need some help with the Data Logger Shield
I reconfigured as shown in the attached Fritzing but I still get the "Failed to initialize" message. I don't know enough about the code for the Data Logger so is what I have coded correct? Any other suggestions?
Also, where do I get information about the pins on the Data Logger. All I've ever seen referenced is Pin 10.
Thanks,
Tom
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Need some help with the Data Logger Shield
Did you change your code to match the new wiring configuration?
- tsans99
- Posts: 12
- Joined: Thu Nov 18, 2021 4:17 pm
Re: Need some help with the Data Logger Shield
Yes, I changed the code to match the new wiring.
BUT!!!! I think I got it.
As I said, a little knowledge to get me into trouble. I noticed the 6 pins on the edge were labeled SPI so I added some connectors to get the Arduino in contact with the Data Logger and guess what, it works and that program now initializes the SD card. I've yet to write to the SD but I'm hopeful.
Thanks again,
Tom
BUT!!!! I think I got it.
As I said, a little knowledge to get me into trouble. I noticed the 6 pins on the edge were labeled SPI so I added some connectors to get the Arduino in contact with the Data Logger and guess what, it works and that program now initializes the SD card. I've yet to write to the SD but I'm hopeful.
Thanks again,
Tom
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Need some help with the Data Logger Shield
If you install the 6-pin ICSP header packed with the kit, those SPI connections should be automatic for all but the oldest models of Arduino.
- tsans99
- Posts: 12
- Joined: Thu Nov 18, 2021 4:17 pm
Re: Need some help with the Data Logger Shield
I didn't install them because I wanted headers that would allow me to "thru-connect" the Data Logger through the breadboard to the Arduino. I've corrected that and now things work fine. My next problem, learning how to use the RTC clock.
Thanks,
Tom
Thanks,
Tom
- rpiloverbd
- Posts: 198
- Joined: Mon Nov 29, 2021 8:13 am
Re: Need some help with the Data Logger Shield
What if you change your input pin? Suppose, if you chose A1 or A5 instead of A0, does the problem persist?
Please be positive and constructive with your questions and comments.