Hi
I'm looking for a small script to convert Base10 Number into Base36. The reasion is, I like to compress numbers before sending them through html POST.
For example Base10 "15000" > "BKO".
At PHP there is a funktion called string base_convert ( string $number , int $frombase , int $tobase ).
Is there anything equivalent for Arduino? I was searching, but couldn't find anything. In case there is nothing, Is it a good way of compressing data like this for sending into the internet? or is there a better way?
Hi Robin,
thank you very much for your answer. I looked for raw byte, haven't heard about yet. If I understood it correctly, its like a kind of Base255 "Number". This would be greate, but I'm using a SIM900 for sending data into the internet. The communication beetween the Ardino and SIM900 is through Hardware Serial. Now I'm just "print" data like Serial.print("http://...&data1=.....) I guess in this case I can't use raw bytes or?
If I understood it correctly, its like a kind of Base255 "Number"
No it is a base 2 number, like all the numbers stored in any computer.
I guess in this case I can't use raw bytes or?
No all communication takes place with raw bytes, it is the interpretation you put on those bytes that make it have meaning. If both ends agree on that interpretation then the information gets passed on correctly.
@Grumpy_Mike: Thank you very much for your explanation!
I'm meassuring every hour and send these data once per day.
One measurement generates data like this: "2014090100-15000-1010-900-800-700-800" >> 37 places
So my http get contains 37x24 = 888 + url~20 = 900 places.
I thought just "ziping" the numbers by also using letters in the data string will be the easiest way of doing this.
maybee ther is another way of sending data from ardiuno throug the SIM900 into the internet?
You are outputting tApikey as a string. That implies that tApikey is a NULL terminated array of chars. Why you think you can cast that to a byte escapes me.
@PaulS: Thank's for your answer, That's correct, tApikey should not become a "byte" but would it work by using byte only on the numbers within this "String" for Serial communication?
Sorry, I'm able to write small programms and know the basics in C but I'm really on my personal limit with this
With my knowledge I thougth the easiest would be to convert my data to send into ABC letters to reduce the number of letters.
But I personally can't imagine sending different "types" of data by Serial.
Maybe It makes no different sending "15000" dec or "BKO" Base36 with Letters due to amounth of data sent physicly?
Maybe It makes no different sending "15000" dec or "BKO" Base36 with Letters due to amounth of data sent physicly?
Well, sending 5 characters vs. 3 characters IS going to make a difference in your phone bill. However, converting from base 10 to base 36 is not terribly difficult. Converting from base 10 to base 16 is simply a matter of repeatedly dividing by factors of 16 that are just smaller than the number to be converted. Then, repeat for the next smaller factor of 16. That same process can be used to convert to base 36.
What range of values are you converting, and does using base 36 actually result in significantly shorter values?
tTemp suggests that the value is a temperature. Are you really dealing with temperatures that exceed 1,296 degrees?