Modify bluetooth low energy scan parameters - bluetooth-lowenergy

I would like to scan for a beacon which sends advertising packets every 330ms. The payload changes at every advertising interval so that I have to receive as many packets as possible.
I use a Raspberry Pi 3 B and bluez 5.43 (hcitool –i hci0 lescan --passive --whitelist --duplicates). But it seems I only get one advertising package every 1.28 seconds. I have not found a way to set scan window and interval. I have already researched extensively on the Internet, but could not find a solution.
I am very grateful for any help!

Related

Zigbee Device, last communication time with the gateway

I've read around about the communication between battery powered Zigbee devices (sleepy end devices) and the gateway
for example: https://www.qorvo.com/design-hub/blog/demystifying-polling-control-in-zigbee-networks
So I get that the device call the gateway every long_polling to check for new commands/data:
would it be possible to know, for a specific device, the time of the last received packet?
Alternatively, I'd like to know every time a packet arrive, so I could extract the ieee (the device identifier) and update somewhere the current time.
In my case, I have a PC with a connected ConBee II, running Home Assistant and ZHA.
I'm interested in determining if the device is still online, and since it periodically communicate with the gateway, I'd like to leverage this behavior.
(Home Assistant will receive a value update every 15 minutes, but I'd like to know if the device is offline in less than a minute)
The device is a Aeotec Multipurpose Sensor (also reported as Samjin Multi)
These are the configured values
'checkin_interval': 0 = disabled
'long_poll_interval': 28 = 7sec
'short_poll_interval': 1
'fast_poll_timeout': 40 = 10s
'cluster_revision': 1
So my device will communicate with the gateway at least every 7 seconds, right?
I kinda can confirm this because though home assistant I can make a LED on the device blink, and the max observed time is about 7 seconds.
Any help would be appreciated,
cheers

Serial Port Data read

I am facing the following problem. I need to connect a sensor to a pc via serial port. i know exactly the values of baud rate (38400), 8 data bits, 1 stop bit and no parity. So i connect the sensor to the computer and i am not seeing any data transmitted to the pc. Note: the sensor is read only. i mean that there is not any handshake.
Do you have any ideas about why i don't get any data?
the connections are ok because i am connecting another device and in the other device i am able to read data.
Thanks everybody in advance!
it could be HW problem. Can you test it on different computer? From where is the sensor getting power? Some parasitic powering on DRT,RTS lines?
The easiest way is using oscilloscope/digital analyzer to see what's going on the line. With sound card oscilloscope like https://www.zeitnitz.eu/scope_en you should be able to see at least some bursts albeit it's sampling frequency is to low to see the data.

Monitoring SOlution for Arduino

I have an Arduino project for solar tracker running. Initially I used the serial monitor to view data with my laptop. Now I'm moving my project about 1000 meters from my home. I want to remotely monitor the data from solar tracker parameter like date, time, track angle, coordinates, etc. updated every 15 minutes.
What would the best best protocol used for long distance transmission? Should I do zigbee, wireless, ethernet, modbus? If particular protocol suggested let me know why it being suggested. I also want to use the least number of pins to do this.
I Googled it and I found an ethernet shield with SD card. I never wanted it to get recorded on a SD card. The data should go directly to the PC.
if you can use a cable connection, as they are the most reitable.
RS485 is the best for bucket (100 kbit/s at 1200 m), optical fiber is very expansive but optimal.
classic ethernet has range of 100meter, wifi without special equipment about 50/100m, some zibee has a maximal range of 1Km, so MAY be the solution, but are at their limit.
Modbus is a "high level" protocol that can be used over RS485 (or other connection)

Most efficient method of communication (Theory)

I have an Arduino Uno connected to a PC via USB and I am communicating via serial to a temperature sensor from PHP.
At present, the temperature sensor records a value and sends it straight down the serial connection to the PC. However, this may not be read for a long period of time. Therefore, I think this method may be inefficient.
I was thinking I could listen on the Arduino for a serial message from the PX requesting the temperature before actually checking it and sending the message back to the PC via serial, therefore becoming more efficient as its not checking the temperature every 0.1 seconds.
My Questions are as follows:
Is this actually worth doing from a code efficiency point?
Is there a better way to improve this than my suggested method?
Would these changes improve battery performance (Eg if I was using a
different communication model and not Serial and therefore might
need a batteries)
A1: Since you already have the routines to measure the temperature and then send it to the PC there should not be much coding left to do to wait for a trigger from the PC before performing the routine.
A2: There always is a 'better' way :)
A3: If your µC does not have many other tasks to perform that keep it busy you can definitely save a lot of juice by putting the µC to sleep between those short periods of activity - which you should do anyway when running off batteries.

Ethernet begin blocks for 60 seconds if there's no Ethernet cable

I'm building a clock. I want to set the clock by plugging an Ethernet cable into the clock. Most of the time the clock would not be plugged into the Internet.
I have an Arduino board and an Ethernet shield that can successfully connect to a time server and read the time (See the UdpNtpClient example file under Examples > Ethernet).
The problem is that to configure the Ethernet shield, the Ethernet.begin() call blocks for 60 sec if the shield is not connected to the Internet. I would like the clock to tell the time and periodically check to see if it has an Ethernet cable plugged in, and if so, make any corrections to the time. Most of the time this check is going to have a negative result, however, so I can't have the clock freeze for 60 sec each time.
Is it is possible to detect if the cable is connected in a quicker way than the Ethernet.begin() function? Is it possible to write a "multithreading" solution, where Ethernet.begin() is non-blocking?
Looking at the stock Ethernet library, it's not possible to prevent it from blocking.
I'm guessing you're using DHCP? This appears to be where the blocking comes from. Do you get the same problem when using a static IP address?
There's a number of blog posts available on Google covering this exact issue, including some forks of the Ethernet library that would allow you to do this in a non-blocking fashion.
In the DHCP.h header file you can find the class definition for a new DHCP connection.
Then you can see that there is a default timeout value of 60000ms.
(helpful hint: if you get past the initial effort, and start using eclipse to manage your adruino projects, its really great because you can just press F3 on a functions like Ethernet.begin and take a bit of a trip through the libraries to find these types of settings)
Its difficult to know how long the timeout should be. But a minute seems like a really long time. Of course you don't want to go to short.
I wouldn't go less than 15 seconds.
/David Cox

Resources