I am trying to read temperature from this little sensor https://www.aliexpress.com/item/temperature-sensor-and-humidity-sensor-HTS221/32953862359.html?spm=a2g0s.9042311.0.0.e3534c4dT9GRz3
There are 4 GattServices available
GattService 00001800-0000-1000-8000-00805f9b34fb - Generic Access
here are characteristics:
00002a00-0000-1000-8000-00805f9b34fb Device Name
00002a01-0000-1000-8000-00805f9b34fb Appearance
00002a04-0000-1000-8000-00805f9b34fb Peripheral Preferred Connection Parameters
GattService 00001801-0000-1000-8000-00805f9b34fb - Generic Attribute
no characteristics
GattService 0000180a-0000-1000-8000-00805f9b34fb - Device Information
here is characteristic:
00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String
GattService 6e400000-b5a3-f393-e0a9-e50e24dcca9e - ???
It looks that HTS221 is not sending data by default, what should I do to be able to read the temperature ?
Related
I am stuck with a project of a BLE Keyboard to PS2 adapter with the ESP32 microcontroller. For the BLE part, I use the NimBLE library. My bluetooth keyboard is a Microsoft Surface Ergonomic Keyboard. I have no previous experience with BLE.
These are the services and their characteristics of the bluetooth keyboard:
0x1800: Generic Access
Characteristics:
0x2a00: Device Name
0x2a01: Appearance
0x2a04: Peripherial Preferred Connection Parameters
0x1801: Generic Attribute
0x180a: Device Information
Characteristics:
0x2a29: Manifacturer Name
0x2a50: PNP Id
0x180f: Battery Service
Characteristic:
0x2a19: Battery Level
0x1812: HID Service
Characteristics:
0x2a4e: Protocol Mode
0x2a4d: Report
0x2a4b: Report Map
0x2a22: Boot Keyboard Input Report
0x2a32: Boot Keyboard Output Report
0x2a4a: HID Information
0x2a4c: HID Control Point
After I find it and pair it by entering the PIN, I can successfully read the battery level and receive notifications when it changes, so I got the pairing, notification registering and reading values from characteristics alright.
Now I want obviously to read key presses. I take the "Report Map" characteristic of the HID service and read its values that describe the report. Meaning of the values here in section E.6.
0x05, 0x01 -> Usage Page (Generic Desktop)
0x09, 0x06 -> Usage (Keyboard)
0xA1, 0x01 -> Collection (Application)
0x85, 0x01 -> ???
0x15 -> Logical Minimum? (0)
I don't know what to do with this information. I assume I will need this later to interpret the incoming reports of key presses. However, I don't know how to receive them.
I continue with the "Report" characteristic because I assume this is the place where key presses come in?
I read the characteristic's value: It has the handle 0x0047 and the value 0x78. I register for notifications.
Then I get the same characteristic a second time, now it has the handle 0x0016, same value and a 2902 descriptor with value 1 (meaning it is in report mode and not in boot mode). I register again for notifications, but I receive no notification when I press keys.
How do I read reports from the device? They obviously do not come as notifications.
I am implementing an USB audio input device (STM32 with two microphones), following the Universal Serial Bus Device Class Definition for Audio Devices, Release 2.0.
I want to use USB High Speed, not Full Speed. The Standard AS Isochronous Audio Data Endpoint Descriptor has the field bInterval.
How should I choose the value for bInterval? Can I use a value of 0x01 (interval of 125us) or should I use an interval of 1ms (0x04, which would be the same interval as in Full Speed)? Does a shorter interval has advantages for the amount of samples that can be transferred (later I would like to use up to 16 microphones)?
I'm building a USB HID device using Arduino Leonardo mini clone, based on ATmega32u4. That particular IC has got a USB controller built in, and turning it in to a HID device is simple. You just need to include Keyboard.h and then use Keyboard.print...
Where can I set/define the name of the device that is shown, when that Arduino is connected to a PC, because at the moment it is named Arduino Leonardo.
The default automated name for tty is usbmodemHIDP1.
In system preferences, I can see:
ID product: 0x8036
ID vendor: 0x2341
Wersion: 1.00
Serial number: HIDPC
Speed: do 12 Mb/sek.
Vendor: Arduino LLC
ID location: 0x14200000 / 16
So where in Arduino is file Keyboard.h? Can I change that name, or ID's?
Is it possible?
Because in my opinion it should be, but I just can't find the right place, and I do not have experience with Arduino AVR as I was working with Microchips Mplab X before for different ICs ;).
The "iProduct" string sent by the board on enumeration tells the operating system to give it the human-readable name. The value of that string is set near the top of USBCore.cpp in hardware/arduino/cores/arduino/. It's a Unicode string, so we need looking for 'L', 'e', 'o', 'n' [...], not "Leonardo". The string used depends on the PID number of the device (also sent during enumeration) which is given in boards.txt.
For distributing own custom hardware based on the Leonardo, there is a need to provide your own VID.
Also there can be used alternative firmware.
The Arduino '32U4 bootloader, Caterina, can be found under hardware/arduino/bootloaders/caterina. It requires LUFA in order to build.
I have the RedBearLab BLE shield connected to Arduino UNO R3. I can connect to it using gatttool from a Rasp-Pi (attached CSR4.0 dongle). I have some sensors (FSR) connected to the analog pin and LED connected to digital pin in Arduino. My goal is to read/write to anything that is connected to the Arduino through BLE.
As a sample, I was looking into this link. It seems I need to know the handle of the sensor, config register # etc. to read/write.But I am not sure how to find the handle/uuid related to the sensor that is attached to the shield.
For example I see below.
[xx:xx:xx:xx:xx:xx][LE]> char-desc
handle: 0x0001, uuid: 2800
handle: 0x0002, uuid: 2803
handle: 0x0003, uuid: 2a00
handle: 0x0004, uuid: 2803
handle: 0x0005, uuid: 2a01
handle: 0x0006, uuid: 2803
handle: 0x0007, uuid: 2a04
handle: 0x0008, uuid: 2800
handle: 0x0009, uuid: 2800
handle: 0x000a, uuid: 2803
handle: 0x000b, uuid: 713d0003-503e-4c75-ba94-3148f18d941e
handle: 0x000c, uuid: 2803
handle: 0x000d, uuid: 713d0002-503e-4c75-ba94-3148f18d941e
handle: 0x000e, uuid: 2902
handle: 0x000f, uuid: 2800
handle: 0x0010, uuid: 2803
handle: 0x0011, uuid: 2a27
Discover descriptors finished: No attribute found within the given range
[xx:xx:xx:xx:xx:xx][LE]> char-read-hnd 0x0001
Characteristic value/descriptor: 00 18
[xx:xx:xx:xx:xx:xx][LE]> char-read-hnd 0x000b
Error: Characteristic value/descriptor read failed: Attribute can't be read
How do I know which of them is the FSR I have attached to the shield?
update
I am using RedBearLab example - simplecontrol
So Arduino and iOS/Android code both are there. My goal is to understand from gatttool's perspective so I can develop something similar (of iOS/Android) in Java running at Raspberry Pi.
From the code, I can figure out which address to write. For example - to turn on the LED attached to the digital out pin, below works
char-write-cmd 0x000b 010100
Similarly, to turn on the sensor reading capability, I need to write below
char-write-cmd 0x000b A00100
I know this works. I see expected output in the Arduino serial monitor. I am pretty sure it is reading the sensor but I can't see that in the RaspPi prompt. I think I need to enable broadcast reading capability at RaspPi end.
Any suggestion?
well, to beging working with BLE, you have to understand how the whole GATT stuff is working. Basically, you need to have some code on your arduino that sets up a profile in the nRF8001 component on your shield that defines "pipes" which is the link between a characteristic exposed by the radio (and seen using the gatttool) and a function from which you can read data or to which you can send data.
To modify and work on gatt profiles, and define those pipes, you need to use the nrfgo tool distributed by Nordic. It's windows only, but it works perfectly fine using wine on OSX or linux (I do it every day).
There you can load a profile and modify it or create a new one, it's up to you. I'd also advice you to look at the nordic examples in their devzone on how to setup a profile for nrf8001 + Arduino, those example are pretty clear.
Then once you've made all your characteristics, you can only read/write the characteristics you're handling. Having a characteristic available does not mean it can be read/written to, you may need to subscribe to it or it may always return an error. Remember that most of the characteristics you list are characteristics used by the gatt for having the whole gatt system work and usually is hidden by libraries abstracting the BLE stuff.
I have a temperature sensor, which is connected using an USB-I2C adapter (http://www.robot-electronics.co.uk/htm/usb_i2c_tech.htm)
I attached this device to my linux computer (suse10).
I typed dmesg and saw
usb 3-3: new full speed USB device using ohci_hcd and address 10
usb 3-3: new device found, idVendor=0403, idProduct=6001
usb 3-3: new device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-3: Product: FT232R USB UART
usb 3-3: Manufacturer: FTDI
usb 3-3: SerialNumber: A7007K93
usb 3-3: configuration #1 chosen from 1 choice
ftdi_sio 3-3:1.0: FTDI USB Serial Device converter detected
drivers/usb/serial/ftdi_sio.c: Detected FT232BM
usb 3-3: FTDI USB Serial Device converter now attached to ttyUSB0
But I have no idea how to read the current temperature.
updated 1: Actually the I2C bus can attach up to 127 sensors. But I have no idea how to list the addresses of available sensors.
Can anybody give me some hints? Thanks in advance
Your adapter allows you to send I2C commands over a virtual serial port. A serial port has been created for you. You need to open it and send commands to it. The commands are specific to the device you are connected to. See the example in the link you provided to get an idea.
It is hard to give you correct instructions without a datasheet. Most probably your device will use one byte address and the read procedure is as follows:
[I2C_AD1] [Device I2C address + Read bit] [Device Address register] [Number of bytes to read]
0x55 0xXX 0x00 0x01
You need to send 4 bytes to the serial port. The first one instructs the USB to I2C converter to send a read command. The second one is the address of the device attached to the I2C bus. I2C devices use 7-bit addresses (0-127). Usually these are given with one bit shifted at the left. Therefore you need to scan these addresses (iterate from 0 to 127, shift left one bit, set bit0 to 1):
([0x00 - 0x7F] << 1) | 1
Since we don't have a datasheet I can't tell anything about the last two bytes. You could try to use dummy values. If a device is attached to the scanned I2C address, it should reply with a NACK to an attempt to read a non-existing register. Read commands sent to an I2C address that doesn't correspond to an actual device should be ignored.