Visualise bit data in emoncms

hi

on a hydro station we get system alarms in bit-form. something like “10101010” which will be stored in emoncms as decimal “170” and showed as graph something like http://appenzeller-energie.ch/furth_pilot.php#alarm2 .

is there a way in emoncms to extract the bits and show them in a more readable way?

thanks a lot

How do the alarms get into emoncms in the first place?

hi stuart
they are read out by emonpi (via serial interface i guess) and then sended decimal to emoncms.

easiest would be to unthread the input signal in emonpi to an output for each bit and send it to emoncms.
since i do not have direct access to the emonpi, i was thinking to do this on emoncms. AND there is also the question of performance. we do have a very slow internet connection to the station. sending 20 alarm instead of 2 makes a matter.

actualy i guess almost everything must be there in emoncms? virtual feed > process (getbit 3)(how to develop such a process operator?) > provide it as a feed which can be implemented in a website like in emoncms dashboard “led”.
???
sorry, i’m quite new to emoncms :slight_smile:

thanks

I think Paul @pb66 is best placed to answer - this seems to be a problem for emonHub. There is at present no decoder for a bit field.

I think @stof999 would have to tell us more about the data and how it is transported before I could say anything useful about emonhub. as emonHub currently only decodes down to bytes not bits so this would need other areas explored.

I think this has been discussed before and transporting the data to emoncms would be more concise when done as a group of booleans sent as a single decimal value. An as far as emoncms is concerned there is no mechanism to store single bits, the phpfina and phptimeseries store data as a 32bit float which is overkill for a single bit.

It would be easy to create some bit handling processes in emoncms, A process to read a user defined bit from a 32bit feed value would be simple or even 2 processes to bitmask (using a user defined decimal number) could allow more complex processing eg if all defined bits are true or if any defined bits are true.

Likewise, the feed value could be manipulated by a process that can read the current feed value and apply a bitmask before saving it again.

I think these would be quite useful. I expect it would also be pretty trivial to set up virtual feeds based on one using of these new processes (above) on an actual source feed so that not only can they be used in dashboards (eg leds) but they can also be queried via the feed api, possibly to control actions or raise alarms etc.

In the past, I’ve played with something like this in emonhub to monitor 8 gpio pins and combine those into a single decimal byte to forward to emoncms rather than breaking out a byte into bits to send, I did however consider the reverse of reading the gpio pins and setting them by receiving a single byte value and breaking that out to set the gpio (output) pins but that’s a different thing and also requires a way to define gpio pins as input or output in emonhub too.

If there was enough interest in it, I know how and where to create additional processes, initially in a separate add-on module if we wanted to experiment further. I’ve been meaning to finish a couple of new processes I started writing a while back too. One was to only save to a phptimeseries feed if the value changed (could be very useful for a bit feed) so that, for example I send firmware revision in my node payloads and I want to just record when they change, not what they are every 10secs nor what they are max/min each day. The characteristic of this process was that if the new value matches the existing feed value it does nothing, if it has changed it will write 2 new data points one at timestamp-1sec with the old value and the new value at the correct timestamp, this would show as a vertical step on graphs rather than a steady change since the last value. The other was just to sum feed values based on including a keyword in the feed name eg sum all feeds that have solar_power in the name, so L1_solar_power, L2_solar_power and L3_solar_power all get totaled etc.

hi @pb66

the “bit” alarms are stored in the feed table as signed integer (ie -32768). i don’t know who (sps, emonpi, emoncms) migrates the “word” to a integer.

but, as i guess, the easiest would be to build in node-red for each bit an own node which then can be showed in the emoncms dashboard with the already implemented “led” visualisation.
thats what i suggest to the emonpi responsibles of our voluntary club. have a look…

but maybe a new “getbit” process could be helpful for others in the future. if you could give me a hand where to start for adding a process (docu on wiki?), i will try.

thanks a lot