# AC Socket SKU:K031
## Description This is an upgrade of a normal AC socket outlet, which empowers the user to customize the AC outlet through RS485 series. Serial communication control can include multiple AC sockets, have them serial connected in the same RS485 main bus, can be applied to a typical industrial application scenario. Let's break it down a little bit, start with the bottom part. - The whole AC socket is consist of two parts. For people who are familiar with M5 industrial product series, would recognize the base at the bottom is BASE26. we put a 3pin inlet socket at one customizable side of BASE26. This is where we power the AC socket from.
- The top is where goes in the AC plug, and the relay control inside would switch on and off the power in here. - To get more AC socket connected in series, we would use an HT3.96 terminal connectors, as you can see the orange socket in the picture.
- The bottom part is mainly in charge of converting the AC power 220V to DC 5V to power the microprocessor STM32F030F4 and RS485 related circult. As you can see from the picture, two parts wire connected by M-Bus socket and a pair of power wire. A red led indication is placed on top. ## Product Features - RS485 OUTLET - Serial communication protocol: ModBUS-RTU - support Mutiple device Series connection - STM32F030F4 - Embedded 4x M3 Nut - Build with BASE26 - INPUT : 100-240V - OUTPUT: 10A - Power Status indicator ## Include - 1x AC Socket ## Applications - Smart AC Socket Outlet With wire control of RS485 ## Specification
Resources Parameter
Net weight 120g
Gross weight 158g
Product Size 52*52*60mm
Package Size 72*102*72mm
## EasyLoader >EasyLoader is a concise and fast program writer, which has a built-in case program related to the product. It can be burned to the main control by simple steps to perform a series of function verification. Please install the corresponding driver according to the device type. M5Core host [Please click here to view the CP210X driver installation tutorial](en/arduino/arduino_development), M5StickC/V/T/ATOM series can be used without driver)

Description:

Press B to turn on the power and a to turn off the power.

## Example [Please click here to download Arduino code](https://github.com/m5stack/M5Stack/tree/master/examples/Modules/AC-SOCKET) ## ACSocket Modbus RTU Protocol ### Description: - 1. Communication uses RS485, 1 bit start bit + 8 bit data bit + 1 bit end bit - 2. Baud rate 9600 - 3.Device ID defaults to AAH - 4. Address 00H is the broadcast address, the slave does not reply ### Instruction: (hexadecimal) (Modbus RTU format) ### 1. Write coil The host sends: `AA 05 00 00 FF 00 95 E1` (closed coil) `AA 05 00 00 00 00 D4 11` (disconnect coil)                                                                                                                                                                                                                        
Send contentbytesSend a messageRemarks
module address1AAH00H is the broadcast address
Function code105HWrite a single coil
start register address20000HCoil 0 Address
Write data2FF00HFF00H: indicates coil closure | 0000H: indicates coil disconnection
CRC check2XXXXHCRC code of all previous data (CRC16)
Slave response: The operation successfully returns the original data: `AA 05 00 00 FF 00 95 E1` Operation failed to return: `AA 85 error code CRC_L CRC_H` ### 2. Reading the coil The host sends: `AA 01 00 00 00 01 E4 11`                                                                                                                                                                                                                        
Send contentbytesSend a messageRemarks
module address1AAH00H is the broadcast address
Function code101Hread coil
start register address20000HCoil 0 Address
Read quantity20001H can only be 0001H
CRC check2XXXXHCRC code of all previous data (CRC16)
Slave response: The operation returns successfully:                                                                                                    
AddressFunction codeReturn data lengthCoil StatusCRC_LCRC_H
AA010101B06C
Coil status: `01H -> coil closed ` \ `00H -> coil disconnected` Operation failed to return: `AA 81 error code CRC_L CRC_H` ### 3. Write device address The host sends: `AA 41 00 00 00 12 A4 13`                                                                                                                                                                                                                        
Send contentbytesSend a messageRemarks
module address1AAH00H is the broadcast address
Function code141HSet module address
start register address20000HAddress
module new address112H1 byte
CRC check2XXXXHCRC code of all previous data (CRC16)
Slave response: The operation successfully returns the original data: `AA 41 00 00 00 12 A4 13` Operation failed to return: `AA C1 error code CRC_L CRC_H` ### 4. Broadcast recovery device address The host sends: `00 42 00 00 A0 30 `                                                                                                                                                                                    
Send contentbytesSend a messageRemarks
broadcast address100H00H is the broadcast address
Function code142HRecovery address is AAH
start register address20000HAddress
CRC check2XXXXHCRC code of all previous data (CRC16)
Slave response: `none`