# 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:** 20\
**Page:** 1

<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:** [30 September 2022 19:38 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/1 "2022-09-30T19:38:42Z")

</div>

Hi, I am trying to take pictures with my Pi Zero and a simple Pi camera.  
Flow is as below:

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

When I run it that is what I get on debug window:

> object  
> \_msgid: "d3493c077845a223"  
> payload: ""  
> topic: ""  
> filename: ""  
> fileformat: ""  
> filepath: ""

Now I tested the pi/camera from a pi terminal as below:

> sudo raspistill -o testshot.jpg

And got:

> -rw-r--r-- 1 root root 2415852 Sep 30 16:36 testshot.jpg

Have checked raspi-config and camera is enabled.

What might still be missing?

---

<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:** [1 October 2022 02:05 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/2 "2022-10-01T02:05:03Z")

</div>

You could use an exec node configured with the raspistill command, for testing purposes. Which node exactly is the one that takes the picture (the one in the middle in your screenshot) ?

---

<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:** [1 October 2022 08:51 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/3 "2022-10-01T08:51:03Z")

</div>

> [@pcborges](#):
>
> Now I tested the pi/camera from a pi terminal as below:
> 
> > sudo raspistill -o testshot.jpg
> 
> And got:
> 
> > -rw-r--r-- 1 root root 2415852 Sep 30 16:36 testshot.jpg

Do you really need sudo to run raspistill?  
You are creating an image file owned by root, so any further processing of it, housekeeping etc, will need sudo as well.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 October 2022 11:25 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/4 "2022-10-01T11:25:39Z")

</div>

indeed - don't use sudo - it won't work inside an exec node either.

If it is this node - [node-red-contrib-camerapi (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-camerapi) - have you installed and checked the pre-reqs ?

---

<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 14:34 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/5 "2022-10-01T14:34:11Z")

</div>

Hi, thanks for your feedback.  
First I installed [node-red-contrib-camerapi] from Node-Red manage palette, updated and run  
sudo apt-get install python-picamera python3-picamera (according to instructions on: [node-red-contrib-camerapi (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-camerapi) and there is where I am now.

Now, what do you mean by not using sudo?  
How I go back and repair it from where I am now?  
Thanks

Just reinstalled the whole set:  
Raspberry Pi, updated, Node-red, node-red-contrib-camerapi, updated again, sudo apt-get install python-picamera python3-picamera  
Problem remains identical.  
I must be missing something very simple, can't find a solution everywhere I looked.

A footnote on the instruction page I mention above says:  
This node is tested on RASPBIAN (buster), Nodejs V12.x LTS and NPM 6.x on Node-Red 1.0.6  
The script that installs Node-Red installed Nodejs v16.17.0  
Installed NPM as well but no change.

---

<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:** [1 October 2022 15:02 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/6 "2022-10-01T15:02:35Z")

</div>

> [@pcborges](#):
>
> Now, what do you mean by not using sudo?

You said "Now I tested the pi/camera from a pi terminal as below:"

> sudo raspistill -o testshot.jpg

You used sudo to launch the command raspistill.  
Apologies if you already know this but...  
On the Bash command line you can run a command by just entering it's name.  
For example the **whoami** command

```auto
pi@MyPi:~ $ whoami
pi

```

But sometimes the "pi"user does not have permission to use a command

```auto
pi@MyPi:~ $ fdisk -l
fdisk: cannot open /dev/sda: Permission denied
(etc)

```

So you can use sudo to run a command as the all powerfull "root" user  
pi@MyPi:~ $ sudo whoami  
root

Beginners occasionally think that they have to use sudo to run every command.  
It is a really bad idea because your directories can get clogged up with files owned by root, whose presence can prevent normal operations.

Edit -  
On your newly installed Pi run these commands:

```auto
cd 
raspistill -o anothertest.jpg
echo $?
ls -l anothertest.jpg

```

In Node-red, use an Exec node to execute **raspistill -o yetanothertest.jpg**  
Use a debug node to show the returned message (the first output) and any error (the second output)

Show us the results  
Does the file get created?

---

<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 15:07 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/7 "2022-10-01T15:07:41Z")

</div>

> [@jbudd](#):
>
> Beginners occasionally think that they have to use sudo to run every command.

That is me!  
Thanks

Now, do you think this problem is caused by that?  
In fact after I reinstalled everything I did not test the camera again.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [1 October 2022 15:10 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/8 "2022-10-01T15:10:43Z")

</div>

I think what @jbudd is saying is try this command in a terminal window / command line...

`raspistill -o testshot.jpg`

And then perform an `ls -al` and see what the ownership is.

---

<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 15:13 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/9 "2022-10-01T15:13:28Z")

</div>

Just did that:

pi@picamera:~ $ raspistill -o testshot.jpg  
pi@picamera:~ $ ls  
testshot.jpg  
pi@picamera:~ $ ls -l  
total 2104  
-rw-r--r-- 1 pi pi 2154070 Oct 1 16:11 testshot.jpg  
pi@picamera:~ $

When I performed this test before I uploaded the testshot.jpg and chcked the image and it corresponds to what was expected.

Sorry, I did not know ls -al and used ls -l (that I am used to) but checked the info about this specific file was 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:** [1 October 2022 15:18 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/10 "2022-10-01T15:18:58Z")

</div>

So that confirms that raspistill works without sudo.

I would expect that it works from Node-red using the exec node too.

If it does, then you can test the camerapi node.

> Now, do you think this problem is caused by that?

It seems unlikely but it's not impossible.

And **ls -al** is the same as **ls -l** but it also shows ""hidden" files - those whose name starts with a dot

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [1 October 2022 15:19 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/11 "2022-10-01T15:19:40Z")

</div>

> [@pcborges](#):
>
> Sorry, I did not know ls -al and used ls -l

`ls -al` means give me a long listing. Shows you the ownership, permissions, file size and creation date.

---

<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 15:27 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/12 "2022-10-01T15:27:24Z")

</div>

> [@pcborges](#):
>
> raspistill -o testshot.jpg

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3a09f503aed3f390dc9bd0bd77c8dda5c9b0a09c.png)

pi@picamera:~ $ ls -l  
total 4320  
drwxr-xr-x 27 pi pi 4096 Oct 1 16:24 node\_modules  
-rw-r--r-- 1 pi pi 8338 Oct 1 16:24 package-lock.json  
-rw-r--r-- 1 pi pi 2154070 Oct 1 16:11 testshot.jpg  
-rw-r--r-- 1 pi pi 2251991 Oct 1 16:25 testshotNew.jpg

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/935897ab1f81d037dbdd7ddec4f96ca70d61d96e.png)

---

<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:** [1 October 2022 15:33 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/13 "2022-10-01T15:33:24Z")

</div>

OK, it looks like the raspistill command doesn't give any useful success message - many Linux commands (deliberately) are silent if they succeed. So the empty output from the exec node isn't a sign of failure.

Probably the camerapi node actually calls raspistill, so it's blank output is not necessarily a bad sign either. But the node help does say this " **msg.payload** will give you the path and the filename including extension to the photo."  
Has camerapi created an image file?

---

<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 15:40 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/14 "2022-10-01T15:40:41Z")

