Water Meter instructions for newbie

Started by zigam, February 03, 2014, 05:28:00 PM

Felix

Hey zigam,
For chat.html you can use the IP of your Pi. I used PHP to create that dynamically depending on where you serve the html page from (host IP).
For a simple test from your own LAN you can hardcode the Pi's LAN IP.

Nginx will be faster and less RAM/CPU intensive on the little Pi.
EmonCMS guys should consider porting to Nginx.

I don't know what are the best recommended settings or distribution for EmonCMS. I think their distribution will come with Apache. You should have no issue with installing EmonCMS ontop Nginx as long as PHP is installed already. EmonCMS is just a PHP app with mysql backend (or Timestore!).

You could certainly add a page to your EmonCMS install and link it on the EmonCMS home page, and display all your other automation stuff there. Then wrap everything in SSL like i did for my simple websockets page, if you really care about that.


zigam

#16
Hi Felix

Now I think I am very close

Can you please check the following settings in gateway.py

# 
### GENERAL SETTINGS ###
SERIALPORT = "/dev/ttyAMA0"  # the default com/serial port the receiver is connected to
BAUDRATE = 115200            # default baud rate we talk to Moteino

### USE THESE NUMBERS TO TWEAK YOUR KAW ADC input SAMPLING ###
CURRENTNORM = 15.8           # conversion to amperes from ADC
VOLTAGENORM = 0.94           # multiply each volt sample by this

MAINSVPP = 169.7 * 2         # +-170V is what 120Vrms ends up being (= 120*2sqrt(2))
SAMPLECOUNT = 28             # expected sample count per packet
GRAPHIT = False              # default of whether to graph V/A/Watts
NUMWATTDATASAMPLES = 1800    # when graphing, how many samples to watch in the plot window (1800 ~= 30min)
DEBUG = False

# EMONCMS Settings
EMONPOST = True
EMONAPIKEY = "here I will put my Read & Write: Feed API code"
EMONHOST = "emoncms.org"
EMONHOSTPORT = 80
SUMP_LVL_LIMIT = 20
SUMP_ALERT_LASTSENT = 0


And than I run python /home/ziga/gateway.py but nothing happend. After a while I pressed ctrl+c to cancel. What am I missing

root@RaspberryPIServer:~/moteino# python /home/ziga/gateway.py
^CTraceback (most recent call last):
  File "/home/ziga/gateway.py", line 358, in <module>
    MAIN()
  File "/home/ziga/gateway.py", line 290, in MAIN
    line = ser.readline()
  File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 461, in read
    ready,_,_ = select.select([self.fd],[],[], self._timeout)
KeyboardInterrupt

Felix

The settings look ok, but that's very little to go on. What did you expect to happen?
What are all the non-EmonCMS settings for? are you running some KillAWatts with Moteinos?
Ctrl-C will cause the program to end and throw that error you included, not surprising.

zigam

Quote from: Felix on February 21, 2014, 12:46:35 PM

What are all the non-EmonCMS settings for? are you running some KillAWatts with Moteinos?


No no I am trying to get water usage. Hopefully.

zigam

Hi Guy's today I spend another 13h working on this water meter but I feel like I am going around and around.

Just need some guidance please. So let us try from from the beginning.

At home (apartment in a building) I have three water meters. Two for cold and one for hot water. So now I have four moteinos one to server as gateway and other three as node's

I have successfully uploaded the gateway and node's with sketches. I have change the the ID's so they have all unique one (22 cold, 23 cold and 24 hot water).

When connected to to my PI I can see data send to my gateway showing (using screen /dev/ttyUSB0 115200,-parenb,-cstopb,cs8 or cat /dev/ttyAMA0 )
22  GLMxx and GPMxx with
23  GLMxx and GPMxx with
24  GLMxx and GPMxx with 
etc...

What I would like to do now is that every 25. in the month Pi would send an email with total usage of hot and cold (22+23) so from eg. 25. jan till 25. feb I use xx L of Hot and xx L of Cold water. For the conversion from Gallons to Litter I will manage.

I was thinking if possible to use python script to this job (any suggestion is welcome may be some other script) . I would just put the script to cron job and that would run the every 25. of the month. But getting the data from node 24,  and than multiplying 22 and 23  that is a bit out of my scope. I know little basic on python but any help is more than welcome.

Question:
Should I use Raspbian for base OS on my PI? or do you recommend something else.

Of course a nice graphic design like EmonCMS would be perfect but for now I will lower my standard and just try to get email working. But I don't want to throw EmonCMS option away, what I did so far I tried to install the EmonCms in the following steps.
Downloaded from site and made copy in www/emoncms folder created SQL database.
Then problem was when registration. When I hit the registration button a red bar open with no text. According to forums I should get some text with in this red bar but that is not in my case.

