17.3.13

Hall Effect

PLC Programming

Protesus Isis- Ares (turkish)

MECHATRONIC


2.2.13

The Current War


Worldwide SMTP Email Service For Travelers!

Click Here!

Holiday Light Bokeh for iPhone or any Smartphone!




'Tis the season for holiday lights and fun photos! And what better way to capture all those pretty lights than bokeh photography? In this Instructable, I will show you how to take bokeh photos with your iPhone or smartphone. There are apps that superimpose blurs, spots, and streaks, but our aim is to take authentic and beautifully blurred pictures on the go.

Before we begin, let's talk a little bit about the technique. Bokeh is the visually pleasing quality of an out-of-focus photo.The reason why our phones can't capture blurred lights with its built-in camera is because the lens is set to have a large depth-of-field. It tries to focus in on the entire scene, which is also why camera phones have a harder time focusing on subjects that are close-up. Since we can't narrow the depth-of-field by adjusting the aperture to a larger size (smaller f-stop), we have to bring the focal point to the foreground by some other means. In order to do this, we will need to use a macro lens. 


Disclaimer: I am in no way responsible for any damage that you may do to your device or yourself.


Step 1: Materials List



Materials:

-Cheap SLR Telephoto Lens
-Fishing Pliers
-Flathead Screwdriver
-Scissors
-Assortment of Precision Screwdrivers
-Locktite Fun-Tak (optional)
-Electrical Tape (optional)
-Phone Case (optional)


Step 2: Disassemble Lens

After you have found the telephoto lens that you are willing to sacrifice (hopefully it's already broken), you will begin disassembling it. This is the hardest part of the entire procedure. You will be working with metal and glass, and if negligent, you could easily hurt yourself, so be careful. If you are unsure you can handle this, there are other ways of obtaining these lenses. You could just as easily purchase a macro lens for your phone online. A negative film magnifier would probably work for this project as well. I'm only suggesting to take apart a telephoto lens for a few reasons: 1.) You will be rewarded with a handful of various shaped lenses that are fun to mess around with. 2.) You get the satisfaction of successfully taking a complex mechanism apart, and 3.) you get to learn how it works. As you go along, just remember that you have to be smarter than the piece of metal or plastic you're working with.

Follow the tips in the photographs for common things to look for as you disassemble your lens. Wear gloves if you can and use the fishing pliers to unthread things you can't get your fingers on.



Step 3: Find and Test Your Macro Lenses

You should now have a bunch of lenses, some being biconvex. You can test each lens by placing it in front of your phone's camera. Try to focus on a small object, and set aside those that magnify while noting which one gives you the best clarity.

Step 4: Try Combining Lenses

Because we now have a handful of lenses, we can experiment and learn a few things about optics. Try combining lenses in different combinations to see what types of results you get. As you can see in these pictures, I've somewhat made a telephoto and a wide angle lens. Luckily, the two lenses worked by placing them back to back. I used electrical tape as a way to join these two together.



Step 5: The Bokeh Effect

Now go ahead and set up a room where candle lights or Christmas lights are the most prominent light source. Grab the macro lenses you had set aside and test each one by holding it in front of your phone. Whichever one gives you the least magnification with satisfactory blur is the lens that will probably work best. Picking the one with the least magnification will allow you to focus on larger objects while still achieving beautiful unfocused spots of light in the background. When you're happy with your results, you can choose how you want to attach your lens to your phone.

Step 6: Attach the Lens to the Phone



Now this last part is completely up to you. I have suggested in a related Instructable that Loctite removable Fun-Tak is a feasible way to adhere a lens to a phone, however I am not fond of it. The agent does not set up and allows for quick removal and application of the lens, but if some of the putty gets in the nooks and crannies of your phone, you may not be able to get it out. If you use it, don't use a lot. A better option for mounting the lens would be your own personalized method. I have slipped smaller lenses under the rubber of my Otterbox case and that worked well. Another member had suggested having a standalone case that you adhere the lens to. Perhaps you could use a rear shell case and attach it to that, which would make removing and attaching a breeze. Any easy and cheap ideas are also welcome.

(Special mention to Instructables member Messy Desk for case suggestion and inspiring this project)

I hope that this was helpful. I'm entering this step-by-step into the Instructuable Photography Contest along with another macro lens Instructable I had authored. Any votes my way would be deeply appreciated.

Happy Holiday Photos and Be Safe. 

SandFlea - Leaps Small Buildings in a Single Bound (Boston Dynamics)



Sand Flea is an 11 pound robot that drives like an RC car on flat terrain, but can jump 30 ft into the air to overcome obstacles. That is high enough to jump over a compound wall, onto the roof of a house, up a set of stairs or into a second story window.
The robot uses gyro stabilization to stay level during flight, to provide a clear view from the onboard camera, and to ensure a smooth landing. Sand Flea can jump about 25 times on one charge. Boston Dynamics is developing Sand Flea with funding from the US Army’s Rapid Equipping Force (REF).
Earlier versions of Sand Flea were developed by Sandia National Laboratory with funding from DARP) and JIEDDO.


more

LS3 - Legged Squad Support Systems (Boston Dynamics)



LS3 is a dynamic robot designed to go anywhere Soldiers and Marines go on foot. Each LS3 will carry up to 400 lbs of gear and enough fuel for missions covering 20 miles and lasting 24 hours. LS3 will not need a driver, because it will automatically follow a leader using computer vision or travel to designated locations using sensing and GPS. The development of LS3 will take 30 months, with first walk out scheduled for 2012. The development of LS3 is being funded by DARPA and the US Marine Corps.
Boston Dynamics has assembled an extraordinary team to develop the LS3, including engineers and scientists from Boston Dynamics, Bell Helicopter, AAI Corporation, Carnegie Mellon, the Jet Propulsion Laboratory, and Woodward HRT.




more

LaserGloves

In this tutorial I will show you my somewhat new lasergloves, made 3 hours before this was written.
Perfect for the party or just showing off your friends.
It's shake-able, meaning you can wave your hands in the air like crazy, and they won't come apart. (!)
Haven't found anything like this on the web, or on instructables, so finally i'm first with something :P

Update: A movie with it in action!



The Number 1 Movie Downloads

Click Here!

Remote control via GPRS/GSM SMS




Remote control, it has been a very profound things in the past. When I was a child, I always imagine that I have an equipment which can control all home appliances. Now, this has become a reality, and it is quite easy. Then I will step by step to show you how to remote control your home appliances via the GPRS/GSM SMS and relays.

At first, let me give a brief introduction about relay to you.
Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. It acts as a “low voltage controlled switch to control high voltage”, For example, if you want to control power of your washer or air conditioner, which is oftern110v or 220v,by microchip, such as AVR or PIC, it is necessary and safe the make your microchip control the relay first, and then control the power supply of those device with the relay.

With the GSM SMS, it is possible to control the relay remotely. You can send a message via phone to control the relay on&off. With this, it will convenient to control any device wirelessly, especially helpfully on irrigation, smart home, outdoor remote control etc.
So, let’s make such a “SMS control relay” with Arduino, GPRS/GSM and a Relay module.

Step 1: Prepare your tools and parts


Select the module you need, a Xrduino, a GPRS/GSM module and relay module is essential. The GPRS/GSM and relay in “Shield” would be more Convenient if works with Arduino. Notice that the Rated Current of the relay Is important, make sure it meets your requirements. Otherwise it maybe dangerous. Here, I use a 2A rating current relay, which is enough for my application to control a lamp. Usually, home appliances consume currents as below:

Device                          Max current(A)
Electric Fan                            1
Lamp                                       2
TV                                             2
Refrigerator                            2
Microwave Oven                    8
Air Conditioner Depends on the power, usually <20

The modules I used in this application are as below:
Crowduino
Elecrow GPRS/GSM Shield
Elecrow Relay Shield

