KEBA sensor



  • Hi everyone,

    got a brand new KEBA p30c wallbox and I'd like to introduce this into MySensors. Some general outlines...

    One can communicate with the KEBA by sending commands using the UDP protocol.
    I've decided to create a sensor which can read data from the wallbox by sending requests to and parse replies from the wallbox.
    In a final step this data could then be presented to a smart home server (which is Domoticz in my case).

    The data I am receiving is of a variety of different types like "time", "milliamps", "text" or "binary" among others.
    All in all, I guess I've got about 50 different variables to expect.

    So far I haven't gotten much. I chose a Mega 2560 and an Arduino Ethernet shield. The Mega is programmed as a gateway; there's no radio because the sole purpose of the device is to be the connection between KEBA and MySensors/Domoticz.
    Right now I can send a command to the wallbox, receive the answer, print that in the serial monitor and send some data to Domoticz.

    That's actually one of the many questions I've got 🙂

    What's the correct way to send text data?
    I am receiving a string of data from KEBA and -just for starters- would like to display the data as ASCII characters in Domotics. The data there is displayed by clicking on the "Log" button of my MySensors "text sensor").

    Some fragments:

    The data from KEBA is stored in array:

    char packetBuffer[UDP_MAX];      // buffer to hold incoming packet,
    
    MyMessage infoMsg(CHILD_ID_INFO, V_TEXT);
    

    and I present my sensor ...

    present(CHILD_ID_INFO, S_INFO);
    

    and then I send a string in "packetBuffer" ...

    send(infoMsg.set (packetBuffer, 1));
    

    What's the correct format for sending text here?
    If I omit the ",1" Domoticz gets but the first ASCII character which is a bracket.
    With a ",1", in Domoticz I get "7B" which is the hex code for said bracket.
    What would I have to do to get a real ASCII string displayed in the log file in Domoticz?

    Just in case anyone's interested :

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Contribution by a-lurker and Anticimex,
     * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
     * Contribution by Tomas Hozza <thozza@gmail.com>
     */
    
    
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG  
    
    // Enable gateway ethernet module type
    #define MY_GATEWAY_W5100
    
    // fixed IP address
    #define MY_IP_ADDRESS 192,168,2,159   // 
    
    // The port to keep open on node server mode / or port to contact in client mode
    #define MY_PORT 5003
    
    // MAC address
    #define MY_MAC_ADDRESS 0xDE, 0xAC, 0xBE, 0xEF, 0xFE, 0xEA 
    
    #include <Ethernet.h>
    #include <MySensors.h>
    #include <EthernetUdp.h>
    
    #define UDP_MAX 345               // just to test
    
    byte mac[] = {MY_MAC_ADDRESS}; 
    IPAddress ip(MY_IP_ADDRESS); 
    IPAddress remIP(192, 168, 2, 83);
    unsigned long localPort = 7090;     // local port to listen on
    unsigned long remPort = 7090;       // KEBA port to send to
    
    char packetBuffer[UDP_MAX];         // buffer to hold incoming packet,
    char  ReplyBuffer[] = "report 2";   // command to be sent to KEBA for testing
    
    // An EthernetUDP instance to let us send and receive packets over UDP
    EthernetUDP Udp;
    
    #define MY_NODE_ID 33                    // 
    #define SN "KEBA Wallbox"
    #define SV "2.00"
    
    // #define MY_PARENT_ID 0
    #define CHILD_ID_INFO 0
    
    MyMessage infoMsg(CHILD_ID_INFO, V_TEXT);
    
    void before()
    {
      
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo(SN, SV);
      present(CHILD_ID_INFO, S_INFO);
      wait(10);
    }
    
    void setup()
    {
      // start the Ethernet and UDP:
      Ethernet.begin(mac, ip);
      Udp.begin(localPort);
    
      Serial.begin(115200);
      Udp.remoteIP() = remIP;
    
      Serial.println("------------------------------------------");
      Serial.print("KEBA IP: ");
      Serial.println(remIP);
      Serial.print("KEBA Port: ");
      Serial.println(remPort);
      Serial.println("------------------------------------------");  
    }
    
    void loop()
    {
      getKEBA();
      delay( 20000);  // for testing purps
    }
    
    void getKEBA()
    {
      Udp.beginPacket(remIP, remPort);          
      Udp.write(ReplyBuffer);
      Udp.endPacket();
    
      int packetSize = Udp.parsePacket();
      if (packetSize)                           // if there's data available, read a packet
      {
        Serial.println("------------------------------------------");
        Serial.print("Received packet of size ");
        Serial.println(packetSize);
        Serial.print("From ");
        IPAddress remote = Udp.remoteIP();
        for (int i = 0; i < 4; i++)
        {
          Serial.print(remote[i], DEC);
          if (i < 3)
          {
            Serial.print(".");
          }
        }
        Serial.print(", port ");
        Serial.println(Udp.remotePort());
    
        // read the packet into packetBufffer
        Udp.read(packetBuffer, UDP_MAX);
        Serial.print("Contents: ");
        Serial.println(packetBuffer);
        send(infoMsg.set (packetBuffer, 1));
      }
      delay(10);  
    }
    
    void parseKEBA()
    {
      
    }
    
    

    Thanks for any input!

    Christoph


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 5
  • 10
  • 2
  • 6

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts