thermometer added

This commit is contained in:
2023-01-21 16:45:06 +01:00
parent 9c7bf54f34
commit c6f5aa112f
8 changed files with 2763 additions and 2 deletions

View File

@ -3,6 +3,9 @@
#include "configuration.h"
#include <string.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// from config.cpp
extern config_t myConfig;
@ -47,9 +50,23 @@ uint8_t appPort = 2;
*/
uint8_t confirmedNbTrials = 4;
OneWire oneWire(ONE_WIRE);
DallasTemperature DS18B20(&oneWire);
/* Prepares the payload of the frame */
static void prepareTxFrame( uint8_t port )
{
DS18B20.begin();
uint8_t cnt = DS18B20.getDS18Count();
Serial.printf("cnt: %d\n\r", cnt);
uint8_t addr[8];
DS18B20.getAddress(addr, 0);
Serial.printf("%02x %02x %02x %02x %02x %02x %02x %02x\n\r", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]);
DS18B20.requestTemperatures(); // send the command to get temperatures
uint32_t tempC = DS18B20.getTemp(addr);
Serial.printf("tempC: %08x\n\r", tempC);
appDataSize = 4;
appData[0] = 0x01;
appData[1] = 0x02;