Posts

Showing posts with the label serial communicaiton

Delta PLC Read/Write internal relay M in C#

Image
Delta PLC provides Modbus communication library DMT, which can be used in C# ​​to communicate with Delta PLC over RS485 (Modbus). First of all to use DMT with your application following functions should be imported from kernel32.dll and DMT.dll: using System.Reflection; [DllImport( "kernel32.dll" , CharSet = CharSet.Auto)] static extern IntPtr LoadLibrary ( string dllPath ) ; [DllImport( "kernel32.dll" , CharSet = CharSet.Auto)] static extern bool FreeLibrary ( IntPtr hDll ) ; // Serial Communication [DllImport( "DMT.dll" , CharSet = CharSet.Auto)] static extern int OpenModbusSerial ( int conn_num, int baud_rate, int data_len, char parity, int stop_bits, int modbus_mode ) ; [DllImport( "DMT.dll" , CharSet = CharSet.Auto)] static extern void CloseSerial ( int conn_num ) ; // MODBUS Address Calculation [DllImport( "DMT.dll" , CharSet = CharSet.Auto)] static extern int DevToAddrW ( string seri...

Arduino Wifi Setup

Image
A IoT device programmed with Arduino need connect to WiFi at start of device to use internet for data transfer etc. First of all we need to include header file “WiFiClient” to our sketch. # include <WiFiClient.h> With code below we will let user enter WiFi credentials over serial communication. we should add this code to our setup() part of our Arduino sketch. Serial . write ( "Please enter name of your wifi network\n" ); while ( Serial . available () == 0 ){}; String Uid= Serial . readStringUntil ( '\n' ); Serial . write ( "Please enter password of your wifi network\n" ); while ( Serial . available () == 0 ){}; String pass= Serial . readStringUntil ( '\n' ); If you want give user a tool to setup WiFi over serial you can download a free serial communication tool “Vengito Serial Tool”. With this tool user can connect IoT device easily and enter WiFi credentials. Download "Vengito Serial Tool"   For more software tools   Af...