# Random number for simulate a machine

**URL:** <https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640>\
**Category:** General\
**Created:** [27 November 2020 18:11 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640 "2020-11-27T18:11:17Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rhum1x56](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Rhum1x56](https://discourse.nodered.org/u/Rhum1x56)\
**Post date:** [27 November 2020 18:11 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/1 "2020-11-27T18:11:17Z")

</div>

Hello, I need help with a school project.  
I am using an HTML POST to send data to nodered. But after some processing, I have BDD errors

I'm looking for how to create a random variable between 1.5 and 4.5 to simulate a machine amperage

I master several languages ​​but not at all java 😕

thanks for your help  
sorry for my english i'm french

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [27 November 2020 18:16 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/2 "2020-11-27T18:16:55Z")

</div>

Node-red-node-random.  
Very flexible random number generator

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 November 2020 18:58 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/3 "2020-11-27T18:58:49Z")

</div>

This can be done with the Change node and JSONata expression. `($random() * 3) + 1.5`

---

<div class="post-metadata">

**Author:** ![Rhum1x56](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Rhum1x56](https://discourse.nodered.org/u/Rhum1x56)\
**Post date:** [27 November 2020 20:50 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/4 "2020-11-27T20:50:15Z")

</div>

> [@gerry](#):
>
> Node-red-node-random.

I can't install Node-red-node-random. i have error, i installed python, it's the same

($ random () \* 3) + 1.5 it's with node-red-node-random ??

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 November 2020 20:56 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/5 "2020-11-27T20:56:01Z")

</div>

> [@Rhum1x56](#):
>
> ($ random () \* 3) + 1.5 it's with node-red-node-random ??

No, that is JSONata expression in a change node...

> [@E1cid](#):
>
> This can be done with the Change node and JSONata expression.

---

<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:** [28 November 2020 08:44 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/6 "2020-11-28T08:44:45Z")

</div>

Did you search for `random` in the list of nodes in the left hand side of the editor? I believe it is one of the default nodes that gets installed.

---

<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:** [28 November 2020 08:48 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/7 "2020-11-28T08:48:19Z")

</div>

Its only a default on pi where we add it as an extra for you.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 November 2020 09:27 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/8 "2020-11-28T09:27:12Z")

</div>

Curious Dave. Why only PI?

---

<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:** [28 November 2020 13:50 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/9 "2020-11-28T13:50:17Z")

</div>

well I had to add gpio and serialport so I thought we may as well add a couple of other potentially useful to experimenters type ones like random (to help simulate inputs) and smooth, and ping to check connectivity. Not really essential for a lot of things so not really needed in core. Of course if you manually install without the script or say no to the extra nodes then you won't get them.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [28 November 2020 14:20 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/10 "2020-11-28T14:20:05Z")

</div>

> [@dceejay](#):
>
> or say no to the extra nodes then you won't get them.

If we currently have the additional nodes installed, then later, update using the script, and say no to the additional nodes, will they then be removed during the update process?

---

<div class="post-metadata">

**Author:** ![Rhum1x56](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Rhum1x56](https://discourse.nodered.org/u/Rhum1x56)\
**Post date:** [28 November 2020 14:20 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/11 "2020-11-28T14:20:18Z")

</div>

it is to install: D  
but the use ... I set between 1.5 and 3.5, I added a text and a debug, and send it to the database but I have nothing in the debug

I have a Pi but the project must be done on windows

 ![node-red-random](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aadc6165afc2e8e3697f5099b92ea8a8b92a8420.png)

---

<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:** [28 November 2020 14:30 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/12 "2020-11-28T14:30:39Z")

</div>

> [@Paul-Reed](#):
>
> will they then be removed

No - it's just an offer to add them - mainly so you can not add them if you use the script on other platforms like Ubuntu etc. Once in you can use the usual palette manager to remove them if you wish.

---

<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:** [28 November 2020 14:31 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/13 "2020-11-28T14:31:53Z")

</div>

you need to trigger the node somehow - so an inject node will let you click to create on or set a repeat to keep creating them over time.

---

<div class="post-metadata">

**Author:** ![Rhum1x56](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Rhum1x56](https://discourse.nodered.org/u/Rhum1x56)\
**Post date:** [28 November 2020 16:44 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/14 "2020-11-28T16:44:28Z")

</div>

Thanks I used Inject, 1 sec repeat interval, and it's good.  
my saviors !! thank you

---

<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:** [12 December 2020 16:44 UTC](https://discourse.nodered.org/t/random-number-for-simulate-a-machine/36640/15 "2020-12-12T16:44:34Z")

</div>

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