Tag Archives: arduino

Arduino Weather Station

21 Mar

After not doing any Arduino fiddling for quite a while I have finally started a small project again. I have made a small weather station for measuring temperature and humidity levels in my home.

IMAG0092_2

The setup is based on an Arduino Uno with the standard Ethernet Shield (because it has an SD card reader) and a DHT-22 sensor that is connected as follows (following the docs):

  • Leg 1 (from the left) –> +5V
  • Leg 2 –> pin 2 (data input)
  • Leg 3 –> not connected
  • Leg 4 –> GND
  • 10k OHM resistor between +5V and data pin 2.

The code is pretty standard, a mixture of the SD library and DHT library code examples …  not really interesting. However, I have added a bit of code to calculate the dew point based on formulas I found on the web, which may be worth sharing here:

// Compute dew point (formula taken from here: http://www.wettermail.de/wetter/feuchte.html
// You need to include the math.h library

float temperature = 20.0; // Set to current temperature in *C (>= 0).
float humidity = 50.0; // Set to current % of relative humidity.

float a = 7.5; // For temperatures >= 0 *C.
float b = 237.3; // For temperatures >= 0 *C.

float sdd = 6.1078 * pow(10, (a * temperature) / (b + temperature));
float dd = humidity / 100 * sdd;
float v = log10(dd / 6.1078);

float dewpoint = b * v / (a – v);

So far the setup seems to work well, but the sensor readings regarding the temperature look a bit high (maybe influenced by the Arduino which gets warm over time … its probably better to place the sensor  away from the board, and not right on top of it).

Edit: In case you are interested, you can find the code of the project here: https://bitbucket.org/snippets/boden/xr746 (without the dewpoint computation).

Candlelight-Atmosphere with Arduino

7 Jan

Just a snipped of code that I have found for creating a candlelight-like light with a yellow LED attached to a PWM port of an Arduino (called here ledPin). You could probably add another red LED to optimize the effect, but for a first try it does not look too bad.

analogWrite(ledPin, random(120)+135);
delay(random(100));

Here is a small video of the setup in action:

A Holder for Bluetooth Camera Remote

7 Jan

I have created a holder that can be used to attach my Arduino-based camera remote to the hotshoe of the camera. The file was created in the CAD software Rhinoceros and printed on a MakerBot Replicator 1 owned by the University I work at. Its a rough first try, but the device works.

The 3d files can be downloaded here: http://www.thingiverse.com/thing:40029

How To Post To Status.net/Identi.ca From An Arduino

6 Oct

Just some brief notes on how to post status-updates to status.net from an Arduino with an ethernet shield. Status.net is an open source micro-blogging solution that is used for example by the Twitter alternative identi.ca (so it should work with identi.ca, too, but I have not tested it so far).

Posting to status.net is actually very straightforward. You just need to send a simple HTTP POST-request with your login credentials and the message you want to send (there are other optional parameters such as the source of the post or your geo-location, check the API description if you want to use those).

