Introduction to Norvi Agent One Devices - ESP32 WROVER-B Chip Integrated Industrial Nodes for IoT Applications

by NORVI Controllers in Circuits > Microcontrollers

969 Views, 2 Favorites, 0 Comments

Introduction to Norvi Agent One Devices - ESP32 WROVER-B Chip Integrated Industrial Nodes for IoT Applications

IMG_20210203_092903.jpg
IMG_20210203_093010.jpg

Norvi Agent One devices are ESP32 WROVER-B embedded industrial nodes. These devices come with many features with distinctive models that make them suitable for automation and IoT applications. ESP32 WROVER-B chip comes with additional external ram (PSRAM), which gives sufficient memory for user applications with huge files like JSON or HTML, etc.

In this instructable, we'll be looking at Norvi Agent One AT01-BM1 model. The features of this model are,

  • 3 Digital Inputs, 24VDC
  • 3 Analog Inputs, 0-10 V
  • WiFi & Bluetooth
  • RS 485 Communication
  • RGB LED indicator for multiple status recognition

In addition to that, the following features are provided with the device as per the user requirement.

  • micro SD card support
  • DS3231 RTC with battery backup
  • SMA external antenna for WIFI
  • GSM Module
  • Lora Module

Now, we'll see how to read three different voltage levels at the analog input and utilize the RGB led to indicate those voltage levels using 3 different colors.

So what do you need to get started?

  • Norvi Agent One AT01-BM1 device Check more about the device
  • 0-10V DC power supply
  • Potentiometer
  • Wires for connection
  • USB cable (Type A to Type B mini)
  • PC/Laptop

Installing ESP32 Board in Arduino IDE and Booting the Device

1.PNG
IMG_20210203_095004.jpg
  • Install the ESP32 Wrover board in your Arduino IDE to start programming the device as shown in the image.
  • ESP32 board must be installed under board manager, it is recommended to use the latest version of ESP32 board driver for Arduino.
  • Due to the installation of different drivers and older versions of libraries, Arduino fails to upload the program to the controller. In most cases, it is due to failure to enter the boot mode of the device. After uploading the program the device can be booted by pressing the boot hole using a pin.

Understanding More About the Analog Inputs.

Capture4.PNG
  • The device has a ADS1115 module of address 0x48 .
  • ADS1115 is a 16-bit analog to digital converter (ADC) that consists of four analog channels. Here in the device, the last three (channel 2, channel 3 and channel 4) channels of the first ADS1115 module used as analog inputs, to measure the input voltage.
  • The GPIOs, 21(SDA) and 22(SCL) of ESP32 in the device are used for I2C communication with the ADC. This ADC module is capable of measuring a maximum voltage of 4.0V. Considering this into account and to facilitate measurement of maximum 10V, the above arrangement is made inside the device using resistors, as shown in the figure.

Hence it is to be noted that the value read by the analog channels of the ADC is 2.5 times smaller than the actual analog input reading at the analog input pins A0-A2.

GPIO Pins of Digital Inputs

IMG_20210203_092830.jpg
  • GPIO pins detail of Digital Inputs are as follows,
I0=18    I1=26   I2=27
  • Here the digital inputs are normally kept on/high (digital logic state "1") by using pull-up resistors inside the device. So when the connection is made the state changes to off/low(digital logic state "0").

To know more about how to work with the digital input side - Getting started with Norvi devices

Analog Inputs and RS485 Communication

IMG_20210203_092817.jpg
  • There are 3 analog input pins starting from A0-A2 which are capable of measuring 0-10V industrial level voltage. These three inputs (A0-A2) are connected to the last 3 channels of the first ADS1115 module of address 0x48.
  • Two pins are provided for RS485 communication and the flow control can be achieved via the GPIO 32 of the ESP32 inside the device.

Programming the Device to Read 3 Different Voltage Levels and Indicating Them Using Different Colors

  • Install the Neopixel and Adafruit ADS1015 libraries in your Arduino IDE and upload the below sketch.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_ADS1015.h>
