# Why does my Pi Zero with Node-Red cannot take pictures

**URL:** <https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428>\
**Category:** General\
**Created:** [30 September 2022 19:38 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428 "2022-09-30T19:38:42Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [1 October 2022 18:32 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/22 "2022-10-01T18:32:43Z")

</div>

Not from Node-Red camera node.  
Trying to rebuild using 32bit now.

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [1 October 2022 22:34 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/23 "2022-10-01T22:34:08Z")

</div>

> [@pcborges](#):
>
> node-red-contrib-camerapi

I have rebuilt PI from scratch.  
Loaded the following PI OS:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/3/5357d5f1df0bfdef0aa8551df2ccef7ad6c92cde.png)  
After that changed to fix IP, updated, run raspi-config and did the following adjustments:  
On interface options I activated the camera.  
On advanced options I expanded the file system  
And updated the tool.

On Node-Red: ([Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi))  
-sudo apt install build-essential git curl  
-bash \<(curl -sL [https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered](https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered))

Installed the camera support software: ([node-red-contrib-camerapi (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-camerapi))  
-sudo apt-get update  
-sudo apt-get install python-picamera python3-picamera

- npm install node-red-contrib-camerapi  
and installed node-red-contrib-camerapi from Node-Red Manage Pallete.

Test:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e346fd15c04d9ac83067d308b03d804287bf17c1.png)  
Note: TakePhotoNode with default parameters.

Result: Precisely the same!

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [2 October 2022 00:13 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/24 "2022-10-02T00:13:22Z")

</div>

Do you have a directory called Pictures? **ls -d ~/Pictures**  
If not, create one. **mkdir ~/Pictures**

Then try taking a photo via the camerapi node again.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [2 October 2022 04:02 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/25 "2022-10-02T04:02:27Z")

</div>

I installed the node-red-contrib-camerapi node for testing and followed the same steps that @pcborges indicated in a previous post. It did not work and the following error message appeared in syslog:

> Oct 2 00:46:03 pi Node-RED[628]: CameraPi (log): Generate - /home/pi/Pictures/pic\_33af943e-d458-45d0-9b5a-d7c24805309c.jpg  
> Oct 2 00:46:04 pi Node-RED[628]: CameraPi (err): Error: Command failed: python /home/pi/.node-red/node\_modules/node-red-contrib-camerapi/lib/python/get\_photo.py pic\_33af943e-d458-45d0-9b5a-d7c24805309c.jpg /home/pi/Pictures/ jpeg 800 600 0 0 0 50 0 0 none auto 0 1.0 80 0 auto  
> Oct 2 00:46:04 pi Node-RED[628]: Traceback (most recent call last):  
> Oct 2 00:46:04 pi Node-RED[628]: File "/home/pi/.node-red/node\_modules/node-red-contrib-camerapi/lib/python/get\_photo.py", line 52, in   
> Oct 2 00:46:04 pi Node-RED[628]: picfile = open(filefqn, "wb")  
> **Oct 2 00:46:04 pi Node-RED[628]: IOError: [Errno 2] No such file or directory: '/home/pi/Pictures/pic\_33af943e-d458-45d0-9b5a-d7c24805309c.jpg'**

Checking the file system I did not find a Pictures directory, so I created it like @jbudd sugested.

I ran the flow to see that it is working.

Apparently the node author forgot to mention in the doc the need to create the Pictures directory.

 ![t1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/b/0bb97c3c545af0daf75ba5fabb16f1584e78d193.png)

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [2 October 2022 06:21 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/26 "2022-10-02T06:21:57Z")

</div>

If I remember correctly, during the years there has always been a Picture folder there in /home/pi by default. I have them in all my RPi's and I have never created them myself

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 October 2022 07:15 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/27 "2022-10-02T07:15:38Z")

</div>

> [@krambriw](#):
>
> there has always been a Picture folder there in /home/pi by default

I think that may only be true on the desktop versions of the OS. My Pis, which are all the Lite (server) versions, do not have the ~/Pictures folder.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 October 2022 07:30 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/28 "2022-10-02T07:30:19Z")

</div>

@pcborges I built a flow a couple weeks ago to take photos for a timelapse. It uses `node-red-contib-camerapi` on a Pi Zero W running  
Buster,  
node-red v3.0.2,  
node.js v14.20.0  
node-red-contib-camerapi v0.0.39

```auto
pi@camera-1:~ $ cat /proc/device-tree/model
Raspberry Pi Zero W Rev 1.1pi@camera-1:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

```

Here is the flow:

