Random number for simulate a machine

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 :confused:

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

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

2 Likes

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

2 Likes

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 ??

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

1 Like

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.

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

1 Like

Curious Dave. Why only PI?

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.

1 Like

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?

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

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.

1 Like

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.

1 Like

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

1 Like

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