Pages

Monday, 17 June 2019

Accessing VFD through MODBUS and updating clouds Via MQTT GPRS

Accessing VFD through MODBUS and updating clouds  Via MQTT GPRS
Accessing VFD through MODBUS and updating clouds Via MQTT GPRS

   Functional Block Diagram


   Step 1 Make the connection as shown in the above diagram

   Step 2 copy the code and change the required parameter.


  Step 3 Execute code  
  Step 4  watch the expected result at Cloud MQTT server.



     Test Setup 


Accessing VFD through MODBUS and updating clouds  Via MQTT GPRS code for your reference 
#include <IndinoDI.h>  // Indino Library 
/*     Cloud initialisation      */
char data1[20];
char* host = "m16.cloudmqtt.com";
//char* host = "52.3.184.147";
char* port = "16997";
char* username = "eoszmzsz";
char* password = "at1yeUD1pERj";
char* topic = "VFD";
char *APN = "www"; //bsnl
/*    Modbus initialisation       */
uint8_t funCode = 0x04; //Read holding register
uint8_t slave_id = 1; //Set the slave id
uint16_t start_addr = 16130; //Address to read frequency of the VFD    
uint16_t len = 2; //Datatype is 32-bit Float for MFR 2810
uint16_t data[2] = {0};
uint8_t freq_hex_bytes[4] = {0};
float frequency = 0;
uint32_t VALUE;
void setup()
{
Serial.begin(9600);
Serial3.begin(9600);
Indino_Modbus_Master_Init(); //Modbus initialisation
delay(2000);
pinMode(41, OUTPUT);
delay(2000);
Serial.println("Start..");
power_on(APN); //Switch on the modem
delay(1000);
}
/* Main Loop */
void loop()
{
start_addr=start_addr-1;
Indino_Modbus_Master_Read_Raw(funCode, slave_id, start_addr, len, data); //Modbus reading
Serial.print(data[0]);
Serial.println(" Hz");
sprintf(data1,"Frequency=%iHz",data[0]);
Indino_GPRS_Upload_MQTT(data1, APN, host, port, username, password, topic); //Uploading data to cloud using MQTT
delay(3000); // Delay
}

Modbus Energy Meter Reading using GPRS MQTT Protocol - Indino 4.0


Energy meters with an integrated Serial RS485 Modbus interface allow direct reading of all relevant data, such as energy , current and voltage , frequency and form factor for every phase and active and reactive power for every phase and for the three phases


step 1- Select the required parameter and register address of the modbus energy Meter as shown in the below given image .


Step 2- Copy the code and change the required parameter 

Step 3 - Execute the code 

Step 4 Watch the expected result at cloud MQQT Server








Test Setup

/*
* The example file shows making a phone call
*  
* Pin Connection :  
*  
*/
#include <IndinoDI.h>  
String data1;
/*    Cloud initialisation         */
char* host = "m16.cloudmqtt.com";
//char* host = "52.3.184.147";
char* port = "16997";
char* username = "eoszmzsz";
char* password = "at1yeUD1pERj";
char* topic = "meter";
char *APN = "INTERNET"; //Vodafone
uint8_t funCode = 0x04; //Read holding register
uint8_t slave_id = 1;
uint16_t start_addr = 3854; //Address to read frequency=3854
uint16_t start_addr1 = 3850; //Line to Neutral Voltage=3850
uint16_t start_addr2 = 3846; //Avg PF=3846
uint16_t len = 2; //Datatype is 32-bit Float for MFR 2810
uint16_t data[2] = {0};
uint8_t freq_hex_bytes[4] = {0};
float frequency = 0;
float voltage = 0;
float power = 0;
uint32_t VALUE;
char data2[80];
void setup()
{
Serial.begin(9600);
Serial3.begin(9600);
Indino_Modbus_Master_Init();
delay(2000);
pinMode(41, OUTPUT);
delay(2000);
Serial.println("Start..");
power_on(APN);
delay(1000);
}
void loop()
{
Indino_Modbus_Master_Read_Raw(funCode, slave_id, start_addr, len, data);
/*     place register values in byte array, lsb in position 0      */
freq_hex_bytes[3] = (data[1] & 0xFF00) >> 8;  
freq_hex_bytes[2] = (data[1] & 0x00FF);
freq_hex_bytes[1] = (data[0] & 0xFF00) >> 8;  
freq_hex_bytes[0] = (data[0] & 0x00FF);
/*    Convert to Float         */
memcpy(&frequency, freq_hex_bytes , 4);
Serial.print("Frequency =");
Serial.print(frequency,2);
Serial.println(" Hz");
delay(300);
Indino_Modbus_Master_Read_Raw(funCode, slave_id, start_addr1, len, data);
/*    place register values in byte array, lsb in position 0        */
freq_hex_bytes[3] = (data[1] & 0xFF00) >> 8;  
freq_hex_bytes[2] = (data[1] & 0x00FF);
freq_hex_bytes[1] = (data[0] & 0xFF00) >> 8;  
freq_hex_bytes[0] = (data[0] & 0x00FF);
/*      Convert to Float          */
memcpy(&voltage, freq_hex_bytes , 4);
Serial.print("Line to Neutral Voltage =");
Serial.print(voltage,2);
Serial.println(" volts");
delay(300);
Indino_Modbus_Master_Read_Raw(funCode, slave_id, start_addr2, len, data);
/*     place register values in byte array, lsb in position 0      */
freq_hex_bytes[3] = (data[1] & 0xFF00) >> 8;  
freq_hex_bytes[2] = (data[1] & 0x00FF);
freq_hex_bytes[1] = (data[0] & 0xFF00) >> 8;  
freq_hex_bytes[0] = (data[0] & 0x00FF);
/*     Convert to Float         */
memcpy(&power, freq_hex_bytes , 4);
Serial.print("Power factor =");
Serial.print(power,2);
Serial.println(" PF");
data1 ="Frequency=";
data1 +=frequency;
data1 +=",Voltage=";
data1 +=voltage;
data1 +=",Powerfactor=";
data1 +=power;
for(int i=0;i<data1.length();i++)
data2[i]=data1[i];
Serial.println(data2);
Indino_GPRS_Upload_MQTT(data2, APN, host, port, username, password, topic);
delay(3000);
}

