Arduino Input in SuperCollider

Dear SC users,

I am measuring temperature and humidity using a DHT11 sensor connected to an arduino. In the post window of the Arduino I see for example this output: Humidity: 48.20 Temperature: 26.20. From the Arduino I go to SuperCollider, where I was able to import the input as ASCII code and convert it to the number 48202620. I would like to ask how I can split this number in two and make it a float again.



Here’s one way:

a = 48202620;     // original number (Integer)
b = a.asString;   // convert to string
c = b.keep(4);    // keep first 4 chars
d = b.keep(-4);   // keep last 4 chars
e = c.asFloat * 0.01;  // c as float with 2 decimal places
f = d.asFloat * 0.01;  // d as float with 2 decimal places

Best, Paul