-
Notifications
You must be signed in to change notification settings - Fork 19
1 Wire Devices
1-Wire devices are natively supported in REM. Currently, the only device pre-configured is the DS18B20 temperature sensor but more can be added. These devices are relatively inexpensive and can be externally powered (using the 3.3v bus) or using parasitic power (stealing from the GPIO port).
REM has built in support for 10k thermistors. The algorithms to convert the resistance from the thermistor are built in and REM will calculate the temperature from the resistance for you. There is also support for Atlas EZO-RTD and EZO-HUM which may be the right choice for you and really only involves adding the appropriate EZO devices to your Raspberry pi stack.
1-Wire needs to be enabled on the O/S in order to be used. On the Pi, you can do this through RasPi Config (sudo raspi-config
) by following these steps:
- Choose 3 - Interface Options
- Choose P7 1-Wire
- Select Yes and exit/reboot the Pi
In order to read the temperature probe you only need to wire it to the right GPIO ports with a resistor. The below picture comes from this AdaFruit tutorial but there are many out there.
Unlike using an ADC, the 1-wire is a simple protocol which can read the registers of the devices directly.
If you want to validate the 1-Wire setup, you can look in the /sys/bus/w1_master_bus1
directory. The DS18B20 devices start with a 28-xxx
and should exist as a directory and also be displayed with cat w1_master_slaves
. If you see devices that start with 00-xxxx
then it is a phantom device and you should check your wiring. (Bonus command for reading the temperature from the command line in the picture - 23625 = 23.625 degrees C).
At this point you should have your hardware set up, REM Installed, and 1-Wire enabled on the Pi. What follows is a Step by Step to start reading the Thermistor(s)
REM will not let you configure 1-Wire devices until you identify the bus so from the general tab click the + sign on the 1-Wire Buses list and a dialog will appear. If you don't know what an 1-Wire Bus number is then leave this as 1 but if you do know then REM will support multiple 1-Wire buses on a single pi. Then click the Create Bus button.
Once you do this another tab should appear and the bus will be listed in the 1-Wire Buses list.
NOTE:Click the Reset Server
button to load the 1-Wire devices (this will happen automatically upon restart). Otherwise, when you go to the next step you will need to tell REM to re-scan the bus for the devices.
Now that REM knows all about your 1-Wire bus, you need to click on the device that you want to configure.
NOTE: You may need to click the + on the Devices List then Re-scan if your device does not show up right away.
If you have multiple devices, you may need to do some trial-and-error to figure out which one is which. Once you figure this out click, on the address in the Devices list, check the Is Active checkbox and select DS18B20 from the Device dropdown. Then click Save Device
The DS18B20 has some configuration options.
- Units: The probe always reads C but you can convert to F.
- Resolution: The probe can be read in 9/10/11/12 bits. The higher number means a more accurate, but longer reading (See the Conversion Time in the Device Info section when you change/save the value.) The resolution corresponds to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C respectively.
- Alarm Low/Alarm High - These are hardware alarms but not wired up to anything yet.
- Poll Interval - How often should REM poll this device?
- Calibration - Software based calibration if you want to adjust the raw temperature feed.
Now that all the components have gotten to know each other we can now send the temperature off to whatever needs it including nodejs-PoolController. If you haven't set up a connection to njsPC yet. Click the + on the Connections list from the General tab then fill out the connection information for nodejs-Pool Controller. If you have ssdp enabled on njsPC you may also search for the server. When you are done press the Save button then the cancel button.
Now lets feed the temperature to njsPC. Click on the 1-Wire Devices tab then click on the device in the Devices list next to the probe we want to feed to njsPC.
From the Feeds tab click the + sign on the Device Value Feeds list and an Add Feed to 1-Wire device dialog will appear. Choose the connection you set up for nodejs-PoolController select Temperature as the send value then select temps as the socket event for njsPC.
The choice for the Property dropdown will be dependent upon your pool setup in njsPC. If you are set up as a shared pool/spa or a single body and this represents your water temperature select waterSensor1. If you are a dual body setup then select waterSensor2 for the second body temperature and waterSensor1 for the first body. If this is the solar temperature select the solarSensor that corresponds to the heater number. In most cases you are selecting solarSensor1 but up to 4 separate solar arrays are supported. Finally, if this is an air sensor then select that. Once you made your selection click the save button and njsPC will now be getting the temperatures from your new probes.
You can use this same functionality to send the temperature values over MQTT, Sockets, or internal devices that will use it by setting up a connection of that type then setting up a feed.
Now that the temp hardware and feeds have been set and you added the sensors you needed, you can calibrate the sensors in njsPC by telling it what the temperature should be (if you did not calibrate them in Step 3 above).