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
}

No comments:

Post a Comment