Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
ressources:photo_ftp [2023/08/30 11:48] – jeff | ressources:photo_ftp [2024/02/08 17:20] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== ESPCAM ====== | ====== ESPCAM ====== | ||
- | un code qui fonctionne ( pas de pb de saturation...) pour prendre à intervalle régulier(frequence) une photo jpg et la poser par ftp sur le serveur.\ | + | un code qui fonctionne ( pas de pb de saturation...) pour prendre à intervalle régulier(frequence) une photo jpg et la poser par ftp sur le serveur. |
un script place la photo sur le site web en utilisant la fonction watch (yum install inotify-tools) | un script place la photo sur le site web en utilisant la fonction watch (yum install inotify-tools) | ||
+ | |||
<code c> | <code c> | ||
#!/bin/bash | #!/bin/bash | ||
Ligne 7: | Ligne 9: | ||
cd / | cd / | ||
mkdir -p archives | mkdir -p archives | ||
+ | mv *.jpg archives | ||
while watch -g -n 10 -d ls -l *.jpg 2>&1 >/ | while watch -g -n 10 -d ls -l *.jpg 2>&1 >/ | ||
do | do | ||
Ligne 15: | Ligne 18: | ||
exit 0 | exit 0 | ||
</ | </ | ||
+ | avec un test horaire | ||
+ | <code c> | ||
+ | # | ||
+ | cd / | ||
+ | mkdir -p archives | ||
+ | mv *.jpg archives | ||
+ | while true | ||
+ | do | ||
+ | currenttime=$(date +%H:%M) | ||
+ | if [[ " | ||
+ | while watch -g -n 10 -d ls -l *.jpg 2>&1 >/ | ||
+ | do | ||
+ | cp *.jpg / | ||
+ | mv *.jpg archives | ||
+ | sleep 10 | ||
+ | done | ||
+ | else | ||
+ | sleep 60 | ||
+ | fi | ||
+ | done | ||
+ | exit 0 | ||
+ | </ | ||
+ | et avec un lancement et archivage , script pour crontab qui tue les process et ses enfants ... | ||
+ | <code c> | ||
+ | # | ||
+ | pkill -P `pgrep ane_photo.sh` | ||
+ | killall -9 ane_photo.sh | ||
+ | currentdate=$(date +%F) | ||
+ | cd / | ||
+ | tar cvfz $(date +%F)_ane.tgz --remove-files *jpg 2>&1 > /dev/null | ||
+ | / | ||
+ | exit 0 | ||
+ | </ | ||
<code c> | <code c> | ||
/* | /* | ||
| | ||
Blog: http:// | Blog: http:// | ||
- | modif gepeto@du-libre.org 2023 | + | Twitter: |
*/ | */ | ||
#include " | #include " | ||
Ligne 27: | Ligne 62: | ||
#include " | #include " | ||
#include < | #include < | ||
- | #include < | + | //#include < |
+ | #include < | ||
#include " | #include " | ||
Ligne 41: | Ligne 78: | ||
#define PIN_LED | #define PIN_LED | ||
- | char* ftp_server = " | + | char* ftp_server = " |
- | char* ftp_user = "espcam"; | + | char* ftp_user = "blabla"; |
char* ftp_pass = " | char* ftp_pass = " | ||
char* ftp_path = "/ | char* ftp_path = "/ | ||
- | |||
int frequence = 1 ; // minutes | int frequence = 1 ; // minutes | ||
- | const char* WIFI_SSID = "blabla"; | + | const char* WIFI_SSID = "ap1"; |
- | const char* WIFI_PASS = "blabla"; | + | const char* WIFI_PASS = "passap1"; |
+ | const char* AP1 = " | ||
+ | const char* PASSAP1 = " | ||
+ | const char* AP2 = " | ||
+ | const char* PASSAP2 = " | ||
WiFiUDP ntpUDP; | WiFiUDP ntpUDP; | ||
Ligne 79: | Ligne 119: | ||
#define BUFFSIZE 512 | #define BUFFSIZE 512 | ||
#define AVIOFFSET 240 // AVI main header length | #define AVIOFFSET 240 // AVI main header length | ||
+ | |||
+ | WiFiMulti wifiMulti; | ||
void setup() { | void setup() { | ||
Ligne 84: | Ligne 126: | ||
Serial.begin(115200); | Serial.begin(115200); | ||
+ | wifiMulti.addAP(AP1, | ||
+ | wifiMulti.addAP(AP2, | ||
- | | + | |
- | + | Serial.println("" | |
- | | + | |
- | while (WiFi.status() != WL_CONNECTED) { | + | |
- | | + | Serial.println(WiFi.localIP()); |
- | Serial.println(" | + | |
} | } | ||
- | Serial.println(" | ||
- | Serial.println(WiFi.localIP()); | ||
- | | ||
#include " | #include " | ||
#include " | #include " | ||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, | WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, | ||
- | initCamera(); | + | initCamera(); |
sensor_t * s = esp_camera_sensor_get(); | sensor_t * s = esp_camera_sensor_get(); | ||
s-> | s-> | ||
Ligne 136: | Ligne 175: | ||
void loop() { | void loop() { | ||
+ | if (wifiMulti.run() != WL_CONNECTED) { | ||
+ | Serial.println(" | ||
+ | delay(10000); | ||
+ | Serial.println(" | ||
+ | ESP.restart(); | ||
+ | } | ||
timeClient.update(); | timeClient.update(); | ||
delay(5000); | delay(5000); | ||
Ligne 229: | Ligne 274: | ||
esp_camera_fb_return(fb); | esp_camera_fb_return(fb); | ||
} | } | ||
- | |||
</ | </ |