Pages: [1]   Go Down
Author Topic: A hardware ZABBIX Agent made with Arduino Mega  (Read 2013 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I created a stand alone, hardware ZABBIX (Monitoring System) Agent (running Zabbix Agent-like firmware directly on micro-controller) using Arduino Mega 2560 Board + Ethernet Shield (Wiznet W5100). This device equipped with DHT22 temperature-humidity sensor.

Current (ZSA1-E model) Features:

1. Measures temperature and humidity using calibrated digital sensor
2. Direct monitoring with Zabbix Server (behave like Zabbix agent in passive mode)
3. Can support PoE 802.3 (need special Ethernet Shield with PoE support)
4. Cheap: 50~60$ for all parts price (based on Alibaba and Sparkfun prices, shipping included)
5. Can be easy assembled (minimal soldering and enclosure modification)
6. Web based network setting setup (save network settings in EEPROM)

It's firmware and design will be free and open source. Also Wi-Fi version (with the same form factor) and support for additional sensors (dust, motion, light, Co2..etc) will be implemented in near future.

Pictures and Screenshots:








Source code:
https://github.com/levkov/sensor.im/blob/master/ZSA1-E/ZSA1E.ino

Electronic Diagram:
https://github.com/levkov/sensor.im/wiki/Electronic-Diagram
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks  to Evengy Levkov,

I made some modifications in the code ,  made it more basics , this was tested with arduino uno and
5100 ethernet shield.

here the source :

//*****************************************************************************************
//* Purpose : Zabbix Sensor Agent - Environmental Monitoring Solution *
//* Author : Evgeny Levkov *
//* Adapted to basics : Schotte Vincent *
//* Credits: *

//-----------------INCLUDES--------------------
#include <SPI.h>
#include <Ethernet.h>


//--------------------------------------------
#define MAX_CMD_LENGTH 25

//--------------------------------------------
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0x5B };

IPAddress ip(192, 168, 1, 93);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

EthernetServer server = EthernetServer(10050); //Zabbix Agent port //Zabbix agent port

EthernetClient client;

boolean connected = false;
//--------------------------------------------

//--------------------------------------------
String cmd; //FOR ZABBIX COMMAND
int led = 2; //LED PORT TO BLINK AFTER RECIEVING ZABBIX COMMAND
int counter = 1;  // For testing
//--------------------------------------------


void setup()
{
     Ethernet.begin(mac, ip, gateway, subnet); 
     server.begin();
     pinMode(led, OUTPUT);
     digitalWrite(led, LOW);
 
}

void loop()
{
//--------------------------------------------
  client = server.available();
  if (client == true) {
    if (!connected) {
      client.flush();
      connected = true;
    }
    if (client.available() > 0) {
      readTelnetCommand(client.read());
          }
    }
}
//--------------------------------------------


void readTelnetCommand(char c) {

  if(cmd.length() == MAX_CMD_LENGTH) {
    cmd = "";
  }
  cmd += c;
  if(c == '\n') {
    if(cmd.length() > 2) {
      // remove \r and \n from the string
      cmd = cmd.substring(0,cmd.length() - 1);
      parseCommand();
    }
  }
}
//--------------------------------------------
void parseCommand() { //Commands recieved by agent on port 10050 parsing

   counter = counter + 1;


  // AGENT ping
  if(cmd.equals("ping")) {
      server.println("1");
      client.stop();
// connected = false;

 // AGENT version
   } else if(cmd.equals("version")) {
      server.println("ArduinZabbixVini.1.0");
      client.stop();
// connected = false;

     
// AGENT sensor1
} else if(cmd.equals("sensor1")) {
      float h = 99;
      server.println(h);
      client.stop();

// AGENT sensor2
} else if(cmd.equals("sensor2")) {
      float t = 20;
      server.println(t );
      client.stop();
     
}     
// AGENT counter
 else if(cmd.equals("counter")) {
      float t = 20;
      server.println(counter );
      client.stop();
     
// NOT SUPPORTED
} else {
    // server.println("ZBXDZBX_NOTSUPPORTED");
    server.println(cmd);
    client.stop();
  }
  cmd = "";
}
//--------------------------------------------



