XStore
View Categories

ESP-HMI-5C-CI – USER GUIDE

4 min read

Programming #

ESP-HMI-5C-CI has a mini USB Port for serial connection with the SoC for programming. Any ESP32-supported programming IDE can be used to program the controller. Follow this Guide to programming NORVI ESP32 Based Controllers with Arduino IDE.

SoC: ESP32-S3-WROOM32
Programming Port: USB UART

The following settings for the Arduino IDE tools should be changed while programming:

BoardESP32-S3 Dev Module , version 2.0.9
USB modeHardware CDC and JTAG
USB CDC on BootDisabled
USB firmware MSC on bootDisabled
USB DFU on bootDisabled
Upload modeUART0 / Hardware CDC
Flash size16MB
PSRAMOPI PSRAM

Digital Inputs #

Wiring Digital Inputs  #

The digital inputs of ESP-HMI-5C-CI can be configured as both a Sink and Source connection. The inverse of the Digital Input polar should be supplied to the common terminal.

ESP-HMI-5C-CI Digital Input Wiring

Programming Digital Inputs  #

Reading the relevant GPIO of ESP32 gives the value of the Digital Input. When the inputs are in the OFF state the GPIO goes HIGH, and when the input is in the ON stage GPIO goes LOW. Refer to the GPIO allocation table in the Datasheet for the digital input GPIO.

#include "Wire.h"
#define SDA 19
#define SCL 20
#define PCA9538_ADDR 0x73
#define PCA9538_INPUT_REG 0x00
#define PCA9538_CONFIG_REG 0x03
#define GPIO1 0x01
#define GPIO2 0x02
#define GPIO3 0x04
#define GPIO4 0x08
#define NUM_INPUT_PINS 4

void setPinMode(uint8_t pin, uint8_t mode) {
  uint8_t config = readRegister(PCA9538_CONFIG_REG);
  if (mode == INPUT) {
     config |= pin;
   } else {
     config &= ~pin;
   }
   writeRegister(PCA9538_CONFIG_REG, config);
}

uint8_t readInput() {
   return readRegister(PCA9538_INPUT_REG);
}

uint8_t readRegister(uint8_t reg) {
  Wire.beginTransmission(PCA9538_ADDR);
  Wire.write(reg);
  Wire.endTransmission(false);
  Wire.requestFrom(PCA9538_ADDR, 1);
  return Wire.read();
}

void writeRegister(uint8_t reg, uint8_t value) {
  Wire.beginTransmission(PCA9538_ADDR);
  Wire.write(reg);
  Wire.write(value);
  Wire.endTransmission();
}

void setup() {
  Serial.begin(9600);
  Wire.begin(SDA, SCL);
  setPinMode(GPIO1, INPUT);
  setPinMode(GPIO2, INPUT);
  setPinMode(GPIO3, INPUT);
  setPinMode(GPIO4, INPUT);
}

void loop() {
  uint8_t input = readInput();
  bool inputValues[NUM_INPUT_PINS];
  for (int i = 0; i < NUM_INPUT_PINS; i++) {
     inputValues[i] = bitRead(input, i);
     Serial.print( inputValues[i]);
  }
}

Transistor Output #

Wiring Transistor Outputs #

ESP-HMI-5C-CI Transistor Output Wiring

Programming Transistor Outputs  #

#include "Wire.h"
#define SDA 19
#define SCL 20
#define PCA9538_ADDR 0x73
#define PCA9538_INPUT_REG 0x00
#define PCA9538_OUTPUT_REG 0x01
#define PCA9538_POLARITY_REG 0x02
#define PCA9538_CONFIG_REG 0x03
#define GPIO5 0x10
#define NUM_OUTPUT_PINS 4

void setPinMode(uint8_t pin, uint8_t mode) {
  uint8_t config = readRegister(PCA9538_CONFIG_REG);
  if (mode == INPUT) {
     config |= pin;
  } 
  else {
     config &= ~pin;
  }
  writeRegister(PCA9538_CONFIG_REG, config);
}

void writeOutput(uint8_t pin, uint8_t value) {
  uint8_t output = readRegister(PCA9538_OUTPUT_REG);
  if (value == LOW) {
     output &= ~pin;
  } 
  else {
    output |= pin;
  }
  writeRegister(PCA9538_OUTPUT_REG, output);
}

uint8_t readInput() {
  return readRegister(PCA9538_INPUT_REG);
}

uint8_t readRegister(uint8_t reg) {
  Wire.beginTransmission(PCA9538_ADDR);
  Wire.write(reg);
  Wire.endTransmission(false);
  Wire.requestFrom(PCA9538_ADDR, 1);
  return Wire.read();
}

void writeRegister(uint8_t reg, uint8_t value) {
  Wire.beginTransmission(PCA9538_ADDR);
  Wire.write(reg);
  Wire.write(value);
  Wire.endTransmission();
}

void setup() {
  Wire.begin(SDA, SCL);
  setPinMode(GPIO5, OUTPUT);
}

void loop() {
  writeOutput(GPIO5, 0);
  delay(300);
  writeOutput(GPIO5, 1);
  delay(300);
}

