Raspberry Pi 2 Weatherstation

10 Jul

I got a Raspberry Pi 2 for my birthday and, as a small evening project, ported my Arduino Weatherstation project to this new platform.

IMAG0268

The setup is relatively simple: I used the Adafruit Python DHT Sensor Library to read the sensor values from the GPIO, logging the resulting values with a timestamp to a CSV file. Another python script then reads this files and creates a graph using the Matplotlib library (which can be installed easily on the RPi with sudo apt-get install python-matplotlib).

log

Both scripts are called every five minutes  by crontab, and the resulting image is displayed on a webserver (I used nginx, which is also quite easy to install).

Next steps would be to log to a database instead of a file, and implement different visualizations over different time intervals.

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.

DIY Minecraft Binary Clock

18 Jul

This is a binary clock that was built into a 3d-printed case created in Minecraft. It shows the current time in a binary coded decimal format. The code and idea are based on a tutorial by Daniel Andrade.

The model was exported with the free tool Mineways and printed on a Zprinter 650 3d-printer, with a block size of 125mm^3 (so every block has an edge length of 5mm).

17:07 (i.e. 5:07 PM)

After printing, LEDs were glued into the case after filing the openings a bit wider. Then, the LEDs were soldered to form a 4×4 LED matrix, and the matrix was connected to an Arduino board. Two pushbuttons were added for setting the clock (hours and minutes).

The circuit of the binary clock (not very accurate, I know, but you get the idea…).

More images can be found here: http://imgur.com/a/Nc5Rk.

The code and case can be downloaded here: https://bitbucket.org/boden/arduino-based-binary-clock-on-a-4×4-led-matrix/overview, and here: http://www.thingiverse.com/thing:28831.

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/