</div>

Has camerapi created an image file?

-rw-r--r-- 1 pi pi 2251991 Oct 1 16:25 testshotNew.jpg  
Yes, it is there

---

<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:** [1 October 2022 15:45 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/15 "2022-10-01T15:45:06Z")

</div>

That's the file created by the exec node. Same size, same time

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [1 October 2022 15:46 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/16 "2022-10-01T15:46:37Z")

</div>

You could try using a 'file-in' node and the image node to see if you can "see" the image you captured.  
 ![image_preview](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ad71d9e6daa6b854a85563208d1ff3769df26821.png)

Image preview node is... node-red-contrib-image-output (Really useful for doing quick tests).

You need to insert the path to where the file is located in the file-in node.  
e.g.` /home/pi/testshotNew.jpg`

You also need to set the 'read-file' node settings to be a 'single Buffer object'  
 ![file_in_settings](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f4d7b40b413e5dfb7087eaf698f90db1df5d9e27.png)

---

<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:** [1 October 2022 17:19 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/17 "2022-10-01T17:19:30Z")

</div>

> [@pcborges](#):
>
> Just reinstalled the whole set:  
> Raspberry Pi, updated, Node-red, node-red-contrib-camerapi, updated again, sudo apt-get install python-picamera python3-picamera  
> Problem remains identical.

Just to double check, which Rasberry Pi OS have you installed ? As far as I know the picamera library (which the installed node seems to use) would not run on 64-bits. So far we know that your hardware os good and you can capture picture with raspstill, which is good.

---

<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:02 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/19 "2022-10-01T18:02:09Z")

</div>

> [@pcborges](#):
>
> -rw-r--r-- 1 pi pi 2154070 Oct 1 16:11 testshot.jpg  
> -rw-r--r-- 1 pi pi 2251991 Oct 1 16:25 testshotNew.jpg

-rw-r--r-- 1 pi pi 2154070 Oct 1 16:11 testshot.jpg -------\>from terminal prompt  
-rw-r--r-- 1 pi pi 2251991 Oct 1 16:25 testshotNew.jpg ---\> From Node-Red exec

Camera not precisely positioned in the same place .

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [1 October 2022 18:23 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/20 "2022-10-01T18:23:16Z")

</div>

So it would appear you have it working 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 18:31 UTC](https://discourse.nodered.org/t/why-does-my-pi-zero-with-node-red-cannot-take-pictures/68428/21 "2022-10-01T18:31:43Z")

</div>

Hi Andrei, did not know that.  
I am rebuilding everything with 32bit Pi OS.  
Thanks

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