[Solved] Compiling a working Firmata firmware for PRi Pico? #2897
Replies: 5 comments 23 replies
-
Can you show which exact sketch you're uploading to the Raspberry Pi Pico, and what serial input you're sending it that makes it stop responding? Or does it immediately lose the serial port after uploading the sketch? I'm looking for a minimum, complete and verifiable example (MVCE) here. |
Beta Was this translation helpful? Give feedback.
-
Summary - Solution:The old #define ENABLE_SERVO About servo - Null problem:The IS_PIN_SERVO(p) Don't you think it would be great to add a condition to the first line, like this: if ( ! IS_PIN_SERVO(p) ) return 0; ? TemperatureIt is very strange, that reading analogue-4 (5th) works great at setup, float f = analogReadTemp(); but if I do the same with Firmata, no data is coming. |
Beta Was this translation helpful? Give feedback.
-
About Temperature (again) - SOLVED too!
I've solved the temperature reading by adding following lines to the 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 is: {"celsius": 23.3933, "rawTemp": 881 } The main difference was this:
|
Beta Was this translation helpful? Give feedback.
-
Question2:
This is the current code for Pico(1) : #elif defined(TARGET_RP2040) || defined(TARGET_RASPBERRY_PI_PICO)
... I've tried these, but none worked: #elif ... || defined(TARGET_RP2350) || defined(GENERIC_RP2350) || defined(RASPBERRY_PI_PICO_2) Thanks for the help in forward! |
Beta Was this translation helpful? Give feedback.
-
Anyway, has anybody else realised: Those numbers defined here are BOTH WRONG !#if defined(PICO_RP2350) && !PICO_RP2350A
#define __GPIOCNT 48
...
#else
#define __GPIOCNT 30
... Because actually there are 49 & 31 pins, if we count the ADC Temperature sensor !This code only works, because you are subtracting a 0th item based array from a "counter" (which starts from: 1th): extern "C" float analogReadTemp(float vref) {
...
adc_select_input(__GPIOCNT - __FIRSTANALOGGPIO); // Temperature sensor I know, it's not your fault, because the whole RPI documentation is strange. Even if I summarise it with IA, it says it's just 30/48 pins, while it is NOT.
|
Beta Was this translation helpful? Give feedback.
-
First of all, I'd like to thank for this excellent library! I've red only great things about it everywhere.
I try to improve [ConfigurableFirmata <-> NodeRED] communication to create a reliable solution to handle attached extra boards. (My progress so far is documented here...)
Only CofigurableFirmata can handle Pico boards, StandardFirmata can not.
I've reached the point where the default firmware is not enough for Pico boards. Would like to implement:
These are all easy with this great library, but nearly impossible with default EmbedOS.
But when I compile Firmata, based on this library, the board stops responding.
It is complicated to debug code running on the board (without spec. cable + other debugger board), so I'm asking for help:
Did anybody run CofigurableFirmata successfully using this lib ?
Beta Was this translation helpful? Give feedback.
All reactions