jremington:
You can do the same for several integer variables, separated by commas, using the snprintf() function. For example:char radiopacket[30] = {0}; //make sure this is large enough
snprintf(radiopacket,sizeof(radiopacket),"%d,%d,%d",pressure, humidity, temperature); //assuming p,h,t are integers
rf95.send((uint8_t *)radiopacket, strlen(radiopacket));
Hey thank you for all your help so far! I have gone back to the code you suggested and guess what i got it working somewhat! I put in the code:
char pressure=15.5;
char humidity=31;
char temperature=15;
What im receiving now is:
Got: 15,31,1506214?ç˝>oø1-‹ˇÔ˚ˇ˜Kıflˇ}s͈¢øißz™fi3Œuv}fl^1fl˛flúÅ˘˘∂æ/ÙØ.ˇıÎøfl}zßflµfl?OÊZΩW‰.ˇvθéÙ<fl|Øø5ófiÛ«˜áE.áu˘˝“≈è.ø¯Ù˚?Õ◊ˇfiá,;Uúq¨‹Ôv√˜s‹–.¸
∏k˘˜æO}‹.}:N›wöªΩΩìÔ!d˜ ®{˛÷˙_∑ˇ”È,∑”ß◊.w„ˇ›r=._yJì˛„˝Wfi≠˛æÙ˛[Ãˇ˜gˇ˘.Ì∫.uÔˇÿ¨M÷Íı.
The problems are now the big amount of symbols in the end of the 15,31 and 15. And how about then when the readings are not integers. Lets say for example 15.3°C. It didn't work with that code.
This is what the code looks like:
int16_t packetnum = 0;
int pressure=15.5;
int humidity=31.6;
int temperature=18.9;
void loop()
{
Serial.println("send #");
// Send a message to rf95_server
char radiopacket[30] = {1000}; //make sure this is large enough
snprintf(radiopacket,sizeof(radiopacket),"%d,%d,%d",pressure, humidity, temperature); //assuming p,h,t are integers
rf95.send((uint8_t *)radiopacket, strlen(radiopacket));
rf95.waitPacketSent();
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
delay (1000);
}