In another post called radio.write I was told that the data I received is in binary. I coppied the above code mentioned in #3 into my receiver and it only returns a numbr of 170. It should print a decimal vaue of -0.61
In another post called radio.write I was told that the data I received is in binary. I coppied the above code mentioned in #3 into my receiver and it only returns a numbr of 170. It should print a decimal vaue of -0.61
The data I receive currently is gubberish.
Any ideas on how to fix this?
Thanks in advance
ALL integer values are stored as binary - it is the ONLY way they can stored in a digital MCU.
The difference arises when you print them out to some sort of display device.
In the case of serial monitor you can chose to display the value as the native binary number: Serial.println(10, BIN)
Or as a more intuitive decimal number Serial.println(10, DEC)....or just Serial.println(10)
When reading integer data from a hardware device you simply don't need to concern yourself as to whether the data is binary or decimal. Such a concern is totally irrelevant.
Just declare an integer variable or variables and read the integer values into those variables.
Then you can chose how you want to display those rad values in Serial monitor for example - as a binary number of a decimal number.
The quoted expression, upon computer based computation, gives:
byte x = 0
x = x + 128; //x = 0x80 ; because the CPU will do binary addition
x = x+ 32; //x= 0x80 + 32 = 0xA0
x = x + 8; //x = 0xA0 = 8 = 0xA8
x = x+2; //x = 0xA8 + 2 = 0xAA
I am back to 10101010 (0xAA); where is the expected 170!
So, trick to obtain decimal (aka BCD) value by adding the respective positional values (positional factor*positional weight) will fail unless provision is kept for the necessary adjustment while the partial decimal (aka BCD) result is about to switch from 9 to 10 (9 + 1 ----> A). The 8085 has DAA, the 80x86 has DAA, the 8051 has DA A, and the ATmega has none for this adjustment.
As explained on your other thread on this topic, you need to post both the transmitter and receiver code.
Note that you are.not just dealing with a binary number, you are dealing with a floating point binary number.
This shouldn't be a problem, because computers are really good at doing simple things like format conversion.
C:\Users\Johan Prinsloo\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino/Print.h:73:12: note: no known conversion for argument 1 from 'float (*)[32]' to 'char'
C:\Users\Johan Prinsloo\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino/Print.h:74:12: note: no known conversion for argument 1 from 'float (*)[32]' to 'unsigned char'
C:\Users\Johan Prinsloo\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino/Print.h:75:12: note: no known conversion for argument 1 from 'float (*)[32]' to 'int'
C:\Users\Johan Prinsloo\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino/Print.h:76:12: note: no known conversion for argument 1 from 'float (*)[32]' to 'unsigned int'
#11
I know about the &. Ive tried variouse options and the result stay the same. If I use anything other than float -ie double,then I have to add & -otherwise the program does not compile.
float does not change the result. Ive tried variouse versions and placement options. If the gubberish is in binary how do I change it to a dec?
Ive tried some code -think its #3- not sure. It returned a different value.
I did change the data length. Please see attached. It only reads more [32] or less [8] gubberish
#9#18
The sketch is in #4 & #8
Sending Text was never an issue. Thats only for my reference to verify data send.
Its day 3( aprox 44 hours on this issue) and I must say Ive never had an programming issue this hard to solve. Im beginning to think that this is one of those problems that nobody can resolve.
//receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(6,7); //CE,CSN pins RF24L01
const byte rxAddr[6] = "00001"; //address of unit 1
void setup()
{
while (!Serial);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void loop()
{
if (radio.available())
{
char text[32] = {0}; // for word Amps1=
char Amps[8];
radio.read(&text, sizeof(text)); //prints the word Amps1=
radio.read(Amps, sizeof(Amps));// data received is giberish. need to clean it up
Serial.print(text);
Serial.println(Amps);
}
}