Passer au contenu principal

Code

Le code est disponible sur le dépôt Github. Vous y trouverez :

  • Le code source.
  • Des releases du firmware compilé.
  • Les fichiers de CAO.

Notes

API

Le process pour récupérer les données est le suivant :

  • Avant tout il faut créer un compte sur la plateforme et s'abonner à l'API
  • Ensuite dans "Mes applications" on récupére la clé ("Copier base64")

image.png

L'accès à l'API est limité à 1 appel / 15 minutes. Pour faire des essais une URL dîtes "bac à sable" permet de simuler sans avoir cette limite. https://digital.iservices.rte-france.com/open_api/ecowatt/v4/sandbox/signals

Exemple de données reçues (depuis le bac à sable) :

{   
    "signals": [
        {
            "GenerationFichier": "2022-06-03T07:36:25+02:00",
            "jour": "2022-06-06T00:00:00+02:00",
            "dvalue": 1,
            "message": "Situation normale ",
            "values": [
                {
                    "pas": 0,
                    "hvalue": 1
                },
                {
                    "pas": 1,
                    "hvalue": 1
                },
                {
                    "pas": 2,
                    "hvalue": 1
                },
                {
                    "pas": 3,
                    "hvalue": 1
                },
                {
                    "pas": 4,
                    "hvalue": 1
                },
                {
                    "pas": 5,
                    "hvalue": 1
                },
                {
                    "pas": 6,
                    "hvalue": 1
                },
                {
                    "pas": 7,
                    "hvalue": 1
                },
                {
                    "pas": 8,
                    "hvalue": 1
                },
                {
                    "pas": 9,
                    "hvalue": 1
                },
                {
                    "pas": 10,
                    "hvalue": 1
                },
                {
                    "pas": 11,
                    "hvalue": 1
                },
                {
                    "pas": 12,
                    "hvalue": 1
                },
                {
                    "pas": 13,
                    "hvalue": 1
                },
                {
                    "pas": 14,
                    "hvalue": 1
                },
                {
                    "pas": 15,
                    "hvalue": 1
                },
                {
                    "pas": 16,
                    "hvalue": 1
                },
                {
                    "pas": 17,
                    "hvalue": 1
                },
                {
                    "pas": 18,
                    "hvalue": 1
                },
                {
                    "pas": 19,
                    "hvalue": 1
                },
                {
                    "pas": 20,
                    "hvalue": 1
                },
                {
                    "pas": 21,
                    "hvalue": 1
                },
                {
                    "pas": 22,
                    "hvalue": 1
                },
                {
                    "pas": 23,
                    "hvalue": 1
                }
            ]
        },
        {
            "GenerationFichier": "2022-06-03T07:36:25+02:00",
            "jour": "2022-06-04T00:00:00+02:00",
            "dvalue": 3,
            "message": "Coupures d'électricité programmées",
            "values": [
                {
                    "pas": 0,
                    "hvalue": 1
                },
                {
                    "pas": 1,
                    "hvalue": 1
                },
                {
                    "pas": 2,
                    "hvalue": 1
                },
                {
                    "pas": 3,
                    "hvalue": 1
                },
                {
                    "pas": 4,
                    "hvalue": 1
                },
                {
                    "pas": 5,
                    "hvalue": 2
                },
                {
                    "pas": 6,
                    "hvalue": 2
                },
                {
                    "pas": 7,
                    "hvalue": 3
                },
                {
                    "pas": 8,
                    "hvalue": 3
                },
                {
                    "pas": 9,
                    "hvalue": 3
                },
                {
                    "pas": 10,
                    "hvalue": 3
                },
                {
                    "pas": 11,
                    "hvalue": 3
                },
                {
                    "pas": 12,
                    "hvalue": 3
                },
                {
                    "pas": 13,
                    "hvalue": 2
                },
                {
                    "pas": 14,
                    "hvalue": 2
                },
                {
                    "pas": 15,
                    "hvalue": 2
                },
                {
                    "pas": 16,
                    "hvalue": 2
                },
                {
                    "pas": 17,
                    "hvalue": 3
                },
                {
                    "pas": 18,
                    "hvalue": 3
                },
                {
                    "pas": 19,
                    "hvalue": 3
                },
                {
                    "pas": 20,
                    "hvalue": 2
                },
                {
                    "pas": 21,
                    "hvalue": 2
                },
                {
                    "pas": 22,
                    "hvalue": 2
                },
                {
                    "pas": 23,
                    "hvalue": 2
                }
            ]
        },
        {
            "GenerationFichier": "2022-06-03T07:36:25+02:00",
            "jour": "2022-06-05T00:00:00+02:00",
            "dvalue": 2,
            "message": "Risque de coupures d'électricité",
            "values": [
                {
                    "pas": 0,
                    "hvalue": 1
                },
                {
                    "pas": 1,
                    "hvalue": 1
                },
                {
                    "pas": 2,
                    "hvalue": 1
                },
                {
                    "pas": 3,
                    "hvalue": 1
                },
                {
                    "pas": 4,
                    "hvalue": 1
                },
                {
                    "pas": 5,
                    "hvalue": 1
                },
                {
                    "pas": 6,
                    "hvalue": 1
                },
                {
                    "pas": 7,
                    "hvalue": 2
                },
                {
                    "pas": 8,
                    "hvalue": 2
                },
                {
                    "pas": 9,
                    "hvalue": 2
                },
                {
                    "pas": 10,
                    "hvalue": 2
                },
                {
                    "pas": 11,
                    "hvalue": 2
                },
                {
                    "pas": 12,
                    "hvalue": 1
                },
                {
                    "pas": 13,
                    "hvalue": 1
                },
                {
                    "pas": 14,
                    "hvalue": 1
                },
                {
                    "pas": 15,
                    "hvalue": 1
                },
                {
                    "pas": 16,
                    "hvalue": 1
                },
                {
                    "pas": 17,
                    "hvalue": 2
                },
                {
                    "pas": 18,
                    "hvalue": 2
                },
                {
                    "pas": 19,
                    "hvalue": 1
                },
                {
                    "pas": 20,
                    "hvalue": 1
                },
                {
                    "pas": 21,
                    "hvalue": 1
                },
                {
                    "pas": 22,
                    "hvalue": 1
                },
                {
                    "pas": 23,
                    "hvalue": 1
                }
            ]
        },
        {
            "GenerationFichier": "2022-06-03T07:36:25+02:00",
            "jour": "2022-06-03T00:00:00+02:00",
            "dvalue": 3,
            "message": "Coupures d'électricité en cours",
            "values": [
                {
                    "pas": 7,
                    "hvalue": 3
                },
                {
                    "pas": 8,
                    "hvalue": 3
                },
                {
                    "pas": 9,
                    "hvalue": 1
                },
                {
                    "pas": 10,
                    "hvalue": 1
                },
                {
                    "pas": 11,
                    "hvalue": 1
                },
                {
                    "pas": 12,
                    "hvalue": 1
                },
                {
                    "pas": 13,
                    "hvalue": 1
                },
                {
                    "pas": 14,
                    "hvalue": 3
                },
                {
                    "pas": 15,
                    "hvalue": 3
                },
                {
                    "pas": 16,
                    "hvalue": 3
                },
                {
                    "pas": 17,
                    "hvalue": 3
                },
                {
                    "pas": 18,
                    "hvalue": 3
                },
                {
                    "pas": 19,
                    "hvalue": 3
                },
                {
                    "pas": 20,
                    "hvalue": 3
                },
                {
                    "pas": 21,
                    "hvalue": 2
                },
                {
                    "pas": 22,
                    "hvalue": 2
                },
                {
                    "pas": 23,
                    "hvalue": 2
                }
            ]
        }
    ]
}

JSON

Le code s'appuie sur ArduinoJson, une librairie connue dont le but est de gérer des données au format json.

Pour aider à construire le code à partir d'un exemple de JSON, il existe un assistant 

On indique sa plateforme, on saisit son JSON, et on obtient la taille mémoire recommandée ainsi qu'un code exemple permettant de parcourir les données.

Paramétrage du wifi

Liens externes