Raspberry Pi is a credit-card-sized single-board computer. Because it is low-cost and easy to equip with various types of sensors, using Raspberry Pi as a cloud data logger is one of its ideal use cases.

You can import sensor data from Raspberry Pi into Treasure Data.

Install Raspbian

Raspbian is a free operating system based on Debian, optimized for the Raspberry Pi. Install Raspbian on your Raspberry Pi by following the instructions in the blog post below:

Install Treasure Agent (Fluentd)

Next, we’ll install Treasure Agent (Fluentd) on Raspbian. Raspbian bundles Ruby 1.9.3 by default, but we need the extra development packages.

$ sudo aptitude install ruby-dev

We’ll now install Treasure Agent (Fluentd) and the necessary plugins.

$ sudo gem install fluentd
$ sudo fluent-gem install fluent-plugin-td

Or, you can use fluent-bit instead of fluentd. See the detail in the following doc.

Configure and Launch Treasure Agent

Sign into your Treasure Data account. You can get your account’s API key from the users page. If you don’t have an account, schedule a free trial to get started.

Prepare the fluent.conf file with the following information, including your API key.

<match td.*.*>
  type tdlog

  buffer_type file
  buffer_path /home/pi/td
  type http
  port 8888
  type forward

Finally, launch Treasure Agent (Fluentd) via your terminal.

$ fluentd -c fluent.conf

Upload Test

To test the configuration, just post a JSON message to Treasure Agent via HTTP.

$ curl -X POST -d 'json={"sensor1":3123.13,"sensor2":321.3}' \

If you're using Python, you can use python logger library.

Now, access the databases page to confirm that your data has been uploaded to the cloud properly.

You can now issue queries against the imported data.

For example, these queries calculate the average sensor1 value and the sum of sensor2 values.

SELECT AVG(sensor1) FROM raspberrypi;
SELECT SUM(sensor2) FROM raspberrypi;


Raspberry Pi is an ideal platform for prototyping data logger hardware. By combining Raspberry Pi and Treasure Data, we can easily analyze the physical world in the cloud.

  • No labels