User Tools

Site Tools


add_temperature_sensor_in_domoticz

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
add_temperature_sensor_in_domoticz [2016/04/04 13:24]
sgripon [The Arduino sketch]
add_temperature_sensor_in_domoticz [2016/11/11 20:01] (current)
sgripon [Reference]
Line 17: Line 17:
 I modified a little bit the previous sketch in order to read from the serial line and send the temperature only when it is requested by client. I modified a little bit the previous sketch in order to read from the serial line and send the temperature only when it is requested by client.
  
-<file C++ sketch.ino>+<file C++ SmartHomeBox_sgripon.ino>
 #include <​RFControl.h>​ #include <​RFControl.h>​
  
Line 171: Line 171:
  
 -- Ask a new read until a signal has been received from the sensor. It should be available within next 30 seconds with this sensor. -- Ask a new read until a signal has been received from the sensor. It should be available within next 30 seconds with this sensor.
 +local nbTries = 0;
 local json_value = JSON:​decode(read_value) local json_value = JSON:​decode(read_value)
-while json_value.channel==0 do +while json_value.channel==0 ​and nbTries < 16 do 
- os.execute("​sleep 2") + nbTries = nbTries + 1 
 + os.execute("​sleep 2")
  wserial:​write("​r"​)  wserial:​write("​r"​)
  wserial:​flush()  wserial:​flush()
Line 180: Line 182:
 end end
  
--- Update the sensor value with the new temperature +-- Update the sensor value with the new temperature ​if a temperature has been read 
-commandArray['​UpdateDevice'​]=deviceNum..'​|0|'​..json_value.temp/​10+if json_value.channel==1 then 
 + commandArray['​UpdateDevice'​]=deviceNum..'​|0|'​..json_value.temp/​10 
 + -- print("​[DEBUG] Temperature:​ "​..json_value.temp) 
 +end
  
 return commandArray return commandArray
Line 188: Line 193:
  
 {{ ::​domoticz-temperature.png |}} {{ ::​domoticz-temperature.png |}}
 +
 +===== See also =====
 +  * [[add_temperature_and_humidity_sensor_dht11_in_domoticz|Add temperature and humidity sensor DHT11 in Domoticz]]
 +  * [[record_temperature_from_lexibook_asm30_sensor|Record temperature from Lexibook ASM30 sensor with Arduino]]
  
 ===== Reference ===== ===== Reference =====
add_temperature_sensor_in_domoticz.1459769047.txt.gz · Last modified: 2016/04/04 13:24 by sgripon