A hardware ZABBIX Agent made with Arduino Mega

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:

Electronic Diagram:

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

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)'

//*****************************************************************************************
//* 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)

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

sensor_local.tar.gz (4.8 KB)

Thank you guys for all the useful info!
With one DHT22 it works like a charm!

Now I encounter an issue when trying to use multiple DHT22's.

For some reason it only shows a maximum of 2 inputs in zabbix at the same time, sometimes it switches between the four(2x humidity measurement and 2x temperature measurement).

Can someone please tell me what I'm doing wrong?

In the picture attached there is some interruptions that are just me reuploading a different script trying to figure out what's wrong

//* Purpose : Zabbix Sensor Agent - Environmental Monitoring Solution *
//* Author : Evgeny Levkov *
//* Adapted to basics : Schotte Vincent *
//* DHT22 implementation to Arduino 1.0 : Carlos Eduardo de Siqueira *
//* Credits: *

//-----------------INCLUDES--------------------
#include "DHT22.h"
// Only used for sprintf
#include <stdio.h>

// Data wire is plugged into port 7 on the Arduino
// Connect a 4.7K resistor between VCC and the data pin (strong pullup)
#define DHT22_1_PIN 7
#define DHT22_2_PIN 8

// Setup a DHT22 instance
DHT22 dht(DHT22_1_PIN);
DHT22 dht2(DHT22_2_PIN);

#include <SPI.h>
#include <Ethernet.h>
#define MAX_CMD_LENGTH 25
//--------------------------------------------
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0x5B };

IPAddress ip(10, 0, 30, 15);
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(void)
{
// start serial port
//Serial.begin(9600);
//Serial.println("DHT22 Library Demo");
Ethernet.begin(mac, ip, subnet);
server.begin();
}

void loop(void)
{
//--------------------------------------------
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

DHT22_ERROR_t errorCode;

// The sensor can only be read from every 1-2s, and requires a minimum
// 2s warm-up after power-on.
//delay(2000);
//counter = counter + 1;

delay(2000);
errorCode = dht.readData();

if (errorCode == DHT_ERROR_NONE){
if (cmd.equals("humid")) {
server.print(dht.getHumidity());
client.stop();
} else
if (cmd.equals("temp")) {
server.print(dht.getTemperatureC());
client.stop();
}

delay(2000);
errorCode = dht2.readData();

if (errorCode == DHT_ERROR_NONE){
if (cmd.equals("humid2")) {
server.print(dht2.getHumidity());
client.stop();
} else
if (cmd.equals("temp2")) {
server.print(dht2.getTemperatureC());
client.stop();
}
}
cmd = "";

}
}