Step 2: Insert a SIM card to the GPRS shield.


The gprs module needs a SIM card to work, just the same as a phone. Insert a SIM card to the SIM socket , make sure the SIM is unlocked. Record the number of SIM Card, it will be used in programming for Arduino.

Step 3: Communicate with Crowduino/Arduino by hardware serial.

There are two methods for GPRS/GSM Shield to communicate with the micro controler, one is through the software serial port, another is hardware serial port. I will show you the second method, communicate with the Crowduino/ Arduino by hardware serial port. There are three pins 2*3 pins in the GPRS shield. You can see the silk mark in both side of pins, one side is Xduino(this is connect to the hardware serial port), and the other side is SWserial(this side is used as software serial port).  Just as the picture, plug the jumper caps to the Xduino side.

Step 4: Upload the program.


As the programming, you will need the Arduino IDE to compile and download the program to Arduino.
Download the code :

Using_SMS_to_Control_Relay_Hardware Serial.ino

Before the compiling, please Open the file: SoftwareSerial.h in arduino\libraries\SoftwareSerial, and modify the
#define _SS_MAX_RX_BUFF 64 // RX buffer size
To
#define _SS_MAX_RX_BUFF 128 // RX buffer size
With this modification, the Arduino would have more buffer for the received message to avoid any communication bugs.
If you have not got ready to comprehend the details, you can just copy the codes into your Arduino IDE and down it to Arduino to continue.

Then, open this file by Arduin IDE.  Upload the program to the Crowduino, please note that don't connect the GPRS shield to Crowduino when uploading program,  very important!!!!

Step 5: Plug shields to the Crowduino

Plug your shields to the Crowduino, you can put the GPRS Shield in the top or put the Relay Shield in the top. In here, because we need operating the Relay Shield later, so I put the Relay Shield in the top.

Step 6: Control the Relay shield by manually.

Now, the hardware has been connected, the program has been uploaded, we can have a try to the Relay Shield, This Relay Shield is very interesting! There are 4 Independent relays on the relay shield, each one can be controlled by the Arduino or manually. Also, there are 4 LEDs to show user the working state of relays.

Step 7: Have a test for the manual control.




Before remote control the lamp, we can make a test. Here, we need a breadboard, a LED, two AA battery and some breadboard cables.

Plug the anode wire(the red one) of power supply to the anode of LED via the breadboard, using the same method, plug the breadboard jumper wire to the cathode of LED.

As we only need one relay here, we use the relay U3, which was controlled by the Arduino Pin5.
There are 3 terminals for U3 relay: COM3, NC3 and NO3. The COM3 is the common port, while the “NO” means “Normally Open” and NC means “Normally Connected”. That’s to say, the logic between these 3 terminals is:
When the relay is not active:
COM3 connected to NC3 and disconnected to NO3;
When the relay is active:
COM3 disconnected to NC3, and connected to NO3;

Insert the cathode wire(black one) of power supply to NO3, insert the cathode wire(orange) of LED to COM3 and tighten the terminal with a screwdriver.

Now, you can control the LED on or off via button 3, it is funny, hah...

Step 8: Control the LED via SMS.





It is time to take out your mobile phone, (make sure your Gprs/Gsm shield is on) sent a text ”onb” to the number of the SIM card in GPRS module, the relay would be on, and the LED on!

It is necessary to explain the program, if you feel it is boring or it is too simple, just skip the following paragraph and remember there are 4 relays: U1, U2, U3, U4 each corresponding to d, c, b, a, if you want to control U1 on or off, you can send 'ond' or 'offd' to the number of the SIM card in GPRS module, the relay U1 would be on or off. If you want to control multiple relays in one SMS, just send the control commands in one SMS. For example, if I want to control U1, U2, U3 on and U4 off, sending 'ond onc onb offa' would reach this purpose. In here, I was using U3 to control the LED, so after I send 'onb', the relay U3 would be on , and the LED on!

