====== Ciel mon Printemps ====== ===== Matériel ===== [[https://www.lextronic.fr/bundle-livre-avec-capteurs-pour-station-meteo-57586.html|Station météo]] [[https://fr.aliexpress.com/item/1214985366.html|Staion météo sur Aliexpress]] [[https://fr.aliexpress.com/item/1005005608369735.html|Télécommande Bluetooth]] [[https://www.manomano.fr/p/wh-sp-ws01-instrument-de-mesure-de-la-du-vent-capteur-de-du-vent-instrument-mto-accessoires-pour-anmomtre-69894495|Anémomètre WH-SP-WS01]] [[https://fr.aliexpress.com/item/32975493537.html?gatewayAdapt=glo2fra|Autre modèle]] [[https://www.lextronic.fr/anemometre-pluviometre-girouette-compatible-arduino-microbit-grove-63661.html|Anémomètre + Girouette chez Lextronic]] ===== Interface ===== Nous utilisons TouschOSC pour effectuer les réglages. en fonction des lieux. Voici le fichier de configuration pour {{ :pad.touchosc.zip |TouchOSC MK1}} Il faut ensuite télécharger [[https://hexler.net/touchosc-mk1|TouchOSC Editor]] sur un ordinateur pour synchroniser avec l'appareil mobile. Attention, il n'y a pas de de version pour Linux. ===== Streaming ===== [[https://raspberry-projects.com/pi/pi-hardware/raspberry-pi-camera/streaming-video-using-vlc-player|Stream avec une Raspberry Pi]] [[https://forums.raspberrypi.com/viewtopic.php?t=178493| stream via UDP]] [[https://blog.miguelgrinberg.com/post/stream-video-from-the-raspberry-pi-camera-to-web-browsers-even-on-ios-and-android|Stremaing avec mpeg]] [[https://www.int21h.eu/stream-raspivid.html| Pour lancer un service à l'appel de la connexion]] [[https://gitlab.com/-/snippets/1967306|Avec V4l2 loopback]] [[https://forums.raspberrypi.com/viewtopic.php?t=335940|La solution sans doute]] [[https://softsolder.com/2020/09/28/raspberry-pi-streaming-video-loopback/| une autre]] [http://www.davidhunt.ie/raspberry-pi-high-quality-camera-setup-for-low-latency-video-conferencing/|UNe autre approche]] [[https://medium.com/@sbonnet.dev/how-to-build-a-virtual-camera-under-linux-and-windows-7af0e6433796|Création d'une caméra virtuelle sous Linux]] ===== Code ===== ==== Code Arduino station météo ==== #include #include "arduino_secrets.h" #define anemometre A2 #define PI_4 0.78539816339 #define PI_2 1.5707963267948966192313216916398 #define PI3_4 2.35619449019 #define PI 3.1415926535897932384626433832795 #define PI5_4 3.92699081699 #define PI3_2 4.71238898038 #define PI7_4 5.49778714378 int status = WL_IDLE_STATUS; // Le nom du réseau et le mot de passe sont stockés dans le fichier arduino_secrets.h char ssid[] = SECRET_SSID; char pass[] = SECRET_PASS; WiFiUDP Udp; // Définition de l'adresse IP et du port de destination IPAddress serveurIp(192, 168, 1, 159); // 192.168.1.159 unsigned int serveurPort = 7000; // définition du port local unsigned int localPort = 7001; unsigned long temps; bool etat = false; bool etat2 = false; void setup() { Serial.begin(9600); // Vérification de la présence du module WiFi if (WiFi.status() == WL_NO_MODULE) { Serial.println("La communication avec le module WiFi a échouée!"); // Arrêt while (true) ; } String fv = WiFi.firmwareVersion(); if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.println("Mettez à jour le firmware"); } // Tentative de connexionau réseau WiFi while (status != WL_CONNECTED) { Serial.print("Tentative de connexion au SSID: "); Serial.println(ssid); status = WiFi.begin(ssid, pass); // Attente de 10s pour la connexion delay(10000); } Serial.println("Connecté au WiFi"); affichageStutWiFi(); Serial.println("\nConnexion au serveur..."); // Démarre la liaison UDP Udp.begin(localPort); // Intialisation des ports de la station météo pinMode(anemometre, INPUT); // Anémomètre pinMode(13, OUTPUT); temps = millis(); } void loop() { if ((digitalRead(anemometre) == HIGH) && (etat == false) && (etat2 == false)) { etat = true; etat2 = true; int duree = millis() - temps; float vitesse = 10.0 / duree; float angle; switch (analogRead(A1) / 100) { case 0: angle = 0.0; // break; case 1: angle = PI_4; // break; case 2: angle = PI_2; // break; case 4: angle = PI7_4; // break; case 6: angle = PI3_4; // break; case 7: angle = PI3_2; // break; case 8: angle = PI5_4; // break; case 9: angle = PI; // break; } envoyeDonnees(vitesse * cos(angle), vitesse * sin(angle), serveurIp, serveurPort); temps = millis(); } if ((digitalRead(anemometre) == HIGH) && (etat == false) && (etat2 == true)) { etat2 = false; etat = true; } if (digitalRead(anemometre) == LOW) { etat = false; } } void envoyeDonnees(float x, float y, IPAddress serveurIp, unsigned int ServeurPort) { // Formaqtion du message OSC uint8_t message[] = { 0x2F, 0x76, 0x65, 0x6E, 0x74, 0x00, 0x00, 0x00, 0x2C, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; uint8_t xTab[4]; uint8_t yTab[4]; memcpy(&xTab, &x, 4); memcpy(&yTab, &y, 4); for (int j = 0; j < 4; j++) { memcpy(&message[12 + j], &xTab[3 - j], 1); memcpy(&message[16 + j], &yTab[3 - j], 1); } // Envoie du message par UDP Udp.beginPacket(serveurIp, ServeurPort); Udp.write(message, 20); Udp.endPacket(); } void affichageStutWiFi() { // Affiche le SSID du réseau Serial.print("SSID: "); Serial.println(WiFi.SSID()); // Affiche l'adresse IP de la carte IPAddress ip = WiFi.localIP(); Serial.print("Adresse IP: "); Serial.println(ip); // Affiche la force du signal reçu long rssi = WiFi.RSSI(); Serial.print("force du signal (RSSI):"); Serial.print(rssi); Serial.println(" dBm"); } ==== Archive projet ==== {{ :apps.zip |Archive}} ==== Code teteDeTurc ==== Code pour la prise de photos pour les festivaliers. {{ :tetedeturc.zip |Archive des sources du programme}} ==== Code cielMonPrintemps ==== Programme principal de l'installation. {{ :cielmonprintemps.zip |Archive des sources du programme}} ==== Liens pour le code ==== [[https://forums.raspberrypi.com/viewtopic.php?t=293457#p1776446|Télécommande Bluetooth]] [[https://linuxfr.org/forums/programmation-python/posts/codes-python-pour-faire-marcher-une-mini-telecommande-sans-fil-bluetooth-sur-mon-raspberry-pi|Un autre pour la télécommande]] [[https://github.com/bluez/bluez/issues/605|Aide pour le Bluetooth]] [[https://www.youtube.com/watch?v=xSBdepi6bFg|Pour l'anémomètre]] [[https://people.csail.mit.edu/albert/bluez-intro/c404.html#simplescan.c|Bluetooth]] bluetooth en Python]] [[https://how2electronics.com/measure-wind-speed-direction-with-ultrasonic-anemometer-arduino/|Anémomètre à ultrasons]] [[https://docs.arduino.cc/tutorials/uno-r4-wifi/wifi-examples/|Code pour le WiFi]] ===== Droidcam ===== Application qui permet de transformer son téléphone en caméra sans fil vue comme une webcam * https://play.google.com/store/apps/details?id=com.dev47apps.droidcam * https://www.dev47apps.com/droidcam/linux/ Lancer l'application via ADB en wifi FP3:/ # monkey -p com.dev47apps.droidcam -v 1 FP3:/ # ps -A |grep cam u0_a156 31680 762 32171960 197348 SyS_epoll_wait 0 S com.dev47apps.droidcam FP3:/ # kill 31680 {{tag> sylvain, OpenFrameworks}}