Slide 1

Slide 1 text

Raspberry Pi Electricity Monitor Reverse Engineering Serial Data Protocols James Singleton unop.co.uk

Slide 2

Slide 2 text

Maplin ● £13 ● Download data feature ● www.maplin.co.uk/wireless-electricity-monitor-611581

Slide 3

Slide 3 text

Looks like this... ● Windows only (and not very good) ● PC power consumption negates benefit

Slide 4

Slide 4 text

And this...

Slide 5

Slide 5 text

And this...

Slide 6

Slide 6 text

And this...

Slide 7

Slide 7 text

And sometimes like this...

Slide 8

Slide 8 text

That makes socket sad

Slide 9

Slide 9 text

Linux ● Windows requires a driver install ● And it's buggy (causes BSOD) ● USB serial driver included on Raspbian ● Just plug it in ● And you can talk to the device

Slide 10

Slide 10 text

That makes socket smile

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

How ● That's the why and the results ● You can read about the rest of the results online ● But how would you go about making generic hardware work on another OS? ● Methods and tools ● RS232 hackery

Slide 16

Slide 16 text

Sniff the data

Slide 17

Slide 17 text

The data 0 0.09933916sems.exeIRP_MJ_CREATE ProlificSerial0 SUCCESS Options: Open 1 0.00001928sems.exeIOCTL_SERIAL_SET_QUEUE_SIZE ProlificSerial0 SUCCESS InSize: 2500 OutSize: 2500 2 0.00000559sems.exeIOCTL_SERIAL_GET_BAUD_RATE ProlificSerial0 SUCCESS 3 0.00000419sems.exeIOCTL_SERIAL_GET_LINE_CONTROL ProlificSerial0 SUCCESS 4 0.00000391sems.exeIOCTL_SERIAL_GET_CHARS ProlificSerial0 SUCCESS 5 0.00000391sems.exeIOCTL_SERIAL_GET_HANDFLOW ProlificSerial0 SUCCESS 6 0.00000391sems.exeIOCTL_SERIAL_GET_BAUD_RATE ProlificSerial0 SUCCESS 7 0.00000363sems.exeIOCTL_SERIAL_GET_LINE_CONTROL ProlificSerial0 SUCCESS 8 0.00000363sems.exeIOCTL_SERIAL_GET_CHARS ProlificSerial0 SUCCESS 9 0.00000363sems.exeIOCTL_SERIAL_GET_HANDFLOW ProlificSerial0 SUCCESS 100.05133837sems.exeIOCTL_SERIAL_SET_BAUD_RATE ProlificSerial0 SUCCESS Rate: 9600 110.00038217sems.exeIOCTL_SERIAL_SET_RTS ProlificSerial0 SUCCESS 120.00098141sems.exeIOCTL_SERIAL_SET_DTR ProlificSerial0 SUCCESS 130.00094090sems.exeIOCTL_SERIAL_SET_LINE_CONTROL ProlificSerial0 SUCCESS StopBits: 1 Parity: NONE WordLength: 8 140.00003269sems.exeIOCTL_SERIAL_SET_CHAR ProlificSerial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13 150.00000503sems.exeIOCTL_SERIAL_SET_HANDFLOW ProlificSerial0 SUCCESS Shake:1 Replace:40 XonLimit:2048 XoffLimit:512 160.00000810sems.exeIOCTL_SERIAL_PURGE ProlificSerial0 SUCCESS Purge: TXCLEAR RXCLEAR 170.00000447sems.exeIOCTL_SERIAL_SET_TIMEOUTS ProlificSerial0 SUCCESS RI:20 RM:20 RC:20 WM:20 WC:3000 180.00000503sems.exeIOCTL_SERIAL_GET_COMMSTATUS ProlificSerial0 SUCCESS 190.00086547sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: .... 200.03268125sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 8: ........ 211.30080499sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0: 220.00082832sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: .... 231.30087539sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0: 240.00047604sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: .... 250.07094952sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: S01....2S0222..1S03....2S04....2S05....2S06....2S07....2S08....2 260.06694426sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: S09....2S10....2S11....2S12....2S13....2S14....2S15....2S16....2 270.02160247sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 1: . 281.30083293sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0: 290.00047799sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: .... 300.05098469sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: S01DAY.......................................................... 310.06696158sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: ......................MON....................................... 320.03139673sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 10: .......... 331.30079717sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:

Slide 18

Slide 18 text

Hex 190.00088894sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: AA 00 00 AD 200.03275919sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 8: AA F0 00 AD 01 00 01 00 211.30085695sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0: 220.00095264sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: AA 01 00 AD 230.05059023sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 53 30 31 44 41 59 07 00 08 00 08 00 08 00 0C 0 240.06584636sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 06 00 07 00 09 00 08 00 09 00 0C 00 0E 00 08 0 250.03186327sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 10: 00 00 00 00 00 00 00 00 00 11 261.30084215sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0: 270.00109204sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: AA 02 00 AD 280.06994297sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 53 30 31 FF FF 00 00 32 53 30 32 32 32 13 08 3 290.06694873sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 53 30 39 FF FF 00 00 32 53 31 30 FF FF 00 00 3 300.02180892sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 1: F9 311.30084885sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0: 320.00063863sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: AA 01 00 AD 330.05113499sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 53 30 31 44 41 59 07 00 08 00 08 00 08 00 0C 0 340.06591955sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 06 00 07 00 09 00 08 00 09 00 0C 00 0E 00 08 0 350.03220409sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 10: 00 00 00 00 00 00 00 00 00 11 361.30084410sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0: 370.00054309sems.exeIRP_MJ_WRITEProlificSerial0 SUCCESS Length 4: AA 02 00 AD 380.07091544sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 53 30 31 FF FF 00 00 32 53 30 32 32 32 D2 07 3 390.06695292sems.exeIRP_MJ_READ ProlificSerial0 SUCCESS Length 64: 53 30 39 FF FF 00 00 32 53 31 30 FF FF 00 00 3 400.02219137sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 1: B7 411.30084717sems.exeIRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:

Slide 19

Slide 19 text

Reimplement ● Poll ● Extract value ● Compress ● Save ● Host ● Graph ● Cron tail ● Digital sign (local or remote)

Slide 20

Slide 20 text

Future improvements ● Use a DB (SQLite) ● Post to online API ● Combine with pricing data ● Calibrate against meter ● Combine with plug in meter for voltage ● An app!

Slide 21

Slide 21 text

The plug ● I've got a startup ● Shutdown Scanner ● Service to automatically measure how much power/money is wasted by inactive computers left on over night or at weekends ● ShutdownScanner.com ● Lots more graphs

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Thanks