Pages

Monday, 17 June 2019

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.



Wednesday, 12 December 2018

RDL 4-20ma module with Raspberry pi

RDL 4-20ma module with Raspberry pi

Step1: Initially do all I2C settings in raspberry pi and check address where module is connected
Command: I2cdetect –y 1
By default ADS115 is detected in address48
Step2: Install Adafruit ads1115 library in raspberry pi
Commands:
1.     sudo apt-get install build-essential python-dev python-smbus git
2.     cd ~
4.     cd Adafruit_Python_ADS1x15
5.     sudo python setup.py install

Step3: Next installing python packages for asd1115
Commands:
1.     sudo apt-get install build-essential python-dev python-smbus python-pip
2.     sudo pip install adafruit-ads1x15

Step4: Executing simple example program
1.     cd ~/Adafruit_Python_ADS1x15/examples
2.     nano simpletest.py   // This program reads vales from all the channels
3.     sudo python simpletest.py  // this command runs the code

We can observe that raspberry pi reading values from each channel
Now connecting potentiometer to one of the channel and reading values