#include <Adafruit_NeoPixel.h>


#define PIN      25
#define NUMPIXELS 1
Adafruit_NeoPixel pixels (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_ADS1115 ads(0x48);
float Voltage = 0.0;
void setup(void) 
{
Wire.begin(21,22);
pixels.begin();
Serial.begin(115200); 
ads.begin();
}
void loop(void) 
{
float adc0;

adc0 = ads.readADC_SingleEnded(1);
Voltage = (adc0 * 0.1875)/1000;

Serial.print("AIN0: "); 
Serial.print(adc0);
Serial.print("\tVoltage: ");
Serial.println(Voltage, 3); 
Serial.println();
if (Voltage<=0.8 && Voltage>=0.6)
{
pixels.setBrightness(30);
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
pixels.show();
}
else if (Voltage<=1.0 && Voltage>=0.8)
{
pixels.setBrightness(30);
pixels.setPixelColor(0, pixels.Color(0, 255, 0));
pixels.show();
}
else if (Voltage<=1.2 && Voltage>=1.0)
{
pixels.setBrightness(30);
pixels.setPixelColor(0, pixels.Color(0, 0, 255));
pixels.show();
}
else
{
pixels.clear();
pixels.show();
}
delay(1000);
}<br>

Understanding the Code

  • The necessary libraries are imported to use I2C (Wire library), to use RGB LED (Adafruit_ADS1015 and Adafruit_GFX libraries) and to read the analog value by the ADC.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_ADS1015.h>
#include <Adafruit_NeoPixel.h>
  • In the below lines, the number of LEDs and the GPIO pin of ESP32 used to make the connection are defined.

#define PIN      25
#define NUMPIXELS 1         //(In our case it is only one)
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  • Then the address of ADC nodule is defined.

Adafruit_ADS1115 ads(0x48);
  • A float variable is defined to store the voltage value.

float Voltage = 0.0;
  • In the following line, you initialize I2C by setting the sda and scl GPIOs to communicate with the display.

Wire.begin(21,22);
  • Next the RGB Led is initialized.

pixels.begin();
  • Next, in setup(), we initialize the Serial Monitor at a baud rate of 115200.

Serial.begin(115200); 
  • Then the ADS1115 module is initialized to begin its operation.

ads.begin();
  • Inside the loop() function, the float variable adc0 is initialized which is used to store the output of the analog channel of the ADC module.

float adc0;
  • The below function reads the second analog channel value of the first ADC module and stores this value in “adc0” float variable.
adc0 = ads.readADC_SingleEnded(1)
  • This statement converts ADC value into voltage where 0.1875mV is the resolution of ADS1115.

Voltage = (adc0 * 0.1875)/1000;
  • The below lines prints the value of ADC and voltage on the serial monitor after every reading.

Serial.print("AIN0: "); 
Serial.print(adc0);
Serial.print("\tVoltage: ");
Serial.println(Voltage, 3); 
Serial.println();
  • Lastly, the conditions for displaying the three different colors are set. Here the voltage ranges 2-4V, 4-6V and 6-8V are selected to indicate three distinct colors.
if (Voltage<4 && Voltage>2)
{
pixels.setBrightness(30);
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
pixels.show();
}
else if (Voltage<6  && Voltage>4)
{
pixels.setBrightness(30);
pixels.setPixelColor(0, pixels.Color(0, 255, 0));
pixels.show();
}
else if (Voltage<8 && Voltage>6)
{
pixels.setBrightness(30);
pixels.setPixelColor(0, pixels.Color(0, 0, 255));
pixels.show();
}
else
{
pixels.clear();
pixels.show();
}

Circuit Connection and Verification

3.PNG
  • Complete the circuit as shown in the diagram. Then upload the sketch and boot the device.

**Norvi Agent One AT01-BM1 is capable of reading 0-10V industrial level voltages.

  • By varying the potentiometer value, you can see for the chosen voltage range, the respective color is being displayed inside the device.

To check more about the Norvi line up - www.norvi.lk