Everything Xbee


#548

How simple, why did I not see this! Anyway the network now shows up. Many thanks.


#549

Alright guys, got my first order of Xbee's yesterday and man am I loving these little things!

Here comes my first contribution:
I have created a small mircopython app that runs on the XBee which sends every minute the current voltage attached to the Zigbee. In additon, I have created a new device driver that is a Presence Sensor and exposes the battery status. I think you already know where I am going with this. I am going to try to install an Xbee powered by batteries in a car to see how reliably you can get presence detection with these guys. I am just waiting on an Amazon order for some parts.

However, what I have now is already usable, even for Router XBees.
You can find my device driver here: Hubitat/xbee.groovy at master · danTapps/Hubitat · GitHub
Just install it in Hubitat and assign it to your Xbee devices in Hubitat

Here comes the installation for the XBee.
First and foremost, you have to change the parameter PS to 1. This will tell the XBee to run a script on start.
Download my little script Hubitat/main.py at master · danTapps/Hubitat · GitHub
and name it main.py
With XTCU, transfer this file to your Xbee (XTCU->Tools->File System Manager) and just store it right in the root folder.
Reset your Xbee and you should receive updates in Hubitat in regard to presence and battery. The first update might fail as the device is not connected to your Zigbee network yet but you should see an update within 2 minutes. The little python app tries to send it every 60 seconds.

Why is this helpful even for a Router? You can see that your Router is alive and actually connected to Hubitat. Let's say the router has an issue, the device driver will change the presence status from "present" to "not present" and you can be alerted about this.

I have tested this with an XB3-24Z8ST and firmware 1006, however, I am doing nothing specific here and it should also work with other devices/firmware versions.

All the other functions of the Router XBee are not affected, you can still to spectrum analysis, mapping, etc.

Hope this might be helpful for someone.....


#550

I knew someone smarter than me would eventually figure this out.
Interesting you were able to do it as a router instead of an end device.
Can not wait to try it out!


#551

My "in the car" Xbee will be an end device, including going to sleep mode to preserve battery.
As a router, you can still send packages to the coordinator (hubitat) and that is exactly what is being done here. Nothing different than a main powered outlet does that acts as an repeater.


#552

In my car I am just going to power it off the usb or rearview mirror power so it will only have power and show presence when the car is turned on.

My other car I use a SmartThing Arrival sensor (3 volts).
I rewired to 2 AA rechargeable batteries and wired a charging circuit board to it then plugged into a USB port in the car. So it charges the batteries whenever the car is running.
I have never had to change batteries.
The range is not great with the Arrival sensor though.
But I could do that for power as well.

2 AA may not be enough to power the Xbee though I would have to check but I think they need 5 volts.
So 4 AA batteries or a rechargeable USB battery pack but it is very hard to find ones that allow low voltage draw.
Most have low voltage protection built in which prevents them working with Xbees or other low voltage devices.
Search for battery packs that work with rasberry pi or Arduino and you might get lucky if the manufacturer has'nt updated the battery pack hardware.


#553

They operate from 2.1V to 3.6V. The USB power you supply is regulated down to 3.3V. I am more concerned about current but will have to play with that for a while


#554

Hi Xbee gurus,
I am hoping that people here will be able to advise me if Xbee is a solution to a potential problem.

I have a few items on there way from china including Xiaomi door sensors, Xiaomi Aqara Temp/Humidity sensors and Gledopto soposh light bulbs. My potential problem is, alot of this gear will be going in a part of the house that I'm not confident that it will communicate well with the HE. I only have one Zigbee switch in between the HE and planned location. The switch has also been reported to not route well. My plan is to build a Xbee router and place it central to the area with these new devices. The distance from the Xbee to the sensors and lightbulbs would be about 3 meters going through a one brick wall. Distance from the HE to the Xbee would be about 8 meters going around 1 corner. Direct from Xbee to HE would be a couple meters less but have to go through 2 brick walls.

Could anyone advise me if you think this setup would potentially work? I have also red in this forum that when using Xbee with Xiaomi you need a non A version of the xbee. Is this still true?

regards

Marko


#555

I have never heard of these but since they are zigbee they should be fine.

Will work great for the Xiaomi devices

not sure which you are referring to regarding the non A version
the only non A version I know of was not regarding Xbee but for Sylvania SMART+ Plug 72922 working with Xiaomi devices

