DS18B20 and Particle Photon #
Wiring #
Components #
- DS18B20 -- Dallas Semiconductor's temperature sensor that uses the Onewire protocol
- Using it in non-parasitic mode
- Case style
- 4.7k resistor
- Particle Photon
Details #
Phase 1 #
- Operate with 3.3v for the circuit side of things.
- connected to gnd and 3v3 from the board power
DATA
pin connected toD2
on particle photon
- Initial code
- pulled out a copy of the blink code
- using the blinking LED as a baseline to ensure the board is working
- reads the temperature sensor and if successful, publishes the celcius temperature to the particle cloud.
- Loop has about 4 seconds of delay in it.
- NOTICED that the sensor would not read on every cycle.
1#include "DS18.h"
2
3
4DS18 sensor(D2);
5
6int led2 = D7; // Instead of writing D7 over and over again, we'll write led2
7double tempC = 0; // temperature in celcius from the ds18b20
8
9
10void setup() {
11 pinMode(led2, OUTPUT);
12 Particle.variable("tempC", tempC); // makes a r/w var queryable through UI
13}
14
15void loop() {
16 digitalWrite(led2, HIGH);
17
18 delay(2000);
19
20 digitalWrite(led2, LOW);
21
22 if (sensor.read()) {
23 tempC = sensor.celsius();
24 Particle.publish("temperature", String(tempC), PRIVATE);
25 }
26 delay(2000);
27}
28
Phase 2 #
Working on ideas for storing some of the data
- Particle web console looks like for the free account has 100k data request limits.
- I burned through a bunch leaving the particle publishing temperature overnight not realizing the limitation
- Dialed it back down to about every 5 minutes and that should keep quota alright.
- Connected to an MQTT broker to publish more often to see what is going on.
brew install mosquitto
to get a client that I can monitor what is getting published more frequently from the device. Note: a particle photon is a WiFi device.mosquitto_sub -t invermere/temperature -h mqtt.eclipseprojects.io
<-- open to anyone wanting to take a boring look at temperature values coming in.- There are some conflicting addresses for the location of the 'free-to-use' mqtt broker. This one above works well enough for testing.
- I am looking to understand what it would take to set up a build pack for heroku to have an mqtt broker running as well as a client.
- Considering how to feed this into the stathat on top of the webhook integration I did after the particle value is published.
July 25, 2022 #
- On the weekend did some work to see if I could get the thing installed. Ran into a bunch of goofy problems.
- Seems that when mounted in the case that I made for it the temperature was reading way wrong.
- Maybe soemthing to do with the bendy lines, no idea. Taking it out of that box and dangling it, seemed to fix the issues - [ ] Need new box for the sensor at least - Power at the light location was sketch. The timer circuit in the house is just pulsing the power to those end points. 1. Need to re-wire the switch to remove the timer aspect
- also working with mqtt resrouces on the server side seem to be harder than it should
- Issues with getting them out to graphing tools.
- like mqtt to webhook or http call functionality
- or just keeping subscribed long enough cloud amqp
- pipdream converted a bunch then ran out of capacity
- Issues with getting them out to graphing tools.
- Seems that when mounted in the case that I made for it the temperature was reading way wrong.
Todo #
- Remove the wiring from 5v system on photon and move to the 3.3v
- Move the GND to the other side of the chip
- Replace the Data wire from photon to the temp sensor
- Get a pure DS18B20 instead of the the DS18B20-PAR