Search

Tono Riesco

Category

Raspberry Pi

Analog Sensors Reading with Raspberry Pi and Zabbix Supervisor

This article is based in this very good one

I added some comments, examples, circuits and Zabbix configuration.

The main goal is having a common interface to read analog values and generate graphs, alarms, actions etc. with Zabbix.

Continue reading “Analog Sensors Reading with Raspberry Pi and Zabbix Supervisor”

Advertisements

Monitoring Home

Introduction

The requirements for my monitoring projects are simple:

  • Want to be mostly cabling free.

One of the things than makes a good monitoring system at home is don’t having to make new cabling all around the house each time you put a new sensor or want to check a new temperature room.

  • Want to use open-source products.

There are several reasons for that. Despite what most people think that we use open-source because is free (like free beer ;-)) in my case is not true. The fact of using open-source products is because the support, the driver availability, the modifications to adapt the product, etc. etc. Several times I did donations to products so at the end, has never be free as a free beer.

Requirements

  • Cheap sensors for temperature, humidity, electrical power consumption, digital status, barometric pressure,
  • Long distances > 20 meters
  • Cheap controllers.
  • Easy deployment
  • Mobile, distance and independent data display
  • Database for making complex requests if needed

Hardware

  • Sensors: DS18B20 with isolation for the heating system, normal one for standard temperatures, DHT21 for temperature and hygrometers, counters and opto-couplers  for electrical consumption, BMP085 Barometric Pressure,
  • Arduino Models: Uno, Mega, Mini Pro, Yún
  • Raspberry Pi: Version 2, 512 Model
  • Servers: Mac mini Server, Standard Desktop PC, HP Proliant.
  • Electronics: 433 Mhz radio transmitters, relays, resistors, diodes, etc.
  • Screens and displays: TV, Standard screens, 1.8″ TFT LCD Displays, Car Cameras

Software

  • ARM Compilers for Arduino, Raspberry Pi.
  • Raspbian
  • Debian with LAMP
  • Mac OS X with LAMP
  • MySQL, SQLite, RRDtools Databases

In the next posts I’ll explain all the projects.

Raspberry Pi and Oracle

Long time working with the Raspberry Pi and having a lot of interfaces I didn’t find anywhere how to make requested to the Oracle DB from the OS Raspbian.

Here are my experiences:

Install Raspbian as usual. There is thousand of how to all around.

Install Java SDK (I’m not a fan of Java… But I didn’t find another system.)  The OCI libraries from Oracle doesn’t work on ARM architectures. Now Java SDK is in the raspbian repositories.

I’ve been using Instant Client from Oracle on Debian host without problems but there are not drivers for Raspbian yet.

I’m using always root to avoid using sudo for all commands!

[bash]root@host:~# apt-get install oracle-java7-jdk[/bash]

Get the ojdbc7 driver from Oracle

Test that java is working well with:

[bash]root@host:~# java -version
java version “1.7.0_40”
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)[/bash]

Write a file Conn.java with the following code:


import java.sql.*;
class Conn {
public static void main (String[] args) throws Exception
{
Class.forName ("oracle.jdbc.OracleDriver");

Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@//ip_or_dns_name_of_oracle_server:port_server/SID_Database", "login_database", "password_database");
                // @//machineName:port/SID,   userid,  password
try {
  Statement stmt = conn.createStatement();
  try {
    ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
    try {
      while (rset.next())
        System.out.println (rset.getString(1));   // Print colon 1
    }
    finally {
      try { rset.close(); } catch (Exception ignore) {}
    }
  }
  finally {
    try { stmt.close(); } catch (Exception ignore) {}
    }
  }
  finally {
    try { conn.close(); } catch (Exception ignore) {}
    }
  }
}

Now, you can compile with:

[bash]javac  Conn.java[/bash]

and run with:

[bash]java -cp /wherever_you_put_the_file/ojdbc7.jar:. Conn[/bash]

Create a free website or blog at WordPress.com.

Up ↑