```auto
[{"id":"5685316f627e140b","type":"camerapi-takephoto","z":"8958e63f41e92ad1","filemode":"1","filename":"","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"2","rotation":"0","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"0","agcwait":"1.0","led":"0","awb":"auto","name":"","x":680,"y":200,"wires":[["7011601517f3fb6f","8421fac5b3818f71"]]},{"id":"f54056c633dfa3f5","type":"inject","z":"8958e63f41e92ad1","d":true,"name":"","props":[{"p":"payload"}],"repeat":"","crontab":"*/1 5-7 * * *","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":200,"wires":[["dc1ce270fc4d1918"]]},{"id":"7011601517f3fb6f","type":"debug","z":"8958e63f41e92ad1","name":"debug 1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":860,"y":200,"wires":[]},{"id":"3ede666cc25a7570","type":"catch","z":"8958e63f41e92ad1","name":"","scope":null,"uncaught":false,"x":700,"y":80,"wires":[["deb85a976cfe0ec8"]]},{"id":"deb85a976cfe0ec8","type":"debug","z":"8958e63f41e92ad1","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":920,"y":80,"wires":[]},{"id":"0bccd66021888cb3","type":"inject","z":"8958e63f41e92ad1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":".02","topic":"","payload":"","payloadType":"date","x":140,"y":80,"wires":[["dc1ce270fc4d1918","d41f0bf8e7579189"]]},{"id":"dc1ce270fc4d1918","type":"counter","z":"8958e63f41e92ad1","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"1","x":300,"y":200,"wires":[["eafeebcd091844df"]]},{"id":"eafeebcd091844df","type":"function","z":"8958e63f41e92ad1","name":"build file name","func":"let padded = (msg.count).toString().padStart(5, '0')\nmsg.filename = 'image'+ padded+\".jpg\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":200,"wires":[["5685316f627e140b"]]}]

```

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [2 October 2022 07:44 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/29 "2022-10-02T07:44:06Z")

</div>

Ah OK, that explains it, I have never used anything else than the full versions

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [2 October 2022 09:55 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/30 "2022-10-02T09:55:06Z")

</div>

I did not have /home/pi/Pictures.  
From /home/pi: mkdir Pictures  
Run test again: from Node-Red debug window the view is the same, no data.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/6892b2bfb03883073875c30325d4025e9b67d59e.png)  
As you can see this time the image file was created (although not reported on the debug screen) but it is empty.

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [2 October 2022 09:57 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/31 "2022-10-02T09:57:39Z")

</div>

Hi, run your flow, somehow for me no change.  
Rebuilt the system several times, last as described above.

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [2 October 2022 10:00 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/32 "2022-10-02T10:00:50Z")

</div>

> [@Andrei](#):
>
> It did not work and the following error message appeared in syslog:

Will check that, may be there is something there.  
Thanks

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 October 2022 10:09 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/33 "2022-10-02T10:09:16Z")

</div>

With your rebuilt system are you able to take a picture using the command line (without sudo)?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [2 October 2022 10:17 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/34 "2022-10-02T10:17:11Z")

</div>

> [@pcborges](#):
>
> As you can see this time the image file was created but it is empty.

I got the hint about the Pictures directory from the node's GitHub issues, but there's nothing there about empty files with default node settings.

The camerapi node hasn't been updated for more than 2 years. If it's true that camerapi doesn't work with the mainstream RPiOS (ie 64 bit), I'd be inclined to give up on it and use the exec node.  
You could write a shell script (python is also available if you prefer snakes to snails) wrapper for **raspistill** to get the right output filename, report success etc

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [2 October 2022 10:27 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/35 "2022-10-02T10:27:01Z")

</div>

Hi all, I just checked syslog and found:  
Oct 2 07:12:51 picamera Node-RED[270]: "Camera is not enabled. Try running 'sudo raspi-config' "  
I have been doing this all along but seems I failed to do it on this last rebuild.  
Once I went back to raspi-config and enabled the camera it works perfectly.  
The real problem I believe was the lack of Picture directory.  
Thank you all for your kind and competent support, learned a number of things with you guys.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 October 2022 10:39 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/36 "2022-10-02T10:39:23Z")

</div>

A couple things I noticed

1. It looks like when you did the `npm install node-red-contrib-camerapi` you had not changed to the `.node-red` directory. If you want to manually install a node, you need to first do a `cd .node_red` then run the npm command. You should go to your home directory and issue a `sudo rm -rf node-modules` then remove package.json and package-lock.json

2. you did `sudo apt-get update` but did not do a `sudo apt upgrade`. I suggest you use `sudo apt full-upgrade`

**apt update: updates the package cache (to know which package versions can be installed or upgraded)**  
**apt upgrade: upgrades packages to the new version**.

(you can use 'apt' instead of 'apt-get')

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [2 October 2022 10:44 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/37 "2022-10-02T10:44:30Z")

</div>

> [@zenofmud](#):
>
> If you want to manually install a node, you need to first do a `cd .node_red` then run the npm command.

Did not know that.  
Will also look into number 2.  
Thanks again for your kind support.  
Paulo Borges

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 October 2022 10:54 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/38 "2022-10-02T10:54:53Z")

</div>

> [@zenofmud](#):
>
> sudo apt-full-upgrade

I think that should be  
`sudo apt full-upgrade`

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [2 October 2022 11:17 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/39 "2022-10-02T11:17:48Z")

</div>

> [@Colin](#):
>
> sudo apt full-upgrade

Running now...  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 October 2022 11:18 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/40 "2022-10-16T11:18:26Z")

</div>

Closed on 16 October 2022 11:18 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428.md?page=1)
