PM2M-2016-CultureHydroponique/Suivi

From air
Jump to: navigation, search

Titre ICI

Etudiants M2PGI PM2M: Etudiants


Dépôt Git : github

Documents : Rapport - Transparents - Flyer - Video


Contexte

Objectif du projet

Matériel utilisé

Technologies utilisées

Plan de développement

Dans un premier temps, nous avons récupéré et traité les informations qui venaient de Agri-Sensor.

Nous avons dans un second temps construit notre boîte de culture en intérieur.

Enfin, nous avons créé notre propre structure utilisant un Arduino, AgriActor.

Mise en place de l'infrastructure

Expérimentations et Résultats

Hardware

Nous avons réussi à brancher sur Agri-Actor;

  • un moteur
  • Une barre de LEDs
  • Une enceinte
  • un Capteur Ultrason

Communication

Un deuxième enjeu consiste à assurer la bonne communication entre nos deux Arduinos via node-red.

Notre objectif est ici de limiter un maximum l'intelligence de nos Arduinos et de transférer tous les calculs et la prise de décisions dans le Cloud.

Agri-Actor est programmé pour lire le port série et réagir à certains codes :

  • 9 mise en route de la pompe
  • 8 augmentation de la luminosité
  • 7 diminution de la luminosité
  • 6 lancement de l'alarme

Cloud

Enfin et surtout, notre troisième défi consiste à pouvoir monitorer notre installation à distance grace à Node-red, Influx-DB et Grafana.

Le flow NodeRED est le suivant:

