Hi I am printing to the serial monitor up to 8 groups of numbers with 2 spaces as separators. The numbers can have up to 4 digits plus a decimal point. a max of 54 character spaces. The result is always 2 lines and I want 1 line. How do I do this? I am using Serial.print on the 1.0.5 IDE
The result is always 2 lines and I want 1 line.
Why? If you don't want a carriage return and line feed, don't send them.
How do I do this?
Correctly. That sometimes involves posting your code, so we can replicate your results/see what you see/find problems. Or not. Your choice.
I am data logging from a number of sensors and then graphing using Excel. I need each line or chain of results to be a single line to make the graph straight forward.
I need each line or chain of results to be a single line to make the graph straight forward.
So? Fix your code. We can't help, because we can't see your code.
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_rx_item_humidity/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 94, /*node address*/ this_node);
radio.printDetails();
}
void loop(void)
{
// Pump the network regularly
network.update();
unsigned long ms;
float counter;
float room_temperature;
float humidity;
float counter1;
float room_temperature1;
float humidity1;
float humidity2;
// Is there anything ready for us?
while ( network.available() )
{
// If so, grab it and print it out
RF24NetworkHeader header;
payload_t payload;
network.read(header,&payload,sizeof(payload));
(temperature_measurement(A1));
Serial.print(millis()/5000);
Serial.print(" ");
Serial.print (counter,0);
Serial.print(" ");
Serial.print(temperature_measurement(A1),1);
Serial.print(" ");
Serial.print( payload.room_temperature,0);
Serial.print(" ");
Serial.println(payload.humidity1,0);
Serial.print(" ");
Serial.print (counter,0);
Serial.print(" ");
Serial.print(temperature_measurement(A2),1);
Serial.print(" ");
Serial.println( payload.room_temperature1,0);
tags added by moderator - click "Modify" to see how it's done.
There is more code after this presumably, as neither the while or loop are closed out.
Post the rest, use code tags (the # button).
The last line is sending a carriage return
Serial.println( payload.room_temperature1,0);
Why aren't these declared once in pre-setup code, vs everytime in loop?
unsigned long ms;
float counter;
float room_temperature;
float humidity;
float counter1;
float room_temperature1;
float humidity1;
float humidity2;
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
// nRF24L01(+) radio attached using Getting Started board
RF24 radio(9,10);
// Network uses that radio
RF24Network network(radio);
// Address of our node
const uint16_t this_node = 0;
// Address of the other node
const uint16_t other_node = 1;
// Structure of our payload
struct payload_t
{
unsigned long ms;
float counter;
float room_temperature;
float humidity;
float counter1;
float room_temperature1;
float humidity1;
float humidity2;
};
// ***************************************************************
float temperature_measurement(int pin)
{
analogReference(INTERNAL);
float Temperature = 0;
float avtempRead = 0;
for (int i = 1 ; i< 101 ; i++ ){
delay (10);
avtempRead += analogRead(pin)*(112000.00/1023.00/1.176) ;
}
Temperature = avtempRead / 100000.00 ;
return Temperature;
}
//*****************************************************************
void setup(void)
{
Serial.begin(57600);
Serial.println(“RF24Network/examples/helloworld_rx_item_humidity/”);
SPI.begin();
radio.begin();
network.begin(/channel/ 90, /node address/ this_node);
radio.printDetails();
}
void loop(void)
{
// Pump the network regularly
network.update();
unsigned long ms;
float counter;
float room_temperature;
float humidity;
float counter1;
float room_temperature1;
float humidity1;
float humidity2;
// Is there anything ready for us?
while ( network.available() )
{
// If so, grab it and print it out
RF24NetworkHeader header;
payload_t payload;
network.read(header,&payload,sizeof(payload));
(temperature_measurement(A1));
Serial.print(millis()/5000);
Serial.print(" “);
Serial.print (counter,0);
Serial.print(” “);
Serial.print(temperature_measurement(A1),1);
Serial.print(” “);
Serial.print( payload.room_temperature,0);
Serial.print(” “);
Serial.println(payload.humidity1,0);
Serial.print(” “);
Serial.print (counter,0);
Serial.print(” “);
Serial.print(temperature_measurement(A2),1);
Serial.print(” ");
Serial.println( payload.room_temperature1,0);
}
}
Here is the whole programme. I don’t understand why when I declare the names in the payload structure I have to re declare it. So rather than find out I put it where it now is and it worked. I should add I generated names for the data as a trial as currently I am only reading 4 sensors…
All I want is the data to appear in a single line rather than 2 lines. If I change the last print from println to print the data will be in continuous line and I will have to add line breaks myself.
What about this one in the middle:
Serial.print(millis()/5000);
Serial.print(" “);
Serial.print (counter,0);
Serial.print(” “);
Serial.print(temperature_measurement(A1),1);
Serial.print(” “);
Serial.print( payload.room_temperature,0);
Serial.print(” “);
Serial.println(payload.humidity1,0);
Serial.print(” “);
Serial.print (counter,0);
Serial.print(” “);
Serial.print(temperature_measurement(A2),1);
Serial.print(” ");
Serial.println( payload.room_temperature1,0);
Nice catch - I missed that one earlier 8)
Thanks. I thought the short line length was a limitation of the IDE but it was a limitation of the programmer. I have modified the sketch and it works as I need