UPIs /MQTT

Post here your applications done based on UPiS
Share your ideas about new possible applications

UPIs /MQTT

Postby adeuxn » Sun Mar 15, 2015 10:53 pm

Hi All,

I am trying to write a bash script which is called by cron to publish to an MQTT topic the values from my Upis. However, I am struggling to convert the values from BCD into sensible values. The script is as follows:
Code: Select all
#!/bin/bash
# Assumes hostname contains FQDN with  server name as first part
ReportName=$(hostname|cut -d"." -f1)
PmRaw=$(i2cget -y 1 0x6a 0)
BattL=$(i2cget -y 1 0x6a 1)
RpiL=$(i2cget -y 1 0x6a 3)
UsbL=$(i2cget -y 1 0x6a 5)
EprL=$(i2cget -y 1 0x6a 7)
CrnL=$(i2cget -y 1 0x6a 9)

#Todo convert values
PmOut= # Do something? to $PmRaw
BattLOut= # Do something? to $BattL
RpiLOut= # Do something? to $RpiL
UsbLOut= # Do something? to $EprL
EprLOut= # Do something? to $CrnL
CrnLOut=

#Publish values to MQTT
mosquitto_pub -h localhost -t "/status/$ReportName/upis/pwr_mode -m $PmOut"
mosquitto_pub -h localhost -t "/status/$ReportName/upis/bat_level -m $BattLOut"
mosquitto_pub -h localhost -t "/status/$ReportName/upis/rpi_level -m $RpiLOut"
mosquitto_pub -h localhost -t "/status/$ReportName/upis/usb_level -m $UsbLOut"
mosquitto_pub -h localhost -t "/status/$ReportName/upis/epr_level -m $EprLOut"
mosquitto_pub -h localhost -t £/status/$ReportName/upis/crn_level -m $CrnLOut"


I have tried various versions of the formula enclosed in the other user apps, but the values make no sense. The raw values I get are:
0x02
0x05
0x61
0x70
0x74
0x75

The Upis is currently receiving power on the Upis usb so I would expect the external value to be 0? I am a bit baffled.

Thanks for any help

Ad
adeuxn
 
Posts: 6
Joined: Mon Jan 19, 2015 8:15 pm

Re: UPIs /MQTT

Postby Pimaster » Sun Mar 15, 2015 11:22 pm

Hi,

I 'm not a specialist of the language you are using, however just simply seeing it, I can say that BCD values are word and not byte, and I have the impression that you are using bytes, my be I'm wrong

BR PiM
Warmest Regards
PiM
---
Designing with Mentor Graphics PADS - www.pads.com
Please read and follow the PiForum rules
http://www.forum.pimodules.com/viewtopic.php?f=13&t=196
---
Pimaster
Site Admin
 
Posts: 1581
Joined: Fri Sep 14, 2012 7:50 am


Return to UPiS Users Application

Who is online

Users browsing this forum: No registered users and 1 guest