There are some important functions you need to learn if you want to learn more on the gprs shied:

void ProcessGprsMsg()
Function: process the data Arduino get from the GPRS shield. If there is a string “+CMGR:” in the received data, theArduino will get to know: “I have received a short message, I need to analyze the message to know what to do next!”
Parameter: none
Return: none;

void ProcessSms( String sms )
Function: Arduinoanalyze the short message received. As received a string: ”ona”, it will pull up the related pin to active the relay, making the terminal COM4 connected NO4; while received a string “offa”, it will pull down the pin to make the COM4 and NO4 disconnected.
Parameter: the received message;
Return : none
In this program, once the Arduino receive the command ”offa”, which means “off the a” it will pull download the Arduno pin4, which change the relay U4 from inactive to active state. You will hear some noise like “bang..bang”, and also the LED would blinks.

Step 9: Connect the Device to the Relay shield.




Step 10: Control the lamp via SMS.


You can control all the device you want via this method. and, you can even control 4 relays simultaneously to control 4 device by modifying the program in Arduino. But again, notice the Potential danger especially for the high voltage and big current decice. Good luck…

Darkness Map Data Collection Device

The Darkness Map encompasses both data collection and visualization of nighttime light levels. You can add to the map by downloading the app for iPhone or Android, but you can also contribute data by creating your own data collection device. This tutorial will cover how to build an Arduino powered data logger with a light intensity sensor. Since the sensor modules are attached to the Arduino on a breadboard, it's fairly simple to swap out the light sensor for a different sensor of your choosing. You can use the device to log data about temperature, air quality, noise, and many other environmental factors, and because everything is attached by breadboard, you can easily adapt it to use in other projects.

Step 1: Parts You Need


Arduino Uno - available from a variety of online resellers, and even your local Radioshack.
Adafruit Proto Shield for Arduino Kit
Adafruit Ultimate GPS Breakout Kit
Adafruit MicroSD card Breakout Board
TSL2561 Digital Luminosity/Lux/Light Sensor
Half-size breadboard
CR1220 Coin Cell Battery - also available at drug stores, other online resellers
MicroSD Card - you can also repurpose one from an old mobile phone
9V Battery clip
9V Battery
The parts for each device cost about $90, not including the Arduino Uno.



Step 2: Solder Your Breakout Boards and Kits


First things first, you'll want to put together the Proto Shield kit. Adafruit has a great step by steptutorial on how to attach and solder all the necessary parts. When it comes time to attach the last parts, don't, as we'll be putting the half-sized breadboard on top of the protoshield.

Next, attach and solder the header pins to the GPS module, MicroSD breakout board, and the TSL2561 light sensor. You may want to tape them if they aren't staying put as you solder. To attach the coin cell battery holder to the back of the Ultimate GPS module, heat the pads on either side of the battery holder with the tip of your soldering iron. Once they're hot enough, let solder flow on top and hold the battery holder in place until the solder hardens.

After you have soldered all your header pins, you are ready to start connecting the modules together. Follow the steps in the Proto Shield tutorial, and break off the sides of the half-sized breadboard. Then peel the adhesive backing off the back of the breadboard and attach it to the top of the Proto Shield.

Once you have all the modules put together, it's time to connect the wiring.

Step 3: Set up the GPS Module




First, you'll want to set up your Ultimate GPS Module and make sure it's working properly. In order for the GPS to get a signal, you'll want to work near a window (possibly even outside), so that you can stick your Arduino and GPS module on a window ledge for it to get a reading. As per the Adafruit tutorial, you can initially wire it so that it bypasses the Arduino's ATMega chip, and communicates directly with your computer's USB serial port. In order to do this, just wire the GPS module's +5V pin to the Arduino's +5V pin, Ground to the Arduino's Ground pin, RX to pin0 and TX to pin1. Next upload a blank sketch, where both the void setup() and void loop() functions are empty. Open the serial monitor in Arduino and you should start seeing a bunch of characters start to spit out. Make sure the serial baud rate is set to 9600. This is raw GPS NMEA code, which you can read more about here.

