MistyGro API
C++ API for MistyGro's ESP32 controller based on the Arduino framework
test_temperature.cpp
Go to the documentation of this file.
1 // Copyright 2023 Myron Rodrigues
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <Arduino.h>
16 
17 #include "temperature_sensor.h"
18 
19 TemperatureSensor temp_sensor(pin::temp_sensor_bus);
20 
21 void setup()
22 {
23  Serial.begin(115200);
25  Serial.println("Temperature sensor test");
26 }
27 
28 void loop()
29 {
30  Serial.print("Device count: ");
31  Serial.println(temp_sensor.device_count());
32  Serial.print("Temperature: ");
33  Serial.println(temp_sensor.read());
34  delay(1000);
35 }
wrapper for Dallas one-wire temperature sensor (DS18B20)
void begin()
Initialise all one wire sensors.
uint8_t device_count()
Get count of total sensors on the one wire bus.
float read()
Read temperature as float value from sensor.
void setup()
TemperatureSensor temp_sensor(pin::temp_sensor_bus)
void loop()