Program for Arduino to send sensor data of a room environment.
- Illuminance sensor
- (probably) NJL7202L-F3
- Temperature sensor
- (probably) LM61CIZ
- Arduino UNO
[5V]-[Long]Illumi Sensor[Short]-T--[PIN A0]
L-[200kΩ]--[GND]
(top view)
(rounded)
___--^--___
[5V]-[Left]Temp Sensor[Right]-[GND]
[Center]
L--[PIN A1]
[GND]---o [Aluminium pieces(electrode)] o---[PIN 2 (PULLUP)]
This program transmits data as json via serial port (baudrate=38400).
{
"type": "sensor",
"light": 1023,
"temperature": 1023,
}
The values of light
, temperature
are examples (Range: [0, 1023]).
This is only transmitted when door open state is changed.
{
"type": "doorSensor",
"doorState": "open",
}
doorState
is open
or closed
. This value will be open
when aluminium pieces connects the circuit.
Temperature can be calculated like below (temperatureRaw
is temperature
in json).
#define TMPR_VOLT 5.0
#define TMPR_V_OFFSET 0.6
#define TMPR_DEGREE_PER_VOLT 0.01
float v0 = (float)temperatureRaw / 1023 * TMPR_VOLT;
float temperature = (v0 - TMPR_V_OFFSET) / TMPR_DEGREE_PER_VOLT;
Probably some offset (calibration) is required (I needed to subtract about 10℃). Use another thermometer.