Find the line that starts with $GPRMC. The first section is GMT (Greenwich Mean Time), next is the letter A which means the GPS module is Active (as opposed to V which would be void). Then next four values are the Geolocation data. In Brooklyn, NY my location data reads: 4041.3198,N,07357.5915,W. This translates to (Latitude 40 degrees, 41.3198 decimal minutes North and Longitude 73 degrees, 57.5915 decimal minutes West). To check this against google maps, you'd covert it into degrees of latitude and longitude that google understands. I typed in +40 41.3198 ,- 73 57.5915, and it was able to find the correct location. If you're getting readings with lots of zeros, try placing the GPS further on the window ledge.

Next, you'll want to wire the GPS to your Arduino. Change the wiring so that the GPS Module's RX pin is connected to Arduino pin2, and it's TX pin is connected to pin3. Adafruit has a GPS library, but we'll be using the TinyGPS library by Mikal Hart. Download the latest version of the library and put the folder inside Documents --> Arduino --> libraries. Make sure it's called TinyGPS. Open the simple test example sketch. Notice how the serial monitor is set to a baud rate of 115200. Also, where it says
ss.begin(4800); change that to be ss.begin(9600); since the Ultimate GPS Module samples at a 9600 rate. Save your changes and upload it to the Arduino.

Once the sketch is uploaded, open your serial monitor. If you see a bunch of weird characters, change the baud rate to 115200. Then you should be able to see the data being printed to the serial monitor. If you're not seeing any GPS data, you may have to put your module on the window ledge again since it's most likely not receiving any new GPS signals.

If your GPS module is working correctly and you've been able to run the TinyGPS library code, the next step is adding the MicroSD breakout board to the Arduino, and seeing if we can save our GPS data to a text file on the MicroSD card.


Step 4: Set up the MicroSD Breakout Board



In order to see if the SD card is formatted correctly, and if the MicroSD card breakout board is setup properly, you'll want to take the GPS module off your breadboard for now and work with the MicroSD card breakout board on its own. Feel free to leave your wires in the breadboard so you can remember to leave space for the different modules. For our purposes, wire the MicroSD card like this:

--5V pin to Arduino 5V pin
--Ground to Arduino Ground pin
--Clock pin to Arduino's pin13
--DO pin to Arduino pin12
--DI pin to Arduino pin11
--CS pin to Arduino pin10

Now you'll want to open an example from the SD card library, which comes with Arduino. We'll be checking whether our MicroSD breakout board is wired up properly, and if the SD card is formatted correctly using the CardInfo sketch. Before you upload the code to the Arduino, make sure you change one line of code. The chipSelect pin should be set to 10, not 4.

const int chipSelect = 10;

Upload the code to the Arduino and turn on the serial monitor. If your serial monitor gives you a message that it can't initialize the card, try reformatting it to FAT32 or FAT16 using your Disk Utility application. If you have further problems, follow the steps in the Adafruit tutorial.

Next let's see if we can write files to our SD card. Open the Files example from the SD library. Make sure to change chipSelect to equal 10, not 4. Upload the code and turn on the serial monitor. If it successfully creates and removes the example.txt file then congratulations, you're able to write to an SD card.

Next we want to see if we can get the Arduino to save our GPS readings to the SD card. Disconnect your Arduino from the computer. Put the GPS module back in place. In order to connect both the GPS and MicroSD card breakout board to 5V and Ground on the Arduino, we'll want to bring the power and ground to the breadboard, and then connect it to each module.

Now, upload the following code to your Arduino. It's best if the Arduino is back out on your window ledge so you can get a GPS reading. You can check to see what's happening by opening the serial monitor, but make sure to change the baud rate to 115200 or else the characters won't make much sense. You should be seeing rows of three values. First the longitude coordinate, next the latitude coordinate, and finally the unix timestamp.