In Zabbix just do the following ;

1. configure a host with ip address of the sketch  example    arduino3 with ip 192.168.1.93
2. configure you're items like following
    Host                          arduino3   
    Description                  Temperature sensor1
    Type                           zabbix agent
    Key                          sensor1           // as in the sketch
   Type of information           numeric float
   



Have fun


Logged

Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Arduinovini, I use your code and everything is fine! Thanks!

But, I include de DHT library for "real" values and get a error message:

sensor2.cpp.o: In function `setup': /usr/share/arduino/hardware/arduino/cores/arduino/IPAddress.h:33: undefined reference to `DHT::DHT(unsigned char, unsigned char, unsigned char)'

 
Code:
//*****************************************************************************************
//* Purpose : Zabbix Sensor Agent - Environmental Monitoring Solution *
//* Author : Evgeny Levkov *
//* Adapted to basics : Schotte Vincent *
//* Credits: *

//-----------------INCLUDES--------------------
#include "DHT1.h"
#include <SPI.h>
#include <Ethernet.h>
#define DHTPIN 7
#define DHTTYPE DHT22
#define MAX_CMD_LENGTH 25

DHT dht(DHTPIN, DHTTYPE);

//--------------------------------------------
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0x5B };

IPAddress ip(10, 0, 1, 3);
IPAddress gateway(10, 0, 1, 1);
IPAddress subnet(255, 255, 255, 0);
EthernetServer server = EthernetServer(10050); //Zabbix Agent port //Zabbix agent port
EthernetClient client;
boolean connected = false;

//--------------------------------------------
String cmd; //FOR ZABBIX COMMAND
//int led = 2; //LED PORT TO BLINK AFTER RECIEVING ZABBIX COMMAND
int counter = 1;  // For testing
//--------------------------------------------


void setup()
{
     Ethernet.begin(mac, ip, gateway, subnet);
     server.begin();
     //dht.begin();
     //pinMode(led, OUTPUT);
     //digitalWrite(led, LOW);
 
}

void loop()
{
//--------------------------------------------
  client = server.available();
  if (client == true) {
    if (!connected) {
      client.flush();
      connected = true;
    }
    if (client.available() > 0) {
      readTelnetCommand(client.read());
      }
    }
}
//--------------------------------------------


void readTelnetCommand(char c) {

  if(cmd.length() == MAX_CMD_LENGTH) {
    cmd = "";
  }
  cmd += c;
  if(c == '\n') {
    if(cmd.length() > 2) {
      // remove \r and \n from the string
      cmd = cmd.substring(0,cmd.length() - 1);
      parseCommand();
    }
  }
}
//--------------------------------------------
void parseCommand() { //Commands recieved by agent on port 10050 parsing

   counter = counter + 1;


  // AGENT ping
  if(cmd.equals("ping")) {
      server.println("1");
      client.stop();
// connected = false;

 // AGENT version
   } else if(cmd.equals("version")) {
      server.println("ArduinZabbixVini.1.0");
      client.stop();
// connected = false;

     
// AGENT sensor1
} else if(cmd.equals("sensor1")) {
      //float h = 68;
      float h = dht.readHumidity();
      server.println(h );
      client.stop();
      delay(2000);

// AGENT sensor2
} else if(cmd.equals("sensor2")) {
      //float t = 22;
      float t = dht.readTemperature();
      server.println(t );
      client.stop();
      delay(2000);
     
}     
// AGENT counter
 else if(cmd.equals("counter")) {
      //float t = 20;
      server.println(counter );
      client.stop();
     
// NOT SUPPORTED
} else {
    // server.println("ZBXDZBX_NOTSUPPORTED");
    server.println(cmd);
    client.stop();
  }
  cmd = "";
}

Debug message is attached.

Any help?




* debug-sensor2.log (6.27 KB - downloaded 9 times.)
Logged

Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Problem: DHT22 library is not to Arduino 1.0.
Solution: attached


* sensor_local.tar.gz (4.8 KB - downloaded 17 times.)
Logged

Pages: [1]   Go Up
Jump to: