Data logger - step 3 -Log engine

Now here is the third step in our project’data logger on Raspberry Pi. Install tools to retrieve and store all data.

What language ?

I chose to do it in python for questions of simplicity. Certainly another language would be more efficient etc. but for me it was the easiest.

With Python I can create something which will interface easily with all components of Raspberry Pi. So to control the recorder and sensors, It is ideal. Python offers a whole range of features to manage threads. It's gonna help me ! 🙂

The engine

Instead you give either stubbornly code, either explain line by line, I told myself that a diagram could be speaking enough. You'll have three :

Here is the Raspberry boot sequence and the establishment of the recorder :


Below, How goes the beginning of a record


Finally, last diagram, that when it stops recording


I have not detailed what happens when you stop the system, It is identical to the a recording with a stop “halt” to properly turn off the Raspberry. There are also a few actions more than those above top (as the calculation of the ID of the next record) but ca rest of retail.

Add new sensors

For me the most important was to find a way to add sensors without having to change any code. Here I think I have a correct solution.

If you want to add a sensor, you create a new class that will inherit from The name of this class will be used in the area type of the configuration file. You need to define two methods :

  • Setup : It sets up in a specific way the sensor. It returns True If the configuration is going well. Otherwise it returns False and the sensor will be ignored by the recorder. Practice if you have not connected a sensor.
  • getSensorValue : the function returns what you want string, integer, BLOB

To create a new sensor, You can sample sensors GenericInt (generation of random integer) and GenericStr (generation of random string)

The source code

For those who now want to put the hands in the machine, Here is the link to the source code :

Remember to change the directory (for the moment /root) in the initialization script /etc/init.d/dataLogger If move you the sources.

If you have ideas or if you develop new modules, n’hésitez pas à les partager pour venir enrichir le projet 🙂

Have fun !

You may also like...