For details about the summit and the talk see Zabbix Summit 2018 and Better dress warm - IOT meets Zabbix.
This repository shows how to build a simple IoT-Sensor based on Espressif Systems ESP32 that directly connects to a Zabbix Server or Zabbix Proxy and can measure temperature, air pressure, humidity and also the RSSI of the Wi-Fi connection. It is a very basic demo application that will not receive further updates.
It includes:
/docs
- Schematic (Wiring)./src
- Demo Application (C++ to be used with Arduino IDE or Espressif's IDF)./zabbix
- Zabbix Template (requires Zabbix 3.0+)
The demo application contains a simple Zabbix Sender library, which is compatible with the "Zabbix Sender Protocol".
To build this sensor the following components are needed:
- Microcontroller Espressif ESP32. (either as a module or as a devKit). Note: There are many vendors on the market, that sell different types of boards based on the ESP32.
- Sensor Bosch BME280. The BME280 modul itself is really tiny (2.5mm*2.5mm) and hard to solder. Better use a breakout board like the ADAfruit BME280
- 2 LEDs with Resistors: These are optional and can be used to signal the user what the sensor is doing. See the schematic in
/docs
and the code for how they are used. - PCB or Breadboard: Either build your own PCB or use a breadboard to get started.
- Micro USB cable: To flash the software, one needs to connect via a serial port to the ESP32. When using a devKit type board, then these boards have a micro USB connector that provides a serial port for the PC next to the power-supply for the ESP32 itself. Depending on the chipset used, a driver will be needed.
To build a working firmware for the ESP32, the code must be cross-compiled. This can be done in a Windows or Linux environment. Basically there are 2 options.
For beginners, the easiest is to use the Arduino IDE. This IDE is simple to configure and contains a library manager, that installs required libraries (like sensor libs) with just some clicks from the GUI. However, this IDE is not a full featured C/C++ IDE.
Download and install Arduino. Then follow the instructions to add support for the ESP32 environment. See the arduino/esp32 respository and specificially the instructions for boards manager
If you are more experienced and prefer to use an IDE like Eclipse, then this requires a lot more work to setup the Espressif's IDF (IoT development Kit) and to configure the various settings in Eclipse. Also, there is no menu driven library manager, thus libraries must be installed manually.
All sources (except the external library) are located in the /src
directory. The main application file is called ZabbixIot.ino
.
Arduino uses a specific naming convention. The main file must have the same name as the project directory and must end with .ino
. So in this case that would be the following structure: ZabbixIot/ZabbixIot.ino
. To start, create a new directory ZabbixIot
in the arduino sketch directory and copy the content of the repository /src directory into it.
Note: Arduino does not allow to place .cpp
or .h
in subdirectories. This is why all those files are located in the main source directory.
Using Eclipse with IDF or only the IDF, a file like main.c
or main.cpp
is expected.
Create a new ESP32 example project using the IDF tools and copy the content of /src
into it. Then rename ZabbixIot.ino
to main.cpp
.
Note: While the IDF is written in C, there are still a lot useful libraries out that are written in C++.
All relevant application settings are defined in settings.h
. This includes the Zabbix configuration, Wi-Fi and measuring interval.
Per default, measuring interval
is set to 60 seconds. This means the sensor will make a measurement and then go to sleep for 60 seconds.
Once the development environment is set, the application requires the following libraries:
- BME280E Sensor: Adafruit_BME280_Library.
- ArduinoJson: ArduinoJson Library
When using the Arduino IDE, simply install this libraries using the library manager.
When using Eclipse or IDF only, the setup depends on your build settings.
Setup Com-Port in Arduino IDE.
Select Compile from the menu, select flash from the menu.
To view the output of the ESP32, select "Serial Monitor" from the menu.
Setup Com-Port by issuing make menuconfig
.
Then make flash
and make monitor
to see output.
We do not provide support for this repository. However we provide custom development for hardware and software. Contact us if you need assistance in your sensor project.