Saving Date and Time using a DS1307

The arduino has no time information. First I wanted to use NTP, but one HTTP client (the one sending the sensor data to the server) is enough difficulty for this problem. A friend of mine build a board similar to this setup: .

For initializing and reading the date/time information I use the code from .

Now I have date/time information for writing the sensor data to the SD card in the future.

Receiving HTTP post using Flask

The server side of my data logger is a very simple Flask site.

First version of the code:

from flask import Flask, request, abort
app = Flask(__name__)

import datetime

def index():
    return "nothing to see here ..."

@app.route('/input/', methods=['POST', 'GET'])
def input():
    if request.headers.get('X-ApiKey') != 'SECRET_API_KEY_SET_ON_ARDUINO':
    if request.method == 'POST':
    return "OK"

def log_to_file(data):
    f = open('/tmp/arduino.logger', 'a')
    f.write(': ')