OneWire onewire(ONE_WIRE_PIN);
DallasTemperature dallas_sensors(&onewire);
DeviceAddress onShieldTemp = { 0x10, 0xE7, 0x77, 0xD3, 0x01, 0x08, 0x00, 0x3F };
+#define TEMPC_OFFSET
typedef struct {
byte offset;
dallas_sensors.requestTemperatures();
float tempC = dallas_sensors.getTempC(deviceAddress);
Serial.print("Temp C: ");
- Serial.println(tempC);
+ Serial.println(tempC TEMPC_OFFSET);
//Serial.print(" Temp F: ");
//Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}
{
pb_postth_state=1;
Serial.println("PanicButton");
- flash_led(7);
+ flash_led(4);
}
else if (!pb_state)
pb_postth_state=0;
last_movement=1
--print "something moved"
end
-
end
-
-
local socket = require("socket")
-local client = assert(socket.connect("127.0.0.1",2010))
---socket.unix = require("socket.unix")
---local socket = assert(socket.unix())
---local client = assert(socket:connect("/var/run/power_sensor.socket"))
-client:settimeout(30)
-
-
-
while 1 do
- local line, err = client:receive()
- if not err then
- parse_value(line)
- end
- client:send("T")
- line, err = client:receive()
- if not err then
- parse_value(line)
- end
- client:send("P")
- line, err = client:receive()
- if not err then
- parse_value(line)
+ local client = socket.connect("127.0.0.1",2010)
+ --socket.unix = require("socket.unix")
+ --local socket = assert(socket.unix())
+ --local client = assert(socket:connect("/var/run/power_sensor.socket"))
+ if client then
+ client:settimeout(30)
+ while 1 do
+ local line, err = client:receive()
+ if not err then
+ parse_value(line)
+ elseif err ~= "timeout" then
+ break
+ end
+ client:send("T")
+ line, err = client:receive()
+ if not err then
+ parse_value(line)
+ elseif err ~= "timeout" then
+ break
+ end
+ client:send("P")
+ line, err = client:receive()
+ if not err then
+ parse_value(line)
+ elseif err ~= "timeout" then
+ break
+ end
+ save_values()
+ end
+ client:shutdown("both")
end
- save_values()
+ socket.select(nil, nil, 10)
end