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=1Why does send() only send 1 instead of the string?
Using 2.2.0-rc.1 -
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=1Why does send() only send 1 instead of the string?
Using 2.2.0-rc.1 -
// 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); } -
// 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. -
// 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); } -
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 -
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login