A value of millisecond between 10-65500 can be set !
Both at startup on the Arduino setup panel,
and at runtime via msg.payload = 500 if node-out Type is set for this.
This will reduce or increase the speed, how (analogue) data will flow (if changed).
This is a global value. So individual pins can not be set differently at Firmata firmware.
Default value is now changed from 19ms to: 200ms, because even my high speed laptop could not handle the amount of debugs showing even for 1 pin.
200ms => max 5 message will be sent pro second, if value changes (for each analogue pin you subscribed for).
About board-reset:
This function has 2 purpose:
it will stop sending analogue values + will set all output pins to default LOW
helps after restart, because the board can be re-attached to NR.
Note: it happens very fast. So if there is only a "LED blink", you will hardly notice anything, because "output" will work again after a few milliseconds.
Analogue read (and maybe digital in too!) will stop completely until flow restart.
Two ways to do it:
Set Arduino-out node to: reset + send a: msg.payoload = true or 1
A code part of Configurable Firmata has been found, prevented reporting of digital pins at higher sampling rate.
Read here...
The only "side effect" is, that fluctuating pins will be reported more times,
but I think that's ok, because usually if someone is not using proper pullup-resistors, it's not a software problem.
After this pull request is accepted, everyone should upgrade his Firmata firmware.
I2C and SPI is also affected, because until now sampling rate was not effecting them.
From now on, it will!
Note:
if using unshielded or long cables, (especially in electric noisy or 110V/240V environment,) it is strongly recommended to use optocoupler. There are complete 4 channel boards under $2 price, and can handle 12V/24V to work stable even at 100/1000 meters of cable.
In-nodes do not report / send new message on start!
Fixed: Reported "pin conflict" at "String", "sampling rate", etc. types too.
Fixed: Reported "wrong pin" at "String-in" type. (strings do not use Pins)
_Strings nodes did not accept Pin values, like: 99
String-in node can start before board-report. (no need to wait)
This way it will report even "...starting" message coming from Firmata board.
Circumvent Firmata-io is reporting "opening port" messages as "Error". (while it is not one.)
Noticed behaviour at disconnect:
While unplugging / disconnecting the board, sometimes it can happen, that:
Close event
gets called by Node-red Firmata-io, instead of:
(transport-) Disconnect event
In these cases it will completely close all sub-nodes, so
In-nodes will stop receiving in-values !
What will still work after reconnecting:
Outputs, like turning a Pin High/Low
String-in
PS: I have no Wifi capable boards to test, but behaviour will probably the same.
Because Node-RED does not properly propagating the current state of NR service, like:
The board definition is wrong. There are 31 pins, including 5 analogue. (Not 30 / 4!)
So, for Pico1 board, you must change the file ...Arduino\libraries
770. lines to this:
#define TOTAL_ANALOG_PINS 5
#define TOTAL_PINS 31
Will add a push req. to Github code soon.
Had to change the resolution to 12 bit. (See code below)
Also IMHO it is essential, to use an up-to-date board library, called: Earle Phil's Arduino-Pico instead of the 4 year old "embedOS".
So, it is necessary adding following lines to the setup() part, before exporting and flashing to RPi-Pico board:
void setup()
{
...
analogReadResolution(12);
// send TEMP °C + RawTempValue, formatted as JSON.
#include <stdio.h>
float c = analogReadTemp();
char buf[50], buf2[25];
snprintf(buf , 25, "{\"celsius\": %f, ", c);
#include <hardware/structs/adc.h>
hw_set_bits(&adc_hw->cs, ADC_CS_TS_EN_BITS);
delay(1); // Allow things to settle. Without this, readings can be erratic
int _rt = analogRead(TOTAL_PINS - 1);
snprintf(buf2, 25, "\"rawTemp\": %d }", _rt);
strcat (buf , buf2);
Firmata.sendString(F( buf ));
// float celsius = 27.0f - ((v * vref / 4096.0f) - 0.706f) / 0.001721f; // const float vref = 3.3f;
}
Result during bootup is coming through Adruino-in STRING node:
{"celsius": 23.3933, "rawTemp": 881 }
The main difference was this: analogReadResolution(12);
Without that line, only values like: 219, 220 came always. (Probably because the default resolution is 10bit.)
So now I can read the same values (779-882) with Node-RED too !
Anyway the interesting thing is, that even at max resolution (12 bit) the temp values having too big jumps if I apply the math:
Ca. 0.47 °C jumps between 2 values.