4 – 20 Analog Input #

Wiring Analog Inputs #

Reading the relevant I2C address of the ADC gives the value of the Analog Input.

ESP-HMI-5C-CI Analog Input Wiring

Reading Analog Input #

Reading the relevant I2C address of the ADC gives the value of the Analog Input.

Programming Analog Inputs  #

#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads2;
#include "Wire.h"
#define SDA 19
#define SCL 20

void setup() {
  Serial.begin(9600);
  Wire.begin(SDA, SCL);
  if (!ads2.begin(0x49)) {
    Serial.println("Failed to initialize ADS 1 .");
  }
  ads2.setGain(GAIN_ONE);
}

void loop() {
  int adc0=0,adc1=0,adc2=0,adc3=0;
  adc0 = ads2.readADC_SingleEnded(0);
  adc1 = ads2.readADC_SingleEnded(1);
  adc2 = ads2.readADC_SingleEnded(2);
  adc3 = ads2.readADC_SingleEnded(3);
  Serial.print("AIN1: "); 
  Serial.print(adc0); 
  Serial.println(" ");
  Serial.print("AIN2: "); 
  Serial.print(adc1); 
  Serial.println(" ");
  Serial.print("AIN3: "); 
  Serial.print(adc2); 
  Serial.println(" ");
  Serial.print("AIN4: "); 
  Serial.print(adc3); 
  Serial.println(" ");
  Serial.println("-----------------------------------------------------------");
}

RS-485 Communication #

RS 485 Wiring #

DriverSP490CN-L
UART RXGPIO48
UART TXGPIO3
GPIO Connections of RS-485

NROVI ESP32 HMI has a 4-wire RS485 connection. So it has terminals A, B, Y, and Z. Connect Y to A and Z to B.

Programming RS-485 #

ESP-HMI series RS-485 connection uses a full-duplex mode of SP490CN-L transmitter with UART
Communication.

#define RXD 48
#define TXD 2
#include "Wire.h"
#define SDA 19
#define SCL 20
void setup() {
  Serial.begin(9600);
  Serial1.begin(9600, SERIAL_8N1, RXD, TXD);
  Wire.begin(SDA, SCL);
}
void loop() {
  Serial1.println("RS485 01 SUCCESS");
  while (Serial1.available()) {
  char c = Serial1.read();
  Serial.write(c);
  }
}

Micro SD Card Support #

SD CARD CSGPIO46
MISOGPIO19
MOSIGPIO12
SCLKGPIO13

Programming SD Card #

#include "SD.h"
#include <SPI.h>
#define MOSI 13
#define MISO 11
#define SCLK 12
#define CS 10
#include "Wire.h"
#define SDA 19
#define SCL 20
File myFile;
void setup() {
  Serial.begin(9600);
  Wire.begin(SDA, SCL);
  if (!SD.begin(CS)) {
    Serial.println(F("SD CARD FAILED, OR NOT PRESENT!"));
    while (1); // stop the program
  }
  Serial.println(F("SD CARD INITIALIZED."));
  if (!SD.exists("esp32.txt")) {
    Serial.println(F("esp32.txt doesn't exist. Creating esp32.txt file..."));
    // create a new file by opening a new file and immediately close it
    myFile = SD.open("esp32.txt", FILE_WRITE);
    myFile.close();
  }
  if (SD.exists("esp32.txt"))
    Serial.println(F("esp32.txt exists on SD Card."));
  else
    Serial.println(F("esp32.txt doesn't exist on SD Card."));
  }
void loop() {
}

Internal RTC #

RTC ChipDS3231
Backup Battery TypeCR2032
InterfaceI2C
I2C Address0x68
SCL PinGPIO19
SDA PinGPIO20
GPIO Connections of RTC

Programming RTC #

#include <Wire.h>
#include "RTClib.h"
#define SDA 19
#define SCL 20
RTC_DS3231 rtc;
void setup() {
   Wire.begin(SDA, SCL);
  Serial.begin(9600);
  rtc.begin();
}
void loop() {
  DateTime now = rtc.now();
  Serial.print(now.year());
  Serial.print("-");
  Serial.print(now.month());
  Serial.print("-");
  Serial.print(now.day());
  Serial.print(" ");
  Serial.print(now.hour());
  Serial.print(":");
  Serial.print(now.minute());
  Serial.print(":");
  Serial.print(now.second());
  Serial.println();
  delay(1000);
}

ETHERNET, USB, and Reset #

ETHERNET, USB, and Reset

TFT LED Display #

Programming TFT LED Display #

Display driverER-TFT050-3
CommunicationI2C
Resolution800×480
TFT Display Specification

Refer to the GPIO allocation table in the Datasheet for the I2C GPIO of the LED Display.

Getting Started with NORVI ESP32 HMI

LVGL EXAMPLE GUIDE FOR NORVI ESP32 HMI

SQUARELINE STUDIOS FOR NORVI HMI GUI DESIGN

NORVI ESP32 HMI DISPLAY TOUCH CALIBRATION