Now I have my pictures avaliable in my web host area, I am still unable to get the url link in the app to work, any ideas?
Which widget are you using?
What image format are you using?
Can you share the URL to one of your images?
Pete.
Pete,
I am using the image gallery widget.
Picture format is .jpg
I think I have solved it. It was due to there being a space either side of the hyphon in the file name that the PHP script creates:
$received = file_get_contents('php://input');
$fileToWrite = "timelapse/upload - ".time().".jpg";
file_put_contents($fileToWrite, $received);
exit();
?>
When changed to the following the url loink shows the picture:
$received = file_get_contents('php://input');
$fileToWrite = "timelapse/upload-".time().".jpg";
file_put_contents($fileToWrite, $received);
exit();
?>
Now I need to try and work out how change the script so that it overwrites the last file with the same name, so that the widget will always show the most up to date picture.
Thank you
Yes, even a little whitespace can ruin an entire script. And if you want to put some spaces then you need to parse the URL properly. Like for spaces, â%20â is used while parsing URLs.
Now, to solve your second problem to overwrite the last file, you simply need to remove the time() function from the file name. Like this -
$fileToWrite = "timelapse/upload-image.jpg";
This will automatically overwrite the existing file on the server
There were some issues with the image gallery widget locally caching images, so when the source changed the displayed image didnât. Iâm not sure if these have been resolved or not.
I think the solution was to update the widgetâs URL from code, but youâd need to search the forum for the details if youâre having issues.
Pete.
Just a coincidence, but this may be helpful: ESP32-CAM and Blynk -> FTP upload đ¸
You will need to use the SIM800 AT Commands (If available/implemented) to upload via FTP.
@Vishal_Roy , Thank you for providing that code, much appreciated! I was trying to remove the time stamp element myself, but was not getting the desired result. My PHP skills leave alot to be desired. It works exactly as required now.
@PeteKnight , I am facing the issues you mention. From searching around it seems like the issue should be resolved by putting in:
Blynk.setProperty(V5, "urls", "http://myhosting.co.uk/timelapse/upload-image.jpg");
This does not have the effect of refreshing the widget. If I close down the app and open it up again, the recent picture is displaid. Whilst this makes it work, it is not very slick. Any thoughts?
@ldb, I will have look through your post , thanks for suggesting it! Many different ways to achieve the same end result, as always with micro controllers!
Thank you
Iâve not really used the widget much, and when I have itâs been via Node-Red, but the documentation says:
you can fully replace the list of images from the hardware:
Blynk.setProperty(V1, "urls", "https://image1.jpg", "https://image2.jpg");
or you can change individual image by it index:
Blynk.setProperty(V1, "url", 1, "https://image1.jpg");
It seems to me that you should be using the âurlâ syntax, not âurlsâ.
Pete.
@PeteKnight, Have given the âurlâ syntax a go and still no luck:
Blynk.setProperty(V5, "url", 1, "http://myhosting.co.uk/timelapse/upload-image.jpg");
All previous posts I have found from searching indicate that it used to be an issue, that got resolved.
In the example I shared above it includes a working implementation, which is url
when changing a single URL, however the key thing to overcome the cache problem is to change the URL, on my example i have included the Unix time at the end:
For example:
String pic_name = "mypicture" + String(now()) + ".jpg";
// UPLOAD the picture named above and change the Blynk URL
String pic_url = "http://myhosting.co.uk/timelapse/" + pic_name;
Blynk.setProperty(V5, "url", 1, pic_url);
@ldb, Thank you for the advice, although I am not sure that this would work for me as I am using two ESP32âs, one just for the camera, and the other is the main controller which is connected to blynk app. The main controller gives a digital output to trigger the ESP32 camera to take a picture.The main controller is using GSM and triggers te ESP32 camera to take a picture. The ESP32 camera is currently on my home WiFi, but one of my next steps is to make that work on GSM also. the final application will be mobile so GSM is a must. If i was to rename the file before uploading, the main ESP does not have any way of knowing what the file name would be. By keeping the file name the same, it gets me around that issue, but not the cache issue.
Thank you
Well⌠Are you transfering the picture file from one ESP32 to the other? Which one is uploading, itâs not clear.
Anyway, to overcome the cache problem an unique URL/filename strategy can be used.
ESP32 cam is taking picture and uploading to url, over wifi curently.
Main ESP32 is the Blynk unit and is triggering the ESP32 cam to take a picture when Blynk app button is pushed.
Working out how to get the two ESPâs to communciate locally, and agree on a unique image name each time could be the way forwardâŚ
Connect both ESP32 together via UART, I2C, ESP-NOW, Bluetooth, via Blynk BridgeâŚ
Why not let the ESP thatâs taking the photos handle the naming, and also update the URL in the app, using Blynk Bridge or the API?
Pete.
I am making progress with a serial link between the two ESP32âs, and now have a number being sent from the main ESP to the ESP camera. I have just realised that it is my PHP script that is handling the image file name, not the ESP32 camera. So sending an image number is not going to help me here, need a rethink.
Thers an example earlier in the thread of how to append the current timestamp to the file name in the ESP, and itâs a simple task to change your PHP to stop it renaming your files on the server.
I think youâre making it far too complex by doing the serial connection, far easier to update Blynk directly as I suggested earlier.
Pete.
Is there a reason for using the two ESP32 devices?
I have used a single RPi (Zero) with the Pi Cam to handle all the video (would work for photo as well), streaming of said video and Blynk scripting (to control the image ON/OFF, BrightPi LED control, and even Pan & Tilt for awhile), all on the single device.
Eventually I will get around to finalising my DIY Wireless Doorbell Camera and may post it in the forum (if it still uses Blynk)
@Gunner, The main reason for using two ESP32 devices is that I can use the ESP32 camera as a module to my main ESP32 board. I am not sure that I could integrate the components into my main ESP32 quicker or cheaper than doing it this way. The amount of I/O pins that i am using on my main ESP32 means that I do not have the required spare either to add the camera.
@PeteKnight, I have got this far by copying and modifying existing examples so far, without fully understanding them. Whilst this gets me some results, it often presents complex issues when it comes to changing how they fundamentally work. Thank you for the pointer of stopping the PHP script renaming the file. I guess if I can get the two ESPâs to sync the file name and change it each time, it should have the desired effect.
My main goal is to build an alarm system to go into the back of a van, to detect a break in. The purpose of the camera is to allow the user to take a picture of the back of the van if the alarm triggers to verify wether or not the alarm is genuine or not. The whole system will need to run off of GSM (SIM800), I am hoping to setup the system so that one GSM modem can service the needs of the alarm system reporting to Blynk, and also the camera module being able to upload the picture when required.
I am currently only running Blynk on my main ESP32, not the ESP32 camera. The ESP32 camera takes a picture and uploads it when the main ESP32 triggers it.
I may be suffering from modifying my design on the fly and finding I am down a route that is not the most suitable. I think I need to take a step back and work out what is the best way to integrate the camera function into the alarm system.
Thank you for your input, much appreciated
I think you should be able to use bridge to link the two and then use a virtual pin to send the file name from one to the other.