I even tried installing the R_Pi Emoncms oem gateway image to the Pi but I guess I got stuck at the initial settings   (http://emoncms.org/site/docs/raspberrypigatewa)

This I should adjust to get reading from moteino
# OemGateway Configuration file example
# Copy this as oemgateway.conf (or any custom name) and edit settings

# Each listener and each buffer has 
# - a [[name]]: a unique string
# - a type: the name of the class it instantiates
# - a set of init_settings (depends on the type)
# - a set of runtime_settings (depends on the type)
# Both init_settings and runtime_settings sections must be defined, 
# even if empty. Init settings are used at initialization, and runtime
# settings are refreshed on a regular basis.

# All lines beginning with a '#' are comments and can be safely removed.

####################
# Gateway settings #
####################
[gateway]
# loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
# see here : http://docs.python.org/2/library/logging.html
loglevel = DEBUG

#############
# Listeners #
#############
[listeners]

# This listener manages the RFM2Pi module
[[RFM2Pi]]
  type = OemGatewayRFM2PiListener
[[[init_settings]]]
  com_port = /dev/ttyAMA0
[[[runtime_settings]]]
  sgroup = 210
  frequency = 8
  baseid = 15
  #time period to update time clock on emonGLCD
  sendtimeinterval = 300

# This listener gets data from a socket
[[Socket]]
  type = OemGatewaySocketListener
[[[init_settings]]]
  port_nb = 50011
[[[runtime_settings]]]

###########
# Buffers #
###########
[buffers]

# The two following buffers instantiate the same class, 
# that formats the data for an emoncms instance.
# One sends the data to a local instance, the other one
# to a distant one.
# If active is set to False, the buffer neither records nor sends any data,
# but it holds unsent data until active becomes True.
[[emoncms_local]]
  type = OemGatewayEmoncmsBuffer
[[[init_settings]]]
[[[runtime_settings]]]
  domain = localhost 
  apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  protocol = http://
  active = False
  path = /emoncms

[[emoncms_remote]]
  type = OemGatewayEmoncmsBuffer
[[[init_settings]]]
[[[runtime_settings]]]
  domain = emoncms.org
  apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  protocol = http://
  active = True
  path =


I even tried Raspberry Pi + Harddrive + Emoncms http://emoncms.org/site/docs/raspberrypihdd but same setting issue.

So as I guess Felix you didn't use any of the pre Emoncms build's on Pi you used the one that was copied to /www/emoncms. I am right? or did you just send the data to http://emoncms.org/ using the gateway.py script. 

Cheers Ziga




   

Felix

Hey Ziga,
Sorry but I did not use a prebuilt EmonCMS distro. I installed it manually sometime last year. I remember it was not quite straight forward, some tweaking to get it to work but can't remember details. I did use the python script to push data into EmonCMS, as seen in this script: https://github.com/LowPowerLab/WattMote/blob/master/WattMote.py

I'm afraid I'm not confident enough with giving a recommendation as to what distro to choose. I always used the official raspbian and kept images of it with different levels of settings/software installed. When I messed it up with experiments I could go back to an image without having to start from scratch. I'm no linux expert so that saved me lots of time.

zigam

Hi Felix

One question with water script I am getting GPM all the time.  Even if nothing is connected to the node

usually its GPM: 66.66
[23] GAL:1501.22 GPM:83.33   [RX_RSSI:-88]


If I hold the Node with my hand the GPM even increases?

zigam

One more thing

How can I erase to 0 or modify the GAL value

Felix

You should have connected the sensor with a pullup. Otherwise that input may float around and give you false readings.
The sketch I published for watermote stores the values in EEPROM, so write a sketch that will erase your EEPROM, something like:

for (i=0; i<1024; i++)
  EEPROM.write(i, 255);

zigam

Hi Felix

Thanks for the replay. I am doing baby steps but every day I am closer to my success :)

I figure it out that the Impulz-Modul PM +m 100l/Impulz that I want to use creates interrupt signal every 10L

The signal is interrupted for aprox. 0.5-0.8s.

So on the remote display (this one that is now connected to Impulz-Modul) that is showing xxxx.xx value. Every time I use 10L of water it changes for 1 value,  eg. 0034.45m3 + one impulse = 0034.46m3.

So now I need to figure it out how to modify the node that will show only the TOTAL water usage since I can't really see the current usage in L only every 10L.

Like I said I will try to play around, but if somebody finds any spare time to help me with the code that would be nice.


zigam

Hi Felix,

What kind of pullup resistor should I used. For testing I used 10kohm but still I am getting some weird indication.

When I make interrupt signal the change is for between 5.6 - and up.

I want to achieve that for one interrupt signal that change would be 0.01

Felix

I don't know what you mean by "5.6 and up" and "0.01"
A pullup should be anywhere from 1K to 10K or even more. Depending on the application, if you care about current drain through those pulled up pins then choose a high value.

zigam

By 5.6 or more I am referring to GPM change. Your scheme is set to 0.22 for one pulse right? For one interrupt I would like to get GPM: 00.01.

zigam

Sorry Felix for the confusion what I want is to disregard the GPM and change GAL for 0.01 for every impulse. This would are the settings that I would like :)

Felix

Hm .. I believe you're using a sensor that I'm not familiar with. Could you provide more details about it? Any datasheet?