Data logger – Step 2 – Equipment
In this second article, I will describe the material that I use at the moment and how it is configured
Here is the list of components that I currently have on my recorder :
- Two push buttons. The first allows to start or stop the recording of data. The second by long press to switch off the system.
- A green LED to indicate that the system is ready to begin a recording
- A red LED to indicate that recording is in progress
- A clock RTC DS1307 to have the correct time when the system is not connected to the Internet
- A gyroscope/accelerometer MPU6050 to measure the slope on 3 axes of the data logger
- A GPS. I made the choice to a USB GPS like the one I presented here. The cost is the same that a card and especially the GPS can be deported from the recorder which allows to fix elsewhere if necessary.
- A probe DS18B20 to record the temperature. I took this model (compared with the DHT22 probes for example) because it may as the GPS be output from the recorder through a long enough cable and it is waterproof
- Resistance between 4.7KΩ and 10KΩ for the connection of the probe on the Raspberry
- A housing 6 AA batteries
- A voltage regulator LM2596 to regulate the voltage from the batteries
- A breadboard
- Wires
Apart from the GPS to 37$, all the components are little expensive and coping well with ebay or dx.com shall be limited to the invoice unless 50$ or 60$ (without the Raspberry).
The connection here is the diagram of the recorder :
Attention, Fritzing is not all components in the list so I took to the nearest on gyro (not MPU6050). There is also a “Tip” concerning this gyro. I added a cable between Vcc and the Add entry to change your address on the i2c bus (0x 68 instead of 0 x 69) If not there is a conflict with the address of the clock.
Same thing for the DC - DC Step down. I put wires but if you have a LM2596, you have all the information to plug into this article.
It now remains to configure Pi Raspberry for his new friends !
To the 19/03/2014, There is a bug in the Raspbian that prevents the simultaneous use of the i2c bus and the 1-wire bus. To use an older version which you can download here.
- Download and install Raspbian. Take the version of 25 September 2013
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip - Update the system but without any upgrade
apt-get update
- Disable the modules in the file /etc/modprobe.d/raspi-blacklist.conf. Here are the contents of the file :
# blacklist spi and i2c by default (many users don't need them) blacklist spi-bcm2708 #blacklist i2c-bcm2708
- Enable the necessary modules. Here are the contents of the file /etc/modules :
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. # Parameters can be specified after the module name. SND-bcm2835 i2c-bcm2708 i2c - dev rtc_ds1307 w1-gpio w1-therm
- Restart the system
reboot
- Install tools for the i2c bus
apt-get install i2c-tools
You can check that your clock is well detected by position 68 and the accelerometer in the position 69 :
The 50 comes from the second possible port of my clock.
- Install and configure the clock (Replace it 0 by 1 If you have a model B revision 2)
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device hwclock r
As you are connected to the Internet, your system must be on time. Send time system to clock
hwclock -w
The command returns no information. You can check the result with the read command
hwclock -r
To sync automatically with the Raspberry boot, You must edit the file/etc/rc.local by adding the following lines before the exit 0 the end
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device sudo hwclock s
- Install the tools for GPS
apt - get install –y gpsd gpsd-clients
You can test that the GPS is connected
cgps s
Edit the file /lib/udev/GPSD.hotplug by adding the line
chmod a rw $DEVNAME
before the line
gpsdctl $ACTION $DEVNAME
- Test the Sensor DS18B20. In the directory /sys/bus/w1/devices, You must find your probe in the form of a directory whose name begins with 28-. In this directory you will have a file containing the measured temperature. It will be updated every time you go to read the contents of the file. Here is a complete example for the temperature :
- Test the accelerometer MPU6050
i2cget y 0 0x 69 0 x 75
The command should display 0 x 68
Your hardware is now ready ! Next step, use Python to save data