Xbees MUST be zigbee versions of course


#556

Let's see/hear some of the ways you're housing and powering your Xbee modules.


#557

@dan.t I submitted a pull request in Github for the driver to add the Enable/Disable function from the ST Arrival Sensor Advanced driver. This allows the user to disable automatic detection of presence and set it manually during that time. VERY useful when your device isn't going to be battery powered. I've been using this code for a while it doesn't seem to have any issues that I can tell with your driver. So, @NoWon, this would be how you would be able to power off your cars 12v system and not worry about the sensor arriving when it is powered on in your garage.


#558

Had a question for the experts here....I'm looking at the XB3-24Z8ST-J:
image
Because I want to be able to mount the antenna outside my garage door under the overhang. When i approach my garage, I'm almost perfectly lined up with the door and I think I am getting interference with the giant metal door that's in my way. So, I figured with this one I could mount the antenna outside. So, which antenna is best to use? I've been looking on amazon and there are just so many different kinds and some say 5ghz and some say 2.4 and some say dual. I know i want one that supports 2.4 but would a dual also work okay? For example, would this one work:

Any advice on how to pick one out or tell a good one from a bad one would be very, VERY appreciated.

Thanks!!!


#559

I am using an old (15-20 years) 2.4 Ghz 9 or 12 dBi (I don't remember) I dug it out of my junk box which works fine.
Most of these new ones that use magnetic bases use weak magnets likely because strong magnets could cause interference.
also you will want to point the antenna straight up or down.
A dual band should work fine.
I generally choose the Amazon prime product with the most number of good reviews.


#560

Thanks!


#561

very impressed!
They were not kidding about the range!
finally had time to test out one of my Xbee3 XB3-24Z8ST as an arrival sensor
I changed it to an end point and used an old Asus dual band wifi antenna (maybe 1-2 dbi could not find the specs)
asus
set on the dash of my car.

and an old 2.4 wifi omnidirectional antenna (I think it is a 12 dbi) attached to another Xbee3 XB3-24Z8ST set as a router in the second floor corner of my house.

It picked picked up the Xbee3 arrival while driving 1/2 mile (600 meters) away.
I could likely do better with a better antenna in the car but 1/2 mile is plenty.

compared to the SmartThings arrival sensor which will only pickup at best when walking 2-3 houses away or in the car it is usually in the driveway before detected.

driver issue: (cosmetic)
The Xbee3 device display shows 2 sets of
"Minutes elapsed until sensor is not present *"
one says "click to set"
and the second says
"3 minutes"
I set both to one minute and they still display
"click to set"
and
"3 minutes"
but still functions with the selected 1 minute selection.

As far as powering the Xbee3 arrival in the car I am going to leave it only powered using USB so it is only present when the car is running. This way if any of the kids get out in the garage and keys happen to be within range of push to start or command start happens to start the car my garage door will open.

I updated the original post for end point settings (I didn't need to change SP settings)
AP = 0 (for an end device)
SM = 5 (has to be not 0 for end devices)
and I just pressed reset on the USB board to get it to change from router to end device.

Thanks Dan.t !


#562

Come on guys! I was perfectly content with my little chip antenna Xbees. Now I have a voice in my head repeating, “Need more range”. Back to Mouser, I go.:smiley:
All joking aside, thanks for another fun project!


#563

Love it. I didn’t get to play as much I wanted to yet as I am traveling for work. I am not sure if a 1/2 mile is too much for me... I might have to play with the PL parameter a bit to find the sweet spot, would rather fire presence a bit closer to home.


#564

I just tried this out, and it works great! I had to use my Xbee 3 as my Xbee S2C did not have the PS parameter, presumably because it is not a programmable model (I think that distinction was done away with in the Xbee 3 generation, as I no longer see them listed separately). I also had to put the main.py file in /flash not in / (what I'd call "root" having no experience with the device). I did not have write access to /, and the Xbee docs suggest /flash is indeed the correct location (and also the default). I'm also getting a Groovy error for line 136 of the driver, def timeSinceLastCheckin = (now() - state.lastCheckin ?: 0) / 1000, about an overloaded minus operator and inability to determine which is appropriate to use (obviously I don't remember much about this error and it's long gone in my past longs, so we'll see if it comes up again--may have just been something that happened the first time the driver ran).

Oh, and I'm not really using it as a presence sensor. I just want a way to know that my Xbee is checking in with Hubitat and staying on my network. To that end, I set the timeout to 5 minutes in the driver preferences (would probably make this a bit higher if I didn't have to modify the code), changed runEvery1Minute to runEvery5Minutes (so it checks less often too), and I changed the Python on the Xbee to only wake every 5 minutes as well. This way, I figure my Zigbee network will get less traffic and I'll get resolution somewhere between about 5 and 10 minutes for determining whether my Xbee has been offline (i.e., "not present") for a while. I might actually venture into using one as a real presence sensor some day (have to figure out power...), but this is still great for now. Wouldn't do much good for me since I rarely drive, but could be good for telling if roommates or whatnot who do are here and adjust my automations accordingly. :slight_smile:

Thanks for your contribution!


#565

@dan.t
first I was wrong the "minutes elapsed until sensor is not present" has stayed at 3 minutes it is not taking the selected change.

quick questions
you have the micro python transmit battery every minute which it is.
but looking at the logs the presence check in varies from 76 seconds to 12 seconds it appears to drift in check in time.
How is the check in being triggered?
I see in the main.py code you have
time.sleep_ms(60000) will it delay the initial response for check in if in sleep mode? (do I really need this since I will not be using a battery)

Why I am asking is you can drive quite far in 76 seconds if the cycle happens to transmit just outside of the zigbee range.
I drove around a bit testing other antennas in the car and could reliably get on average at least a 1/4 mile every time.
Sometimes less though sometimes more.
So range will depend on peoples antenna setup and check in timing.
The SmartThings Arrival sensor reports every 20 seconds it does not appear to drift.

Since I will only be powering mine when the car is running I will not have to worry about flooding the hub with info or draining an Xbee battery.

so far it has been very reliable.

@bertabcd1234

What exactly did you change/add in the python code?

import xbee
import time
import binascii
import sys
x = xbee.XBee() #Create an XBee object
while True:
voltage = x.atcmd('%V')
print("Voltage at " + str(voltage))
tx_req = ("7E"+"00"+"05"+"2D"+"01"+str(voltage))
try:
xbee.transmit(xbee.ADDR_COORDINATOR, binascii.unhexlify(tx_req))
except:
print("Error occured to send package, probably not connected to ZigBee network")
print("going to sleep now")
time.sleep_ms(60000)
if x.wake_reason() is xbee.PIN_WAKE:
print("woke early on DTR toggle")
sys.exit()


#566

I am traveling right now so it is hard for me to test/debug things. But here are some answers:

Even though you don’t use batteries, the message is used to detect presence. The idea in the code is to send the battery status on a regular basis and the driver takes that battery message to detect the xbee being present. After a timeout of X minutes not receiving that message, the driver will make the Xbee as not presence. There is no “disconnect” message that the Xbee sends.

You change the time.sleep_ms to 300000, that reflects 5 minutes. However, you would also need to change the driver. I would not expect those skew times your are seeing. At least I haven’t seen them and I have that code running on my router Xbee right now. But I will certainly look at it.

In regard to range: I would actually not change anything in the code. First thing I wanted to try to play with the PL parameter of the Xbee. I bet you have it set to 4 which is maximum power. Set it to 1 and see how far you will get. I bet it won’t be a 1/4 mile anymore.

I am back home by the end of the week and will continue my testing and cleaning up those code errors. I also ordered myself a 3V LCD display to connect to my “driving around Xbee” to have an easy way to see what the status is while driving around.


#567

ok I understand
I misunderstood the logs I was reading like a SmartThings arrival sensor log.

that is just the "sensor checked in" time in the driver since the last battery report.

So then I would actually want the battery check in a lot more often since you can drive fairly far in 1 minute.
The 1/4-1/2 mile is just fine for me as is but most people will not have a 12 dbi antenna laying around. So being able to send the battery report more often would be better.
like every 20-30 seconds Similar to the SmartThings Arrival sensor reporting.
This would make the range of check in a lot narrower.

I am going to test 2 - 5 dbi antennas one on each Xbee and see what sort of range they do as this is what most people will have lying around.

as far as the driver display for devices and displaying double
"Minutes elapsed until sensor is not present *"
it only showed double on my end device and did not change settings on it
On my routers it showed a single set and changed fine.
so I deleted the Xbee3 end device and re added it now it appears fine and takes the selected changes
very weird Hubitat glitch