#include "Wire.h"
#include "SD.h"
#include "SoftwareSerial.h"
#include "TinyGPS.h"
#include "RTClib.h"

const int chipSelect = 10;
RTC_Millis RTC;
File dataFile;

TinyGPS gps;
SoftwareSerial ss(3, 4);

void setup() 
{
  Serial.begin(115200);
  Serial.print("Initializing SD card...");
  ss.begin(9600);
  pinMode(chipSelect, OUTPUT);
  RTC.adjust(DateTime(__DATE__, __TIME__));
 
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    while (1) ;
  }
  Serial.println("card initialized.");
 
  // Open up the file we're going to log to!
  dataFile = SD.open("GPStest.txt", FILE_WRITE);
  if (! dataFile) {
    Serial.println("error opening GPStest.txt");
    // Wait forever since we cant write data
    while (1) ;
  } 
}

void loop()                  
{
  DateTime now = RTC.now();
  bool newData = false;

for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

    if (newData)
  {
    float flat, flon;
    unsigned long age;
    int year;
    byte month, day, hour, minute, second, hundredths;
    gps.f_get_position(&flat, &flon, &age);
    gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
        char sz[32];
    sprintf(sz, "%02d/%02d/%02d, %02d:%02d:%02d,  ",
     month, day, year, hour, minute, second);
   
    Serial.print("");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(", ");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(", ");
    Serial.println(now.unixtime());

    dataFile.print("");
    dataFile.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    dataFile.print(", ");
    dataFile.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    dataFile.print(", ");
    dataFile.println(now.unixtime());
  }

  dataFile.flush();
  delay(500);
}

Now unplug your Arduino and eject the MicroSD card from the breakout board. Find the SD card adapter and insert it into your computer, either with a card reader or directly if you have an SD card slot. See if there is a text file called GPSTEST.TXT. If there is, yay! If not, then I'd try reformatting your card and trying to write to it again. Open the text file and make sure the data has been written. Sometimes the file gets created but no data gets saved, and if this is your case, check your wiring, and try following LadyAda's SD card tutorials.

Step 5: Adding the Light Sensor



If you've been able to save GPS data to your SD card, the last step is adding our light sensor to the mix. Add the TSL2561 sensor to the breadboard. Wire it in the following way:

--Connect Ground to the Ground rail on the breadboard
--Connect the VCC pin to the 3V pin on the Arduino
--Connect the SCL pin to Arduino pin A5
--Connect the SDA pin to Arduino pin A4

We'll be using the TSL2561 Arduino libray from Adafruit. You can download it here, unzip it, and put in the Arduino libraries folder. If Arduino is open restart it for the library to appear in the Examples dropdown choices. Open the example sketch and upload it to the Arduino. Press the serial monitor to make sure it's reading data. Wave your hand over the sensor to see if that changes the light values. Once you're satisfied that your sensor is working, upload the following code to the Arduino:


// Darkness Map Data Collection Device
// Genevieve Hoffman, 2012
// TinyGPS Library, by Mikal Hart, download here: http://arduiniana.org/libraries/tinygps/
// TSL2561 Library, by Ladyada (Limor Fried), download here: https://github.com/adafruit/TSL2561-Arduino-Library
// RTClib, by Ladyada (Limor Fried), download here: https://github.com/adafruit/RTClib
// RTClib originally developed by Jeelabs: https://github.com/jcw/rtclib

#include "Wire.h"
#include "TSL2561.h"
#include "SD.h"
#include "SoftwareSerial.h"
#include "TinyGPS.h"
#include "RTClib.h"

const int chipSelect = 10;
RTC_Millis RTC;
File dataFile;

int sensorPin = A0;  // input pin from sensor
int lux = 0; // variable to store the value coming from sensor
TSL2561 lightSensor(TSL2561_ADDR_FLOAT);

TinyGPS gps;
SoftwareSerial ss(3, 4);


