Skip to content

BLE Beacon Scanner example might not handle negative temperatures? #7618

Closed
@Humancell

Description

@Humancell

Board

Olimex ESP32 PoE ISO

Device Description

PoE PCB using the ESP32 WROOM 32UE

Hardware Configuration

Nothing special

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

All

Flash frequency

80Mhz

PSRAM enabled

no

Upload speed

115200

Description

https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/examples/BLE_Beacon_Scanner/BLE_Beacon_Scanner.ino#L118

When low temperatures occur, and go below 0 C, the calculations do not seem to be correct. It appears that using these 16-bit values in a 32-bit INT doesn't detect/use twos complement to handle the negative numbers properly.

In my final code I moved to a "signed short" which seems to fix the issue.

Sketch

signed short value;

          // extract the temperature
          value = (cServiceData[TEMP_MSB] << 8) + cServiceData[TEMP_LSB];

Debug Message

No debug ... just wrong calculated values.

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Area: BT&WifiBT & Wifi related issuesType: ExampleIssue is related to specific example.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions