Sending a string in send() - not doing as I want it to do
-
Hi,
I have this function in my sketch:void CheckRSSI() { char SendingRSSI[10]; char ReceivingRSSI[10]; char TxPowerLevel[10]; char TxPowerPercent[10]; String sendRSSI; itoa(RFM69_getSendingRSSI(), SendingRSSI,10); wait(200); itoa(RFM69_getReceivingRSSI(), ReceivingRSSI,10); wait(200); itoa(RFM69_getTxPowerLevel(), TxPowerLevel,10); wait(200); itoa(RFM69_getTxPowerPercent(), TxPowerPercent,10); wait(200); // Now, combine all values and send it in // Line should look like "T:-90 R:-81 PL:20 PP:100" sendRSSI = "T: "; sendRSSI.concat(SendingRSSI); sendRSSI.concat(" R:"); sendRSSI.concat(ReceivingRSSI); sendRSSI.concat(" PL:"); sendRSSI.concat(TxPowerLevel); sendRSSI.concat(" PP:"); sendRSSI.concat(TxPowerPercent); #ifdef MY_DEBUG Serial.print(F("RSSI String: ")); Serial.println(sendRSSI); #endif send(msgRSSI.set(sendRSSI)); }
The output is:
RSSI String: T: -59 R:-51 PL:-2 PP:0 TSF:MSG:SEND,13-13-0-0,s=1,c=1,t=47,pt=0,l=23,sg=0,ft=0,st=1
Why does send() only send 1 instead of the string?
Using 2.2.0-rc.1
-
How is msgRSSI created?
-
// Debug #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RFM69_NEW_DRIVER #define MY_RFM69_FREQUENCY RFM69_868MHZ // #define MY_RFM69_ENABLE_ENCRYPTION #include <MySensors.h> #define SKETCH_NAME "Test-text" #define SKETCH_VERSION "1.0" #define CHILD_ID_RSSI_INFO 1 // Mysensors settings MyMessage msgRSSI(CHILD_ID_RSSI_INFO, V_TEXT); void before() { } void setup() { Serial.begin(115200); // for serial debugging. Serial.println(F("Start up sensor.")); } void presentation() { present(CHILD_ID_RSSI_INFO, S_INFO, "RSSI Info"); } void loop() { #ifdef MY_DEBUG Serial.println(F("Starting new measurements")); #endif CheckRSSI(); // Sleep #ifdef MY_DEBUG Serial.println(F("Waiting 1 minute")); #endif wait(60000); }
-
@mickecarlsson sendSketchInfo is missing. Not sure if that affects anything.
The presentation call is strange. I haven't seen it used with three paramters before.
Edit: seems to be my inexperience, so presentation is probably ok.
-
@mickecarlsson see if changing
send(msgRSSI.set(sendRSSI));
to
send(msgRSSI.set(sendRSSI.c_str()));
helps
-
THANKS!!
That did it:RSSI String: T: 127 R:-49 PL:-2 PP:0 TSF:MSG:SEND,13-13-0-0,s=1,c=1,t=47,pt=0,l=23,sg=0,ft=0,st=OK:T: 127 R:-49 PL:-2 PP:0
-
@mickecarlsson great!
5 out of 7
Suggested Topics
-
Day 1 - Status report
Announcements • 23 Mar 2014, 22:45 • hek 24 Mar 2014, 20:12 -
Ghost Child
Troubleshooting • 14 days ago • FcNanoLed 11 days ago -
Echo request is not set
Troubleshooting • 12 Aug 2024, 15:36 • kamilb85 3 Sept 2024, 08:58 -
Compiling Sensor code using BME280 and ESP8266
Troubleshooting • 26 Feb 2025, 00:32 • dpcons 26 Feb 2025, 06:22 -
Can not compile MySensors on esp8266
Troubleshooting • 24 Aug 2024, 15:35 • TheoL 29 Aug 2024, 20:47 -
Forum Search not working?
Troubleshooting • 4 Oct 2023, 23:33 • Gibber 2 Sept 2024, 20:28