void setup() 
{
  Serial.begin(115200);
  Serial.print("Initializing SD card...");
  ss.begin(9600);
  pinMode(chipSelect, OUTPUT);
  RTC.adjust(DateTime(__DATE__, __TIME__));

 
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    while (1) ;
  }
  Serial.println("card initialized.");
 
  // Open up the file we're going to log to!
  dataFile = SD.open("Data5.txt", FILE_WRITE);
  if (! dataFile) {
    Serial.println("error opening datalog.txt");
    // Wait forever since we cant write data
    while (1) ;
  } 
    lightSensor.begin();
    if (lightSensor.begin()) {
    Serial.println("Found sensor");
  } else {
    Serial.println("No sensor?");
    while (1);
  }
 
  //lightSensor.setGain(TSL2561_GAIN_0X);         // set no gain (for bright situtations)
  lightSensor.setGain(TSL2561_GAIN_16X);      // set 16x gain (for dim situations)
  //lightSensor.setTiming(TSL2561_INTEGRATIONTIME_13MS);  // shortest integration time (bright light)
//lightSensor.setTiming(TSL2561_INTEGRATIONTIME_101MS);  // medium integration time (medium light)
lightSensor.setTiming(TSL2561_INTEGRATIONTIME_402MS);  // longest integration time (dim light)
}

void loop()                     // run over and over again
{
  DateTime now = RTC.now();
  bool newData = false;

for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
     // Read Light Sensor
     uint32_t lum = lightSensor.getFullLuminosity();
     uint16_t ir, full;
     ir = lum >> 16;
     full = lum & 0xFFFF;
     lux = lightSensor.calculateLux(full, ir);    
  }

    if (newData)
  {
    float flat, flon;
    unsigned long age;
    int year;
    byte month, day, hour, minute, second, hundredths;
    gps.f_get_position(&flat, &flon, &age);
    gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
        char sz[32];
    sprintf(sz, "%02d/%02d/%02d, %02d:%02d:%02d,  ",
     month, day, year, hour, minute, second);
  
    Serial.print("");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(", ");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(", ");
    Serial.print(sz); //prints out GMT time
    Serial.print("unixtime: ");
    Serial.print(now.unixtime());
    Serial.print(", Lux: "); Serial.println(lux);
   
    dataFile.print("");
    dataFile.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    dataFile.print(", ");
    dataFile.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    dataFile.print(", ");
    dataFile.print(lux);
    dataFile.print(", ");
    dataFile.println(now.unixtime());
  }

  dataFile.flush();
  delay(500);
}

Since the Darkness Map project is about collecting light values at night, you'll want to configure your TSL2561 sensor for dim lighting situations. So, you'll want to turn on the line of code that says:

lightSensor.setGain(TSL2561_GAIN_16X);      // set 16x gain (for dim situations)

and

lightSensor.setTiming(TSL2561_INTEGRATIONTIME_402MS);  // longest integration time (dim light)

Comment out the other lines that set the gain and the timing. And feel free to change these settings if you decide to use the TSL2561 sensor for other purposes.

After the code is uploaded, start the serial monitor, making sure it's set to 115200 baud rate. If the monitor stops printing out any information after "Found sensor," then your Arduino probably isn't picking up any GPS signal, and you'll want to stick it back out on your window ledge. You should start seeing values for the longitude, latitude, and lux and timestamp coming into the serial monitor. Congratulations! You've made yourself a datalogger.

Since everything is breadboarded, feel free to swap out the TSL2561 for another sensor of your choice in order to make another GPS enabled datalogger. The possibilities are endless!

Step 6: Troubleshooting

If you have trouble getting a GPS signal, or writing to the SD card, I'd recommend going through the Adafruit tutorials for the TSL2561 light sensor, the Ultimate GPS Module, and the MicroSD Breakout Board separately.

MicroSD breakout board tutorial

Ultimate GPS Module tutorial

TSL2561 Light Sensor tutorial