asmaklad / TeleView

A telegram photo sending bot using the ESP32 CAM on Arduino IDE.
GNU Lesser General Public License v2.1
20 stars 8 forks source link

I can´t access with telegram #2

Closed anmorfe closed 3 years ago

anmorfe commented 3 years ago

I have instaled the sketch properly in esp32 cam as a esp CAMERA_MODEL_AI_THINKER, no errors, i have configured the telegram token and the chat id, but the telegram bot doesn´t shows anything... Could you tell me what is the problem...? The esp32 cam was bought in aliexpress, but the sketch didn`t show any problem...

anmorfe commented 3 years ago

There is some kind of problem with telegram comunication...

asmaklad commented 3 years ago

Hi anmorfe. Have you tried to connect the board to the Serial port and check what kind of errors it shows ? Is the wifi connected ? have you tried the Arduino IDE's Sample sketch first ? regards

anmorfe commented 3 years ago

Yes, Serial port doesn't shows problems, And i have tried this seketch and works properly, but it's very simple. https://randomnerdtutorials.com/telegram-esp32-cam-photo-arduino/

Your sketch is loaded properly via arduino ide, the board creates the access point, I can connect to my wifi but it seems that doesn't connet to telegram. Thank you in advance.

anmorfe commented 3 years ago

I have tried this one too https://github.com/fustyles/Arduino/blob/master/ESP32-CAM_PIR_Telegram/ESP32-CAM_PIR_Telegram.ino

and via serial it shows : "Connected to api.telegram.org failed"

anmorfe commented 3 years ago

This is the serial monitor output:

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:10944 load:0x40080400,len:6388 entry 0x400806b4 Compile Date:Apr 20 2021 Compile Time:11:49:20 Compile Compiler:201103

[["/start", "/options"],["/sendPhoto"],["/vflip", "/hmirror", "/setlapse", "/webCaptureOn"],["/useFlash"],["/QQVGA","/QQVGA2","/QCIF","/HQVGA","/QVGA","/CIF"],["/VGA","/SVGA","/XGA","/SXGA","/UXGA","/QXGA"],[]] found settings prefrences. Attribute | Value

Device Name      |TeleView
useFlash         |true
hMirror          |true
vFlip            |true
webCaptureOn     |true
frameSize        |13,,
adminChatIds     |***********
userChatIds      |0123456789
lapseTime        |60
timeZone         |Europe/Berlin
Last Photo taken |UNKNOWN 

populateResolutionsSelects#4 mDNS responder started WiFi connected: 192.168.1.143 JAZZTEL_E4 RSSI:-43 WiFi MAC: B0:AD:C8:1F:9C:9C IP address: 192.168.1.143 I am Alive!!

anmorfe commented 3 years ago

Telegram bot doesn't respond to /start command

asmaklad commented 3 years ago

just a guess, this line doesn't seem right : frameSize |13,,

can you please adjust it in the UI ?

maybe VGA is fine. frameSize |6,VGA,640x480

asmaklad commented 3 years ago

Also check if the adminchatIds has a space or anyother hidden char . like tab or something.

anmorfe commented 3 years ago

ok, I'm trying it

anmorfe commented 3 years ago

it doesn't work....

I have change the frame size and the bot token i correct, no results:

ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:10944 load:0x40080400,len:6388 entry 0x400806b4 Compile Date:Apr 20 2021 Compile Time:11:49:20 Compile Compiler:201103

[["/start", "/options"],["/sendPhoto"],["/vflip", "/hmirror", "/setlapse", "/webCaptureOn"],["/useFlash"],["/QQVGA","/QQVGA2","/QCIF","/HQVGA","/QVGA","/CIF"],["/VGA","/SVGA","/XGA","/SXGA","/UXGA","/QXGA"],[]] found settings prefrences. Attribute | Value

Device Name      |TeleView
useFlash         |true
hMirror          |true
vFlip            |true
webCaptureOn     |true
frameSize        |6,VGA,640x480
adminChatIds     |*********
userChatIds      |**********
lapseTime        |60
timeZone         |Europe/Berlin
Last Photo taken |UNKNOWN 

populateResolutionsSelects#4 mDNS responder started WiFi connected: 192.168.1.143 JAZZTEL_E4 RSSI:-39 WiFi MAC: B0:AD:C8:1F:9C:9C IP address: 192.168.1.143 I am Alive!!

anmorfe commented 3 years ago

I think there is a problem about comunication between module and telegram bot...

asmaklad commented 3 years ago

ok if you think the communication with Telegram is the problem: Can you use web telegram on the same wifi network as your ESP32-CAM module ? does this link work https://web.telegram.org/ on your pc ?

asmaklad commented 3 years ago

are you using any proxy ? or middle entities in your wifi lke pi-hole or something ?

asmaklad commented 3 years ago

double check the bot token

asmaklad commented 3 years ago

in the file TeleView/UniversalTelegramBot.h , change line 92 to bool _debug = true; if you have problems with Telegram , then you should see it as in UniversalTelegramBot.cpp lines 57 to 62

anmorfe commented 3 years ago

ok if you think the communication with Telegram is the problem: Can you use web telegram on the same wifi network as your ESP32-CAM module ? does this link work https://web.telegram.org/ on your pc ?

I'm using web telegram on the same wifi network Yes, Telegram web works properly

anmorfe commented 3 years ago

are you using any proxy ? or middle entities in your wifi lke pi-hole or something ?

no proxies

anmorfe commented 3 years ago

after change debug option, serial monitor shows:


populateResolutionsSelects#4
mDNS responder started
WiFi connected: 192.168.1.143
JAZZTEL_E4
RSSI:-35
WiFi MAC: B0:AD:C8:1F:9C:9C
IP address: 192.168.1.143
SEND Post Message
[BOT Client]Connecting to server
[BOT Client]Conection error

[BOT Client]Connecting to server
[BOT Client]Conection error

[BOT Client]Connecting to server
[BOT Client]Conection error

[BOT Client]Connecting to server
[BOT Client]Conection error

[BOT Client]Connecting to server
[BOT Client]Conection error

[BOT Client]Connecting to server
[BOT Client]Conection error

[BOT Client]Connecting to server
[BOT Client]Conection error
anmorfe commented 3 years ago

I have tried to connect to the router directly via wifi (i have a wifi repeater), this is the output in serial monitor

I am Alive!! GET Update Messages [BOT]Connecting to server [BOT]Conection error Received empty string in response! GET Update Messages [BOT]Connecting to server [BOT]Conection error Received empty string in response! GET Update Messages [BOT]Connecting to server [BOT]Conection error Received empty string in response! GET Update Messages [BOT]Connecting to server [BOT]Conection error Received empty string in response! GET Update Messages

anmorfe commented 3 years ago

captura

I don't know if this information could be usefull...

anmorfe commented 3 years ago

I have tried using my phone as an access point... Same result: GET Update Messages [BOT]Connecting to server [BOT]Conection error Received empty string in response!

asmaklad commented 3 years ago

then can you please double check the bot token or even create a new one

anmorfe commented 3 years ago

I have revoke the token, even create a new one. No results.

asmaklad commented 3 years ago

let me sleep on it .. I will think about it.

anmorfe commented 3 years ago

Ok. I'm very grateful for your interest. I think your code is amazing... if I'm able to make it works... ;). I'm trying to make a cheap security system for my second house, conecting a pir sensor to the esp32-cam. We live there only few days every month, and this sektch seems to be all that I'm looking for.

I have found another programs but no one like yours.

asmaklad commented 3 years ago

Ok , I think I got to the bottom of this. I have a running board that is perfectly working fine. when I try to upload the code to a new board , I get similar errors. it is partially fixed when I add the "botClient.setInsecure()" and the board can send and receive messages, but it fails in sending photos ! again error with the ssl_client.cpp:301 with some sort of UNKNOWN ERROR.. It seems there is a bug in the current ESP32 library version 1.0.6 Please follow these instructions to downgrade the version of the ESP32 Board Libraries: 1) in the menu "Tools" -> Board (xyz) -> Board Manager 2) in the search box type "ESP32" 3) got to the "select version" combox and select the version "1.0.4" 4) recompile and upload please test and feed me back so I can update the README file.

anmorfe commented 3 years ago

Have a good day;

I have been trying to change the telegram_utils.h by adding "botClient.setInsecure()" and this is the result: image

However, I have noticed that if I downgrade the ESP32 library to 1.0.4, the code works perfectly without adding this line "botClient.setInsecure()" BUT.....it seems that the SSID and the password aren't saved properly when they are grabbed in web page AutoConnect... I mean, firstly i load the sketch to the board, the board creates an access point named Teleview, then I connect my phone to this ap and I can configure all the parameters (SSID and password), but when I reset the board or unplug and plug the power cord, I notice that SSID and password weren't loaded properly.... Really, the SSID and password are saved in web page "Open SSIDs". Every time i unplug the powercord, i have to ccess to te AP Teleview and reconfigure the parameters SSID and pasword. Really, I don't know if this is a normal behavior.... But I think is more confortable to configure this parameters only one time

anmorfe commented 3 years ago

About using a pir, i have added to the camera_pins.h a line like that

define PIR_PIN 13

And obviusly, I have connect the signal pin to the pin 13 in esp32-cam But when a load the code with this change it detects movement and send photos continuously.... I don't know if the line #define BUTTON_PIN 34 is needed, but I didn't added

asmaklad commented 3 years ago

Losing the SSID credentials is not a normal behavior. I am just guessing here , please try these: 1) I have AutoConnect Library version 1.1.3 and ArduinoJson Library version 5.13.5 can you please align to these versions ? 2) I sometimes have similar behavior , but I think after several reboots or using the reset button , it works.

to stop motion detection you have to set it to false from the Telegram Keyboard or type "/motDetectOn" case sensitive . if you can't see the Telegram keyboard , then type "/start" or "/options" and then you can just click the button you want. image

as for the #define BUTTON_PIN 34 it is not needed. The code doesn't use it currently. but I just put there to in case I decide to use it in the future.

asmaklad commented 3 years ago

Try also to setup the ArduinoIDE as Follows in the Tools menu: (Except the board type) image

anmorfe commented 3 years ago

I don't know if I explained well, when I configure the pin 13 to receive the signal from pir, the telegram bot send every few seconds "motion detection" and send an image, even there is no movement.

anmorfe commented 3 years ago

Try also to setup the ArduinoIDE as Follows in the Tools menue: image

ok

asmaklad commented 3 years ago

I don't know if I explained well, when I configure the pin 13 to receive the signal from pir, the telegram bot send every few seconds "motion detection" and send an image, even there is no movement.

have you added a pull up or pull down resistor to the PIR ?

anmorfe commented 3 years ago

I don't know if I explained well, when I configure the pin 13 to receive the signal from pir, the telegram bot send every few seconds "motion detection" and send an image, even there is no movement.

have you added a pull up or pull down resistor to the PIR ?

no...

asmaklad commented 3 years ago

I understand you use the Board "AI Thinker ESP32-CAM" according to this : https://randomnerdtutorials.com/esp32-cam-pir-motion-detector-photo-capture/ you need a power down or up resistor ( I don't know how to identify it) image

anmorfe commented 3 years ago

I understand you use the Board "AI Thinker ESP32-CAM" according to this : https://randomnerdtutorials.com/esp32-cam-pir-motion-detector-photo-capture/ you need a power down or up resistor ( I don't know how to identify it) image

Ok

asmaklad commented 3 years ago

is the SSID problem resolved yet ?

anmorfe commented 3 years ago

Try also to setup the ArduinoIDE as Follows in the Tools menue: image

ok

This configuration works but same results with wifi credentials

anmorfe commented 3 years ago

could i use pinMode(PIN_PIR, INPUT_PULLUP); ???

asmaklad commented 3 years ago

for the PIR issue, some one asked the same questions last year and I see I gave him a similar answer: https://github.com/asmaklad/TeleView/issues/1 It should be a PULL_DOWN Try this maybe it works with softwear only: in TeleView.ino, change the line 230 "pinMode(PIR_PIN, INPUT); " to pinMode(PIR_PIN, INPUT_PULLDOWN ); Who knows , maybe we learn something new today.

asmaklad commented 3 years ago

I don't know why the AutoConnect Lib it doesn't save the SSID if the SSID issue is still persistent, then try the following: we need basicly to program that SSID, pass in the ESP32 rom . it keeps record of the last 10 connected WIFI. so we need to establish the connection once and then it should remember it on its own. got to the menu "File"-> "Examples" -> "WebServer" -> "HelloServer"

change the line to hardcode your wifi: const char ssid = "........"; const char password = "........";

then compile and upload HelloServer to your board,

then compile and upload Teleview sketch again.

anmorfe commented 3 years ago

for the PIR issue, some one asked the same questions last year and I see I gave him a similar answer:

1

It should be a PULL_DOWN Try this maybe it works with softwear only: in TeleView.ino, change the line 230 "pinMode(PIR_PIN, INPUT); " to pinMode(PIR_PIN, INPUT_PULLDOWN ); Who knows , maybe we learn something new today.

PULLDOWN isn't recognized, only pullup.....what a pitty image

image

asmaklad commented 3 years ago

sorry about that. that is why you will have to do circuit I sent earlier.

or you could use this board : https://www.aliexpress.com/item/32995230085.html?spm=a2g0o.productlist.0.0.24e61f80B4job9&algo_pvid=14f6b00e-d76c-4ba6-bebf-42587f9bffdb&algo_expid=14f6b00e-d76c-4ba6-bebf-42587f9bffdb-0&btsid=0b0a556d16190923870365488eec94&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

asmaklad commented 3 years ago

Wait a sec... It compiles with PULLDOWN ... forget about ArduinoIDE's syntax highlight ..

anmorfe commented 3 years ago

I have tried it. It doesn't work. PULLDOWN doesn't detect movement and PULLUP detect movement every few seconds without real movement

asmaklad commented 3 years ago

question,. you sensor sends 1(HIGH) when detecting motion or 0 (LOW) ? if it sends 1 all the time then you need to make pullup and only detect the LOW state : THEN-> PINMODE = INPUT_PULLUP and line TeleView.ino:238 should have "!digitalRead(PIR_PIN)"

if it sends 0 all the time then you need to make PULLDOWN and only detect the HIGH state : (current state of the code) THEN-> PINMODE = INPUT_DOWN and line TeleView.ino:238 should have "digitalRead(PIR_PIN)"

anmorfe commented 3 years ago

question,. you sensor sends 1(HIGH) when detecting motion or 0 (LOW) ? if it sends 1 all the time then you need to make pullup and only detect the LOW state : THEN-> PINMODE = INPUT_PULLUP and line TeleView.ino:238 should have "!digitalRead(PIR_PIN)"

if it sends 0 all the time then you need to make PULLDOWN and only detect the HIGH state : (current state of the code) THEN-> PINMODE = INPUT_DOWN and line TeleView.ino:238 should have "digitalRead(PIR_PIN)"

I have tried PULLUP and "!digitalRead(PIR_PIN)", no results. Same problem with WiFi credentials. Curiously, if I use ArduinoJson 1.0.6 it saves the credentials...

asmaklad commented 3 years ago

ok just to keep track and document this later in the README :

Problem Description Solution
Unable to connect to Telegram downgrade ESP32 library to version 1.0.4
SSID credentials not saved downgrade Arduino JSON to ArduinoJson 1.0.6
anmorfe commented 3 years ago

I can`t understand why this code works https://github.com/fustyles/Arduino/blob/master/ESP32-CAM_PIR_Telegram/ESP32-CAM_PIR_Telegram.ino , and your code doesn't work.... I have a HC-SR501, always low unless it detects movement. In the other code, the author use INPUT_PULLUP: image

asmaklad commented 3 years ago

me neither. try this in https://github.com/asmaklad/TeleView/blob/master/TeleView.ino

in setup() line 229

if defined(PIR_PIN)

pinMode(PIR_PIN, INPUT_PULLUP) ; // the logical thing to work is INPUT_PULLDOWN .. but who knows !

endif

in loop() line 237

if defined(PIR_PIN)

int vPIR = digitalRead(pinPIR); Serial.print("PIR VALUE:"); Serial.println(vPIR ); if ( configItems.motDetectOn && vPIR==HIGH )) { Serial.println("Motion Detected."); bot.sendMessage(configItems.adminChatIds, "Motion Detected!","" ); String restult= sendCapturedImage2Telegram(configItems.adminChatIds); Serial.println("restult: "+restult); delay(100); }

endif