How can i send 2 potentiometer values over xbee using arduino?( I mean in code)

Hi guys!

I need help in sending 2 potentiometer values over xbee via 2 arduinos... I want to print those 2 pot values over serial monitor :)

Do anyone had an idea about this? Would you mind sharing your ideas to me? :)


sort by: active | newest | oldest
maewert5 years ago
If you are going to send two numbers, you will need to distinguich between the numbers when you receive them.  You could send the numbers as ASCII text.  For example, Say the first parameter is 'A' and the second is 'B'.  You can send the text string "AXXXXXXX." when you send the first parameter and "BYYYYYYYY." when you send the second.  The first letter is the Parameter identifier, the the XXXXX's and the YYYYY's are the actual reading or the parameter value.  Finally the end is identified by the '.'  The code fragment to accomplish this is like so:

char string_to_send[40];

int A,B;

... send string_to_send via xbee
... send string_to_send via xbee

Best Wishes.
GraffikeL (author)  maewert5 years ago
Can you give me a brief idea what will the receiver code will look like?
GraffikeL (author)  GraffikeL5 years ago
And, what "A%s" mean in the code?
The 'A' and the 'B' distinguish between the two values. so the A is the first value and the B the second. The '%' is part of the '%d' which is how you tell in C that you want to print a decimal number.

Here is an example: Say you are building a remote control for your window blinds and you have two pots, one controls the position of the blinds and the other controls the angle of the blinds.  Your remote reads in the position of the Pots as analog values from 0 - 1023. Lets say Pot A is the position and pot B is the angle.  Lets say the remote reads the position as 519 and the angle as 27.  The remote sends the string "A519.B27." if you used the code snippit I sent above. 

The receiver now has to listen to the characters coming in and decode them.
Best Wishes.
lemonie5 years ago
How are you reading the values?

GraffikeL (author)  lemonie5 years ago
via arduino's analog pins
Are you putting voltage across them?

GraffikeL (author)  lemonie5 years ago
rickharris5 years ago
In general:

Read the value with ADC

Send that value via Wifi as a serial data stream (Binary number)


Convert data back to decimal and send to display.

Exactly how in terms of code will be for others to add if they like although I would say half the fun is figuring out how to o these things yourself by research - trial and error.