[{"id":"a92c3d8b.49a0b","type":"mqtt-broker","z":"4ce7896f.096518","broker":"broker.mqttdashboard.com","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"9f7bc2ff.60844","type":"influxdb","z":"4ce7896f.096518","hostname":"192.168.1.25","port":"8086","database":"m2m","name":""},{"id":"d7817e2c.06a56","type":"function","z":"4ce7896f.096518","name":"Infos extraction","func":"if (!msg.payload.split) {\n    msg.payload = 'error';\n    return msg;\n}\nconst info = msg.payload.split(' ');\n\nconst key = info[0].split('/');\nconst env = key[1];\nconst car = key[2];\n\nconst value = info[1];\n\nif (env && car && value) {\n    msg.payload = [env, car, value];\n} else {\n    msg.payload = 'error';\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":394.42857360839844,"y":576.1428470611572,"wires":[["57303db9.388d84"]]},{"id":"db5c6122.1b2a5","type":"debug","z":"4ce7896f.096518","name":"Air hum","active":false,"console":"false","complete":"payload","x":933.023811340332,"y":262.99999713897705,"wires":[]},{"id":"57303db9.388d84","type":"function","z":"4ce7896f.096518","name":"Analysis","func":"const infos = msg.payload;\n\nif (infos[0] === 'air') {\n    if (infos[1] === 'humidity') {\n        return [msg, null, null, null, null, null];\n    } else if (infos[1] === 'temperature') {\n        return [null, msg, null, null, null, null];\n    } else if (infos[1] === 'dewpoint') {\n        return [null, null, msg, null, null, null];\n    }\n} else if (infos[0] === 'soil') {\n    return [null, null, null, msg, null, null];\n} else if (infos[0] === 'light') {\n    return [null, null, null, null, msg, null];\n} else if (infos[0] === 'water') {\n    return [null, null, null, null, null, msg]\n}\n","outputs":"6","noerr":0,"x":566.8571548461914,"y":575.1428298950195,"wires":[["49608446.b69f7c"],["96cde7bb.693218"],["6ea94021.9156c"],["496af499.b6950c"],["4c7b637a.b3849c"],["576ea78d.788958"]]},{"id":"49608446.b69f7c","type":"function","z":"4ce7896f.096518","name":"Air humidity","func":"if (msg.payload) {\n    msg.payload = +msg.payload[2];\n}\nreturn msg;","outputs":1,"noerr":0,"x":772.8809928894043,"y":305.4285640716553,"wires":[["db5c6122.1b2a5","ffc74287.0038c"]]},{"id":"6ea94021.9156c","type":"function","z":"4ce7896f.096518","name":"Air dewpoint","func":"if (msg.payload) {\n    msg.payload = +msg.payload[2];\n}\nreturn msg;","outputs":1,"noerr":0,"x":767.7619934082031,"y":487.33334732055664,"wires":[["3abc96ef.c5436a","448670da.bb799"]]},{"id":"96cde7bb.693218","type":"function","z":"4ce7896f.096518","name":"Air temp","func":"if (msg.payload) {\n    msg.payload = +msg.payload[2];\n}\nreturn msg;","outputs":1,"noerr":0,"x":756.571605682373,"y":403.1666431427002,"wires":[["3bbed7f9.c44128","ab5d6595.54a298"]]},{"id":"3bbed7f9.c44128","type":"debug","z":"4ce7896f.096518","name":"Air temp","active":false,"console":"false","complete":"payload","x":927.0000305175781,"y":347.21428871154785,"wires":[]},{"id":"3abc96ef.c5436a","type":"debug","z":"4ce7896f.096518","name":"Air dewpoint","active":false,"console":"false","complete":"payload","x":927.5713958740234,"y":442.714298248291,"wires":[]},{"id":"9a9154bb.656ea8","type":"inject","z":"4ce7896f.096518","name":"air hum ++","topic":"agri-m2m","payload":"/air/humidity 30.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":225.14286041259766,"y":267.0714235305786,"wires":[["d7817e2c.06a56"]]},{"id":"496af499.b6950c","type":"function","z":"4ce7896f.096518","name":"Soil humidity","func":"if (msg.payload) {\n    msg.payload = +msg.payload[2];\n}\nreturn msg;","outputs":1,"noerr":0,"x":747.6428909301758,"y":592.214316368103,"wires":[["fa882bb.f0577d8","b8bb6004.4744a","c83afbef.e4e548"]]},{"id":"4c7b637a.b3849c","type":"function","z":"4ce7896f.096518","name":"Light intensity","func":"if (msg.payload) {\n    msg.payload = +msg.payload[2];\n}\nreturn msg;","outputs":1,"noerr":0,"x":746.928596496582,"y":729.0000133514404,"wires":[["ce330573.31ccf8","fe01f341.01fe1","9e52635a.ad2e7"]]},{"id":"1bda8246.e4257e","type":"inject","z":"4ce7896f.096518","name":"air hum --","topic":"agri-m2m","payload":"/air/humidity 15.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":222.2857208251953,"y":325.6428556442261,"wires":[["d7817e2c.06a56"]]},{"id":"fa882bb.f0577d8","type":"debug","z":"4ce7896f.096518","name":"Soil hum","active":true,"console":"false","complete":"payload","x":923.9285469055176,"y":538.2143087387085,"wires":[]},{"id":"ce330573.31ccf8","type":"debug","z":"4ce7896f.096518","name":"Light intensity","active":false,"console":"false","complete":"payload","x":936.9286079406738,"y":679.0000419616699,"wires":[]},{"id":"1038c218.efc73e","type":"inject","z":"4ce7896f.096518","name":"air temp --","topic":"agri-m2m","payload":"/air/temperature 15.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":223.71429824829102,"y":429.78571033477783,"wires":[["d7817e2c.06a56"]]},{"id":"a0ca97a6.5f3568","type":"inject","z":"4ce7896f.096518","name":"air temp ++","topic":"agri-m2m","payload":"/air/temperature 30.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":228.00000381469727,"y":379.2142686843872,"wires":[["d7817e2c.06a56"]]},{"id":"ba79864f.458678","type":"inject","z":"4ce7896f.096518","name":"air dew --","topic":"agri-m2m","payload":"/air/dewpoint 5.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":225.14286041259766,"y":542.5714416503906,"wires":[["d7817e2c.06a56"]]},{"id":"b96cb3ec.46935","type":"inject","z":"4ce7896f.096518","name":"air dew ++","topic":"agri-m2m","payload":"/air/dewpoint 7.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":228,"y":484.00000953674316,"wires":[["d7817e2c.06a56"]]},{"id":"c7b55160.384ab","type":"inject","z":"4ce7896f.096518","name":"soil hum --","topic":"agri-m2m","payload":"/soil/humidity 15.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":223.71428680419922,"y":761.1428833007812,"wires":[["d7817e2c.06a56"]]},{"id":"e660286d.199fd8","type":"inject","z":"4ce7896f.096518","name":"soil hum ++","topic":"agri-m2m","payload":"/soil/humidity 30.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":226.57142639160156,"y":702.5714511871338,"wires":[["d7817e2c.06a56"]]},{"id":"82ca8e4.f7d357","type":"inject","z":"4ce7896f.096518","name":"light intensity --","topic":"agri-m2m","payload":"/light/intensity 15.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":227.6428680419922,"y":878.642897605896,"wires":[["d7817e2c.06a56"]]},{"id":"b8adc399.47524","type":"inject","z":"4ce7896f.096518","name":"light intensity ++","topic":"agri-m2m","payload":"/light/intensity 30.00","payloadType":"string","repeat":"","crontab":"","once":false,"x":230.50000762939453,"y":820.0714654922485,"wires":[["d7817e2c.06a56"]]},{"id":"ab5d6595.54a298","type":"influxdb out","z":"4ce7896f.096518","influxdb":"9f7bc2ff.60844","name":"air temp","measurement":"airtemp","x":930.7142906188965,"y":401.7856779098511,"wires":[]},{"id":"ffc74287.0038c","type":"influxdb out","z":"4ce7896f.096518","influxdb":"9f7bc2ff.60844","name":"air hum","measurement":"airhum","x":933.4523811340332,"y":307.1428632736206,"wires":[]},{"id":"448670da.bb799","type":"influxdb out","z":"4ce7896f.096518","influxdb":"9f7bc2ff.60844","name":"air dewpoint","measurement":"airdew","x":929.2857131958008,"y":497.8571443557739,"wires":[]},{"id":"b8bb6004.4744a","type":"influxdb out","z":"4ce7896f.096518","influxdb":"9f7bc2ff.60844","name":"soil humidity","measurement":"soilhum","x":932.5000381469727,"y":589.6428880691528,"wires":[]},{"id":"fe01f341.01fe1","type":"influxdb out","z":"4ce7896f.096518","influxdb":"9f7bc2ff.60844","name":"light intensity","measurement":"lightint","x":936.0714721679688,"y":727.8572540283203,"wires":[]},{"id":"852a3ca7.2c50a","type":"mqtt in","z":"4ce7896f.096518","name":"agri-m2m","topic":"agri-m2m","broker":"a92c3d8b.49a0b","x":83.3333511352539,"y":591.6667098999023,"wires":[["71bc0f03.6de2c"]]},{"id":"c83afbef.e4e548","type":"function","z":"4ce7896f.096518","name":"water?","func":"if (msg.payload < 40) {\n    msg.payload = 9;\n} else {\n    msg.payload = 0;\n}\nreturn msg;","outputs":1,"noerr":0,"x":914.1666450500488,"y":639.1667041778564,"wires":[["204b13e5.8093cc","e21956c4.bc03d8"]]},{"id":"e21956c4.bc03d8","type":"mqtt out","z":"4ce7896f.096518","name":"water","topic":"agri-m2m-retour","qos":"","retain":"","broker":"a92c3d8b.49a0b","x":1102.50004196167,"y":639.1666221618652,"wires":[]},{"id":"204b13e5.8093cc","type":"debug","z":"4ce7896f.096518","name":"water signal","active":false,"console":"false","complete":"payload","x":1122.4999237060547,"y":585.8333673477173,"wires":[]},{"id":"71bc0f03.6de2c","type":"debug","z":"4ce7896f.096518","name":"mqtt brut","active":false,"console":"false","complete":"payload","x":198.33332061767578,"y":643.3332777023315,"wires":[]},{"id":"576ea78d.788958","type":"function","z":"4ce7896f.096518","name":"Water distance","func":"if (msg.payload) {\n    msg.payload = +msg.payload[2];\n}\nreturn msg;","outputs":1,"noerr":0,"x":753.3333282470703,"y":882.5000133514404,"wires":[["c65fe6b2.b289f8","e0a03178.ebd07"]]},{"id":"c65fe6b2.b289f8","type":"debug","z":"4ce7896f.096518","name":"Water distance","active":false,"console":"false","complete":"payload","x":933.3333435058594,"y":822.4999294281006,"wires":[]},{"id":"3915c94a.5430d6","type":"mqtt out","z":"4ce7896f.096518","name":"light","topic":"agri-m2m-retour","qos":"","retain":"","broker":"a92c3d8b.49a0b","x":1094.1665534973145,"y":781.6666564941406,"wires":[]},{"id":"9e52635a.ad2e7","type":"function","z":"4ce7896f.096518","name":"light?","func":"if (msg.payload < 3) {\n    msg.payload = 8;\n} else if (msg.payload > 3) {\n    msg.payload = 7;\n} else {\n    msg.payload = 0;\n}\nreturn msg;","outputs":1,"noerr":0,"x":942.4999465942383,"y":781.666654586792,"wires":[["6d26762c.8447b8","3915c94a.5430d6"]]},{"id":"6d26762c.8447b8","type":"debug","z":"4ce7896f.096518","name":"light signal","active":false,"console":"false","complete":"payload","x":1114.166633605957,"y":716.6666622161865,"wires":[]},{"id":"e0a03178.ebd07","type":"function","z":"4ce7896f.096518","name":"noMoreWater?","func":"if (msg.payload > 0.30 && context.done != 1) {\n    msg.payload = 6;\n    context.done = 1;\n} else if (msg.payload > -1) {\n    msg.payload = 0;\n} else {\n    context.done = 0;\n}\nreturn msg;","outputs":1,"noerr":0,"x":941.6667022705078,"y":884.9999527931213,"wires":[["9a0566fe.aa8a28"]]},{"id":"9a0566fe.aa8a28","type":"mqtt out","z":"4ce7896f.096518","name":"sound","topic":"agri-m2m-retour","qos":"","retain":"","broker":"a92c3d8b.49a0b","x":1105.0000610351562,"y":884.9999918937683,"wires":[]},{"id":"429eebc2.b7e414","type":"inject","z":"4ce7896f.096518","name":"Reset alarm","topic":"","payload":"{payload: 0.40}","payloadType":"none","repeat":"","crontab":"","once":false,"x":582,"y":945,"wires":[["83329e9e.dd521"]]},{"id":"83329e9e.dd521","type":"function","z":"4ce7896f.096518","name":"Reset","func":"msg.payload = -1;\nreturn msg;","outputs":1,"noerr":0,"x":731,"y":945,"wires":[["e0a03178.ebd07"]]}]

Photos et Vidéo

Test du son ! https://www.youtube.com/watch?v=cqTI-i-xu70

eGrow Prototype
eGrow NodeRED