For more details visit www.rdltech.in

Friday, 11 January 2019

ESP32-SEVEN SEGMENT DISPLAYS

ESP32-SEVEN SEGMENT DISPLAYS

Aim:
Interfacing ESP32-Microcontroller with seven segment display, to display the numbers.
Hardware Required:
ESP32-Microcontroller development board
Connections:


Pin Mapping:
A
I04
B
I012
C
I033
D
I032
E
I025
F
I026
DP
I05
D1
GND

Program:
void setup()
{
  // define pin modes
  
pinMode(4,OUTPUT); //Set pin D2-D9 as input pins
pinMode(12,OUTPUT);
pinMode(33,OUTPUT);
pinMode(32,OUTPUT);
pinMode(25,OUTPUT);
pinMode(26,OUTPUT);
pinMode(27,OUTPUT);
pinMode(5,OUTPUT);
 
}
 
void loop() 
{
  // print 0
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,LOW);
   digitalWrite(27,HIGH);
   digitalWrite(5,LOW);
   delay(1000);
  }
 // print 1
  
  {
   digitalWrite(4,HIGH);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,HIGH);
   digitalWrite(25,HIGH);
   digitalWrite(26,HIGH);
   digitalWrite(27,HIGH);
   digitalWrite(5,LOW);
   delay(1000);
  }
 // print 2
{
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,HIGH);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,HIGH);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
 
  // print 3
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,HIGH);
   digitalWrite(26,HIGH);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW); 
   delay(1000);
  }
  // print 4
  {
   digitalWrite(4,HIGH);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,HIGH);
   digitalWrite(25,HIGH);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 5
  {
   digitalWrite(4,LOW);
   digitalWrite(12,HIGH);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,HIGH);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);  
   delay(1000);
  }
  // print 6
  {
   digitalWrite(4,LOW);
   digitalWrite(12,HIGH);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 7
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,HIGH);
   digitalWrite(25,HIGH);
   digitalWrite(26,HIGH);
   digitalWrite(27,HIGH);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 8
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,LOW);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW);
   delay(1000);
  }
  // print 9
  {
   digitalWrite(4,LOW);
   digitalWrite(12,LOW);
   digitalWrite(33,LOW);
   digitalWrite(32,LOW);
   digitalWrite(25,HIGH);
   digitalWrite(26,LOW);
   digitalWrite(27,LOW);
   digitalWrite(5,LOW); 
   delay(1000);
  } 
}




ESP32-CONTROLLING LED USING SWITCH

ESP32-CONTROLLING LED USING SWITCH


Aim:
Controlling LED using a Switch
Objective:
Understanding the working of switch. Turn ON the led when switch is pressed and Turn off when it is released
Connections:
Pin Mapping:
Switch
I012
LED
I04

Program:
void setup() {
pinMode(4, OUTPUT);//Initialize the output pin 
pinMode(12, INPUT);//Switch is connected to pin 12
Serial.begin(9600);
}
 
// the loop function runs over and over again forever
void loop() { 
if (digitalRead(12)==HIGH)
{
digitalWrite(4, HIGH);// Turn the LED on
delay(1000);   // Wait for a second.
digitalWrite(4, LOW);  // Turn OFF LED
delay(1000); // Wait for a second.
}
}

ESP32- BLINKING AN LED

ESP32- BLINKING AN LED


Aim:
 Turn ON and OFF an LED after Particular delay
Objective:
To learn how to connect LED to digital pins of an ESP32 Microcontroller and program to blink an LED
Connections:
Pin Mapping:

LED
I04
Program:
void setup() {
pinMode(4, OUTPUT);//Initialize the output pin
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(4, HIGH);// Turn the LED on
 delay(1000);   // Wait for a second.

digitalWrite(4, LOW);  // Turn OFF LED
delay(1000); // Wait for a second.
}

Sunday, 6 January 2019

ESP32 INSTALLATION IN ARDUINO

ESP32 INSTALLATION IN ARDUINO

Step1:
Open the preferences window from the Arduino IDE. Go to File> Preferences

2.       Step2: Enter https://dl.espressif.com/dl/package_esp32_index.json into   the  “Additional  Board  Manager URLs”. Then, click the “OK” button

3.       Open boards manager. Go to Tools > Board > Boards Manager
4.       Select ESP32 by Espressif Systems and install it.