Processing the smart meter data (2)

Today I made some progress on processing the smart meter data with a SimpleCortex.

I started collecting the P1 data from our smart meter from the first day it was installed. A laptop, an RX-inverted USB cable and HyperTerminal take care of that for almost a week now.

Logging P1 smart meter data with HyperTerminal Now it was time to do something with the data I logged (currently 25 MB in size).

For that, I needed to create a test setup, with which I could simulate that the SimpleCortex was directly connected to the Smart meters P1 port.

Well, that was not so hard; I wrote a quick & dirty VB.Net tool that mimics the P1 ports behaviour, by reading the logged data and writing it to a Serial port.

This Serial Port is a USB-BUB connected to  UART0 of the SimpleCortex:

Feeding the SimpleCortex with smart meter data

Now I only needed a receiver for what the Simplecortex wants to send; for that I used a small Delphi app with a Indy IdTCPServer component – this logs everything it receives to a file, so I can easily monitor what’s being received.

With the VB.Net “P1 feeder”, the USB-BUB and the Delphi TCP server app I can now code, flash, test & debug with the Simplecortex right beside me in my office; I think I’ll need it, cause I’ve still got a long way to go.

Now that I had setup the right test-environment I could start with writing the code for the Simplecortex. If only I could get some sort of ‘Hello world’ example for the uIP TCP/IP stack to get me going – the Simplecortex webserver example looked like overkill; too much to learn at once, I needed something simpler to start with. Mark, who commented on an earlier post about the Simplecortex, was so kind to help me out and provided me with an example of a project that echoed the TCP data it received; and that was all I needed – suddenly it was clear to me how I should start.

And here it is, the output that’s being received from the SimpleCortex:

15:34:11.078  TCP < !
15:34:20.952  TCP < /ISk52ME382-1003
15:34:20.952  TCP < 137
15:34:21.112  TCP < 0-0:96.1.1(4B414C37444035313039373537343132)
15:34:21.112  TCP < 1-0:1.8.1(00002.368*kWh)
15:34:21.112  TCP < 1-0:1.8.2(00000.000*kWh)
15:34:21.112  TCP < 1-0:2.8.1(00000.000*kWh)
15:34:21.112  TCP < 1-0:2.8.2(00000.000*kWh)
15:34:21.312  TCP < 0-0:96.14.0(0001)
15:34:21.312  TCP < 1-0:1.7.0(0000.88*kW)
15:34:21.312  TCP < 1-0:2.7.0(0000.00*kW)
15:34:21.312  TCP < 0-0:17.0.0(0999.00*kW)
15:34:21.312  TCP < 0-0:96.3.10(1)
15:34:21.312  TCP < 0-0:96.13.1()
15:34:21.312  TCP < 0-0:96.13.0()
15:34:21.312  TCP < 0-1:24.1.0(3)
15:34:21.312  TCP < 0-1:96.1.0(3238303131303031344439323034343132)
15:34:21.513  TCP < 0-1:24.3.0(120807230000)(00)(60)(1)(0-1:24.2.1)()
15:34:21.513  TCP < (00000000)
15:34:21.513  TCP < 0-1:24.4.0(1)
15:34:21.513  TCP < !

For now, the only thing the Simplecortex does is waiting for data on UART0 and transmitting the data it received to the IP address of my PC. Sounds like a simple task, and it was; I was actually surprised with how fast I finished this first step.

But as I said: I still have a long way to go, cause this is still on my todo-list for this project:

  • Parse the incoming P1 data and collect the data I need (power usages, gas usage)
  • Act as a MQTT client and publish the collected data;
  • Being able to handle 7-E-1 with the UART instead of 8-N-1
  • Automatically reconnect when the connection fails for whatever reason;

And of course there are some technical issues I don’t understand fully yet; one of them being the interval with which the Simplecortex seems to send the data – every 200 ms? Strange.

So there’s still a lot to do, but the preliminary results make me happy and give me confidence for a good end result 🙂

Tagged , . Bookmark the permalink.

3 Responses to Processing the smart meter data (2)

  1. Patrick says:

    Robert,

    I see you decided on using MQTT as messaging framework. I think it’s a good choice. Being a Delphi Developer myself, i would like to know if you are going to use Jamies Delphi client or are you going to make your own? Jamies client doesn’t suport Delphi after D2007 (No unicode support) and is not able to use QoS levels 1 and 2 of the MQTT protocol. What are your thougts on this?

    Patrick

    • Hi Patrick,
      Yep, it’s going to be MQTT because I think it’s the better choice if you want to have boards like Arduino, SimpleCortex, FEZ Panda, Netduino act as a messaging client. I’ve been doing some tests with Jamie Ingilbys MQTTClient and for now that will suffice (I’m still developing in D2005). When things get really serious I think I will need to extend the current MQTTClient.
      Robert.

  2. Pingback: Processing the smart meter data (3) - Digits Domotica Blog

Leave a Reply

Your email address will not be published. Required fields are marked *