Giter VIP home page Giter VIP logo

arduino-teleinfo's Introduction

TeleInfo

Bufferless implementation of the Teleinfo protocol for Arduino.
It is used to stream checksum-validated data without any big static buffer.

It supports both Historical and Standard modes.

Usage

Prerequisites

You may choose:

Usage

Using SoftwareSerial and Historical teleinfo protocol:

#include "teleinfo.hpp"

SoftwareSerial softSerial(RX_PIN, TX_PIN);
auto tinfo = teleinfo::create<teleinfo::Historical>(softSerial);

void setup()
{
    tinfo.begin();
}

void loop()
{
    if (!tinfo.waitForFrame())
    {
        Serial.println("Failed ");
        // Error
    }
    teleinfo::Historical info;
    Teleinfo::Error err;
    for (; (err = tinfo.read(info)) == teleinfo::FRAME_OK;)
    {
        // info contains a valid frame with right checksum
        // info.buf contains the full frame (NULL-terminated)
        // info.key.buf contains the key (ADCO, HPHP...). Its size is info.key.size
        // info.value.buf contains the value. Its size is info.value.size
        // Attention: they are not NULL-terminated
        Serial.write(info.key.buf, info.key.size);
        Serial.write(" = ");
        Serial.write(info.value.buf, info.value.size);
        Serial.write("\r\n");
    }
    // Get the error:
    //PGM_P error_P = teleinfo.get_P(err);
}

Usage with Serial and Standard protocol. The serial object must stay valid:

auto tinfo = teleinfo::create<teleinfo::Standard>(Serial);
// ...
void loop()
{
    // ...
    teleinfo::Standard info;
    for (; (err = tinfo.read(info)) == teleinfo::FRAME_OK;)
    {

    }
}

arduino-teleinfo's People

Contributors

ivankravets avatar

Watchers

Alexandre Blazart avatar

Forkers

ivankravets

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.