Closed Amine1079 closed 3 years ago
You would need to convert it to a string. For example, from the page Arbitrary precision (big number) library port for Arduino:
// function to display a big number and free it afterwards
void printBignum (BigNumber n)
{
char * s = n.toString ();
Serial.println (s);
free (s);
} // end of printBignum
I'm trying to send a big number from master(Arduino) to slave(Arduino) I
have tried with printBignum but the same problem
Serial.read reads one byte. You need to make your slave read multiple bytes, for example until you hit a newline. On your slave you received 52, 49, 56, 53 ... Now if you look at an ASCII code chart, that is equivalent to '4', '1', '8', '5' which is what you are sending. Once you have received the whole number (24 bytes in your case by the looks) you can use the Bignum library to convert that string back into a big number.
There are some tips about reading serial data until you get a newline or similar on my page about processing serial data.
Thank you :)
I have tried to convert String to BigNumber but :
error: no match for 'operator=' (operand types are 'BigNumber' and 'String')
See https://github.com/nickgammon/BigNumber
BigNumber bigNum;
bigNum = "67411411944031530524562029520200239450929984281572279077458355238873731477537";
You supply a string (not a String) to the BigNumber. The link I gave above about processing serial input shows how to do that. If you use the String class you are likely to run out of memory because of memory fragmentation.
Make an array of char, and put the incoming data into it. In your case an array of (say) 33 bytes should be enough to hold 32 bytes of digits, plus a terminating 0x00 byte.
hello, how to send a big number with serial in Arduino ? I have tried to send with serial.write but the result is false and thanks