If you’re going to have a laptop or whatnot to run Firestorm, you can use the pixelblaze-client library to broadcast data from one sensor expansion board to the other Pixelblazes with this little program:
broadcastSensorData.py
#!/usr/bin/env python3
# Import standard library modules.
import argparse
from datetime import datetime
# Import third-party packages.
from pixelblaze import *
# ------------------------------------------------
def timeInMilliseconds():
td = datetime.now()
return (td.microsecond + (td.second + td.day * 86400) * 10**6) // 10**3
# Here's where the action starts.
if __name__ == "__main__":
# Parse command line.
parser = argparse.ArgumentParser()
parser.add_argument("--fromIpAddress", required=True, help="The IP address of the Pixelblaze to copy expansion board variables FROM")
parser.add_argument("--toIpAddress", required=True, help="The IP address (or comma-separated list of IP addresses) of the Pixelblaze(s) to copy expansion board variables TO")
parser.add_argument("--verbose", action='store_true', help="Display debugging output")
args = parser.parse_args()
print(args.toIpAddress)
# Connect to the Pixelblazes.
print(f"Connecting to source Pixelblaze @ {args.fromIpAddress}...")
with Pixelblaze(args.fromIpAddress) as src:
dests = []
for destIP in args.toIpAddress.split(','):
print(f"Connecting to destination Pixelblaze @ {destIP}...")
dests.append(Pixelblaze(destIP))
print("Mirroring expander board variables; press [Ctrl]-[c] to quit...")
numSamples = 0
lastVars = {}
lastTime = timeInMilliseconds()
extra = ''
while True:
try:
# Get the exported variables from the source Pixelblaze.
vars = src.getActiveVariables()
numSamples += 1
# Remove any variables not related to the expansion board.
for key in list(vars.keys()):
if not key in ['light', 'accelerometer', 'analogInputs', 'frequencyData', 'energyAverage', 'maxFrequency', 'maxFrequencyMagnitude']:
del vars[key]
if args.verbose: extra = f": {vars}"
print(f"Received frame {numSamples}{extra}\r", end='')
if len(vars) > 0 and lastVars != vars:
print(f"Sending frame {numSamples}\r", end='')
for dest in dests:
dest.setActiveVariables(vars)
# Back off for a while, since the sensor board only updates every 25 millliseconds.
thisTime = timeInMilliseconds()
deltaTime = 25 - (thisTime - lastTime)
lastTime = thisTime
if deltaTime > 0: time.sleep(deltaTime / 1000)
except KeyboardInterrupt:
print('')
break