battery manager test code
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* @file DS18B20.h
|
||||
* @author your name (you@domain.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2020-06-09
|
||||
*
|
||||
* @copyright Copyright (c) 2020
|
||||
* Based on the LUA code from the ESP8266
|
||||
* --------------------------------------------------------------------------------
|
||||
* -- DS18B20 one wire module for NODEMCU
|
||||
* -- NODEMCU TEAM
|
||||
* -- LICENCE: http://opensource.org/licenses/MIT
|
||||
* -- Vowstar <vowstar@nodemcu.com>
|
||||
* -- 2015/02/14 sza2 <sza2trash@gmail.com> Fix for negative values
|
||||
* --------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef DS18B20_H
|
||||
#define DS18B20_H
|
||||
|
||||
#include <OneWire.h>
|
||||
|
||||
class Ds18B20 {
|
||||
private:
|
||||
OneWire* mDs;
|
||||
int foundDevices;
|
||||
public:
|
||||
Ds18B20(int pin) {
|
||||
this->mDs = new OneWire(pin);
|
||||
}
|
||||
|
||||
~Ds18B20() {
|
||||
delete this->mDs;
|
||||
}
|
||||
/**
|
||||
* @brief read amount sensots
|
||||
* check for available of DS18B20 sensors
|
||||
* @return amount of sensors
|
||||
*/
|
||||
int readDevices(void);
|
||||
|
||||
/**
|
||||
* @brief Read all temperatures in celsius
|
||||
*
|
||||
* @param pTemperatures array of float valuies
|
||||
* @param maxTemperatures size of the given array
|
||||
* @return int amount of read temperature values
|
||||
*/
|
||||
int readAllTemperatures(float* pTemperatures, int maxTemperatures);
|
||||
};
|
||||
#endif
|
74
esp32test/Esp32DeepSleepTest/include/DS2438.h
Normal file
74
esp32test/Esp32DeepSleepTest/include/DS2438.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* DS2438.h
|
||||
*
|
||||
* by Joe Bechter
|
||||
*
|
||||
* (C) 2012, bechter.com
|
||||
*
|
||||
* All files, software, schematics and designs are provided as-is with no warranty.
|
||||
* All files, software, schematics and designs are for experimental/hobby use.
|
||||
* Under no circumstances should any part be used for critical systems where safety,
|
||||
* life or property depends upon it. You are responsible for all use.
|
||||
* You are free to use, modify, derive or otherwise extend for your own non-commercial purposes provided
|
||||
* 1. No part of this software or design may be used to cause injury or death to humans or animals.
|
||||
* 2. Use is non-commercial.
|
||||
* 3. Credit is given to the author (i.e. portions © bechter.com), and provide a link to the original source.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DS2438_h
|
||||
#define DS2438_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <OneWire.h>
|
||||
|
||||
#define DS2438_TEMPERATURE_CONVERSION_COMMAND 0x44
|
||||
#define DS2438_VOLTAGE_CONVERSION_COMMAND 0xb4
|
||||
#define DS2438_WRITE_SCRATCHPAD_COMMAND 0x4e
|
||||
#define DS2438_COPY_SCRATCHPAD_COMMAND 0x48
|
||||
#define DS2438_READ_SCRATCHPAD_COMMAND 0xbe
|
||||
#define DS2438_RECALL_MEMORY_COMMAND 0xb8
|
||||
#define DS2438_PAGE_0 0x00
|
||||
|
||||
#define DS2438_CHA 0
|
||||
#define DS2438_CHB 1
|
||||
|
||||
#define DS2438_MODE_CHA 0x01
|
||||
#define DS2438_MODE_CHB 0x02
|
||||
#define DS2438_MODE_TEMPERATURE 0x04
|
||||
|
||||
#define DS2438_TEMPERATURE_DELAY 10
|
||||
#define DS2438_VOLTAGE_CONVERSION_DELAY 8
|
||||
|
||||
typedef uint8_t DeviceAddress[8];
|
||||
|
||||
class DS2438 {
|
||||
public:
|
||||
DS2438(OneWire *ow);
|
||||
DS2438(OneWire *ow, uint8_t *address);
|
||||
|
||||
void begin();
|
||||
void update();
|
||||
double getTemperature();
|
||||
float getVoltage(int channel=DS2438_CHA);
|
||||
boolean isError();
|
||||
boolean isFound();
|
||||
private:
|
||||
bool validAddress(const uint8_t*);
|
||||
bool validFamily(const uint8_t* deviceAddress);
|
||||
|
||||
bool deviceFound = false;
|
||||
OneWire *_ow;
|
||||
DeviceAddress _address;
|
||||
uint8_t _mode;
|
||||
double _temperature;
|
||||
float _voltageA;
|
||||
float _voltageB;
|
||||
boolean _error;
|
||||
boolean startConversion(int channel, boolean doTemperature);
|
||||
boolean selectChannel(int channel);
|
||||
void writePageZero(uint8_t *data);
|
||||
boolean readPageZero(uint8_t *data);
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user