The message you want to send needs to be URL-encoded, which basically means that you have to exchange certain characters (!*'();:@&=+$,/?#[])with codes. For example, a whitespace becomes %20, so “This is a test” would become “This%20is%20a%20test”. Check this site to find out how to encode other characters.

Your login-credentials also need to be encoded, but this time as Base64. There are several websites that will enocode your credentials for you, check for example this site. Enter your credentials there in the form of username:password and you will get a result such as dXNlcm5hbWU6cGFzc3dvcmQ= which needs to be entered into the code. Obviously, username and password have to match an account at the server you are posting to.

If you got this, you are ready to go. Just start an Ethernet connection with your Arduino (using the Ethnernet library) to the IP address of your status.net server. You can find out how to use EthernetClient with Arduino here.

If the connection was initialized, perform the following HTTP request that is based on the examples described above:

client.println("POST /api/statuses/update.xml?status=This%20is%20a%20test&source=Arduino HTTP/1.0");
client.println("Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=");
client.println();

The first line defines the url of the statusnet api (the path may need to be adjusted to the correct url of your server), and adds the URL-encoded status message as well as the source of the post. The second line provides the basic HTTP authentification as a Base64 string. The third line sends an empty line to signal the server that the HTTP request is completed.

That should do the trick.

Update: Bluetooth Camera Remote

7 Jun

I have updated both the hardware setup of my camera remote as well as the software that is used to control the Arduino.

With regard to the hardware, I have soldered the optoisolator and capacitors to a small board. I also bought a remote cable for the Nikon D200 and connected it to my optoisolator, so that the setup can now be connected more easily to the camera.

The revised hardware part (the pins can be connected to the Arduino ports 13 and GND). Note that the setup can also be used for different brands of cameras by using a different adapter.

Here is a description of the circuit:

The simple circuit (note that the type of optoisolator given there is different to the one I used; could not change that in the software somehow).

With regard to the software, I updated my app with further modes for interval shooting and bulb (apart of the existing self timer mode). The new version of the app depends on Android 4.0 (ICS) in order to work properly, as I used the advanced number pickers that are not available in the older versions of Android.

The start screen of the App.

The interval shooting mode. You can pick the pause between the shots, as well as how many pictures you want to have taken (as the Arduino keeps track of time etc., the App can be closed after triggering the interval shooting).

I also pushed all the code to a Bitbucket repository with a small description of how to get this setup to work: https://bitbucket.org/boden/btcamremote/

A description of the initial setup can be found here: https://postapocalypticresearchinstitute.wordpress.com/2012/01/15/bluetooth-camera-remote/

Bluetooth Camera Remote

15 Jan

Recently I have been experimenting with interfacing my Ardunio Uno with my Nikon D200 DSLR. The D200 has a connector for a remote control cable that consists of 10 pins. After some research on the web I was able to find some information on how the pin layout works: http://www.doc-diy.net/photo/remote_pinout/#nikon. Basically, you have to connect the two pins  for activating the autofocus and the shutter to the ground pin in order to take a picture.

The pin layout of the remote connector

As I do not own a remote for this camera or a cable that fits into the remote connector, I used breadboard cables which fit perfectly into the pins of the connector. With these cables and an optoisolator, it was easy to connect the camera to my Arduino board.

The remote connector of the D200

Some experiments showed that activating the optoisolator for 1000 milliseconds was a good value to activate the camera for one shot (this can also be done by simply bypassing the three cables. This opens up many possibilities for triggering the camera for example with a lightbarrier (for example using an IR diode and a photodiode), or by sound sensors or other means of activation (such as a photo resistor for detecting ambient light and automatically shooting sunsets if you are too lazy to get up early).

The Arduino board (with Bluetooth Shield), connected to the optoisolator

However, as I was recently experimenting with the Amariono toolkit (http://amarino-toolkit.net/) that enables the interfacing of Arduino boards with Android devices over Bluetooth, I decided to build a remote control App that would be able to trigger my camera wirelessly: a Bluetooth Camera Remote.

The Bluetooth Camera Remote Prototype

The BTCamRemote consists of several components:

  • An Arduino Uno board with an optoisolator connected to the right remote trigger pins at the DSLR.
  • A Bluetooth Shield (I use the one from iteadstudio.com).
  • An Arduino program that depends on the Amarino Library and listens to commands that are recieved over the Amarino framework (basically consisting of a certain flag and an Integer value that sets the duration for activating the optoisolator and thus the camera).
  • An Android cellphone (I use an HTC Legend with Android 2.2) running the Amarino App (where the connection to the Arduino has to be set-up, coupling the Bluetooth devices).
  • An Android App that uses the Amarino Framework to send commands to the Ardunio board when a button is pushed (the user can also set a delay before the command is sent, so you can hide the cellphone when you want to take self portraits).

This setup is not really simple (because of the many software components), but it works and can be easily extended with further functions (for example activating other pins with further optoisolators etc.). It is also possible to use the Arduino for long term exposures, for instance when taking night shots (as far as I know, the camera can do exposures up to 30 seconds without using the manual “bulb” mode; the Arduino could control exposure times that are much longer, and it could be easily made accessible with a nice user interface on the Android phone.

The Android App “BTCamRemote”

The next steps will be to solder the circuit to a (smaller) circuit board and exchange the breadboard cables with the right camera cable. I will also try to attach the Arduino board to the hot shoe of the camera, and power the Ardunio with a battery in order to make the setup more mobile and easier to carry around. It would also be nice to learn more about how the other pins on the connector work, in order to access more camera functions with my remote.

You can download the source code as well as a signed APK of the application here (note that it depends on the Amarino App that has to be installed separately): https://bitbucket.org/boden/btcamremote/

Arduino-powered three-color lamp

31 Dec

This is a small example of interfacing Arduino with Android via bluetooth. I am using a very nice and convenient framework for this: Amarino, and basically followed one of the tutorials that are featured there to build a christmas decoration that I can control with my Android phone.

Arduino-powered three-color lamp

The setup consists of several components:

  • An Arduino Uno board with a bluetooth shield (I use the bluetooth shield from iteadstudio (v2.2))
  • A 3-color LED that is connected to the Arduino (via three PWM digital output pins)
  • An Android phone that is connected to the Arduino via bluetooth (using the Amarino framework). I used an HTC Legend running Froyo (2.2).
  • An Android App that uses the Amarino API to control the output value of the three PWM pins on the Arduino, thus enabling the user to set the color of the LED

Here is a picture of basically the same setup, but using three different LEDs instead of one 3-colored one. As you can see, the circuit is pretty simple: the LEDs are connected to three of the PWM digital output pins (9,10,11). Don’t forget to add capacitors, or you will probably burn your LEDs at some point.

Arduino-powered three-color lamp

The code that runs on the Arduino board depends on the Amarino library, that can be downloaded at http://www.amarino-toolkit.net/, and is pretty much the same that is documented in the abovementioned tutorial (with some slight changes to work with my setup). Basically, I just changed had to change the baud rate to 115200 as this is recommended for my bluetooth shield.

The App that is running on my Android phone is also the same like the one featured in the tutorial. In the current version it cannot be shared as an APK, but has to be compiled as the MAC Address of the Ardunio board that has to be controlled needs is hardcoded. So you will need the Android SDK in order to get the App installed, but then it works just fine. You also need the Amarino App to be installed on your phone, and connect it to your bluetooth shield in order to get the setup to work.