One Wire Slave

So i'm creating a project that focuses to replace the thermostats around my home with various sensors that report back to a raspberry pi that handles relay switching and web UI for the system.

I'm using neuoy's OneWire Slave Library in order to emulate a Dallas Semiconductor DS18B20 device (temperature sensor).
I currently have the setup working with one Arduino that has a DHT11 Temp/Humidity Sensor relaying information as an emulated temperature over the one wire protocol.

I was wondering if it would be possible to pass multiple variables over 1-wire, so i could pass both temp and humidity, and possibly add more sensors like lux. I have tried recently to combine the temperature and humidity with addition and multiplication in hopes to separate out the numbers on the master's end, however the output i get from the arduino console does not match that of the recieved data over 1-wire

​ float t = dht.readTemperature();
   float h = dht.readHumidity();
   float p = 1000*(t);
   float a = (p)+(h);
	if (localState == DS_ConvertingTemperature && millis() > localConversionStartTime + 750)
		float temperature = (a); // here you could plug any logic you want to return the emulated temperature
		int16_t raw = (int16_t)(temperature * 16.0f + 0.5f);​

To the console the output is 19043.00
but to one wire host is 486213000

This is by far the most complicated sketch i've worked on, and i'm still unsure of what every line does, so any advice would be greatly appreciated.


Your problems most probably reside in the one wire part of your sketch, or on the receiver (master) end, which may interpret the bit pattern in a wrong way. If your master expects integers, you must transmit integer values, or tell it to expect float or double values. You also have to make your master accept multiple values, or send the values from different slave addresses, if you want to emulate multiple sensors.

Try to understand the one wire protocol and library code, before you continue with the data transfer part of your code.