Water Meter instructions for newbie

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

zigam

Hi all,

First I would like to say great job Felix on your projects. I have just received my Moteinos (already burned one  :o, but I fix that) and I am very anxious to start on my water reading project with Moteinos. Not to forget I am newbie in this sort of programming.

So I am trying to program Moteinos using the FTDI. I have installed the Arduino on my Linux Mint OS. I have downloaded the and importer the RFM12B, RFM69, SPIFlash to library. Also I downloaded TimerOne from https://arduino-timerone.googlecode.com/files/TimerOne-r11.zip

If I open WaterMote.ino I see that there is #include <RFM12B.h> shouldn't I use RFM69? To apply configuration to Moteino with Arduino I just open the xx.ino file modify the entry and at the end execute upload. This is correct. I was reading the tutorials but still careful before I start uploading stuff.

It is possible to brick the Moteino or I can overwrite any time? 

How/Can I change from Gallons to Liters

Should I install WaterMote.ino on all my (3 three for transceiver and 1 for receiver). How do I connect receiver to my RasbPI?

What setting should I do on RasbPI to start collecting and writing data to SQL base.

As said at the beginning I am fresh in programming so please be patience. I might need some extra explaining than others.

Cheers Ziga

KanyonKris

Welcome to Moteinos. I'll try to help.
Quote from: zigam on February 03, 2014, 05:28:00 PM
If I open WaterMote.ino I see that there is #include <RFM12B.h> shouldn't I use RFM69? To apply configuration to Moteino with Arduino I just open the xx.ino file modify the entry and at the end execute upload. This is correct. I was reading the tutorials but still careful before I start uploading stuff.

It's almost that easy. The RFM68 library has slightly different commands because the RFM69 radio modules have some new capabilities. So open up the WaterMote.ino file in the Arduino program (aka IDE - Integrated Development Environment) and compare with a newer example like GarageMote (https://github.com/LowPowerLab/RFM69/blob/master/Examples/GarageMote/GarageMote.ino) that uses RFM69 and make the appropriate changes - search for all the "radio" stuff. You will not need to use radio.Wake with RFM69, and for transmitting you will probably want to use sendWithRetry.

When you think you've got the code right, click the upload button and it will compile your code, or give you an error if there's a mistake. After your code compiles, the new program will be sent to the Moteino attached to the USB FTDI cable. In the Arduino IDE you will need to set the Tools | Board to Uno and the Port to the one used by the FTDI.

Quote
It is possible to brick the Moteino or I can overwrite any time? 

Very unlikely you'll brick a Moteino. It has a bootloader, a small program in it's own flash memory, that should always allow you to upload new programs. Essentially you don't have to worry about reprogramming it over and over.

Quote
How/Can I change from Gallons to Liters

Google the unit conversion factor and apply it to the code that converts pulses from the sensor to gallons. Or install the sensor and count how many pulses it takes to fill a liter bottle.

Quote
Should I install WaterMote.ino on all my (3 three for transceiver and 1 for receiver). How do I connect receiver to my RasbPI?

WaterMote goes on the Moteino connected to the water flow sensor. A different program goes on the gateway Moteino. There are many examples, do some research on this forum, the blog and the github examples.

Quote
What setting should I do on RasbPI to start collecting and writing data to SQL base.

That's a big question with many solutions. I use a Python program on my RasPi to talk to the Moteino via a serial port. I'm just logging to a text file for now but will probably move to a database. Python is a pretty easy language to learn.

Felix

THanks for the help Kris,
FWIW there's an interesting logging database developed by Mike Stirling, haven't tried it but it's supposed to be optimized for logging real time data points, store them in a lightweight fashion without the bulk of a large DB system and most importantly offer fast aggregation: http://www.mike-stirling.com/redmine/projects/timestore

KanyonKris

Felix,
I checked out the website, timestore sounds good. I see timestore has replaced mySQL for Emoncms as of v6, that's a strong endorsement. And it runs on a RasPi OK:

http://openenergymonitor.blogspot.com/2013/07/from-13-minutes-to-196ms-timestore-on.html
http://openenergymonitor.blogspot.com/2013/07/emoncms-powered-by-timestore.html

I also learned about flot for graphing, very nice - http://www.flotcharts.org/

So many toys to play with, so little time.

Felix

Ohhh thats'weeet!
Yeah i'm seriously behind on EmonCMS. I need to revisit that. I read that they were looking into timestore but didn't know they actually released EmonCMS based on it yet. Awesome!
BUT .. at least I'm making progress and getting ever closer to releasing SwitchMote. Been taking pictures for a walkthrough/assembly/wiki for the past 2 days ... posting a video right now, lots going on. One day all this stuff will hopefully run on EmonCMS and be beautifully integrated with graphics, plots, timestore.

zigam

Hi gents,

So I been searching and figuring out how to set up (my first moteino project) water meter. I will try to go step by step 

Connection between Motenio and RasPI I figure it out. On RasPi I will use pins P2, P6, (for power) and P8 and P10 (for TX/RX) and Moteino I will use the FTDI connections.

On the Moteino connected to RasPi I will use guide fro here http://lowpowerlab.com/blog/2013/10/07/raspberrypi-home-automation-gateway-setup/ and the gateway.ino for Moteino its self.

But here come the trouble for me

Quote from: KanyonKris on February 03, 2014, 07:45:52 PM

It's almost that easy. The RFM68 library has slightly different commands because the RFM69 radio modules have some new capabilities. So open up the WaterMote.ino file in the Arduino program (aka IDE - Integrated Development Environment) and compare with a newer example like GarageMote (https://github.com/LowPowerLab/RFM69/blob/master/Examples/GarageMote/GarageMote.ino) that uses RFM69 and make the appropriate changes - search for all the "radio" stuff. You will not need to use radio.Wake with RFM69, and for transmitting you will probably want to use sendWithRetry.

When you think you've got the code right, click the upload button and it will compile your code, or give you an error if there's a mistake. After your code compiles, the new program will be sent to the Moteino attached to the USB FTDI cable. In the Arduino IDE you will need to set the Tools | Board to Uno and the Port to the one used by the FTDI.


I have like 0 experience in this kind of programming so I was trying to compare the GarageMote.ino and WaterMote.ino but I have very difficult time seeing what goes where. Modifying the code its self (gallons to liters, etc) I think I will manage but putting two together (if this is what you mean) I don't think I will know how to do that. Does maybe somebody have the WaterMote.ino for RFM69 setup that they can posted online. I would very much appreciate for the source code. I was reading the difference between the two (http://lowpowerlab.com/blog/2013/06/20/rfm69-library/) but it didn't help with my research.

Felix

I will try to make some time later today to port the WaterMeter to RFM69. Stay tuned...

zigam

Hi Felix I really appreciate your effort

Best regards, Ziga

Felix

Ok it's posted along with the RFM12B sketch in the WaterMote github repo (WaterMote_RFM69.ino):
https://github.com/LowPowerLab/WaterMote/blob/master/WaterMote_RFM69.ino

I have not tested it from lack of time, but I just upgraded all the radio stuff from RFM12B to RFM69.

zigam

Hi Felix,

I will give it a try. Thanks again for your fast responds,

Cheers Ziga

zigam

Hi

A little update from my side. I have manage to program my gateway and node and I see that they are nicely talking to each other (lights illuminating)

I try to setup my Raspberry following instructions from http://lowpowerlab.com/blog/2013/10/07/raspberrypi-home-automation-gateway-setup/

On fresh install I try to modify the Pi according http://www.hobbytronics.co.uk/raspberry-pi-serial-port
Here I notice that by default my Serial Port Login was already in this configuration #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Next step I try to modify /boot/cmdline.txt

from:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

to

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait


But after this change by Pi stop working. So I needed to change the code back.

I failed trying to install the Nginx by the instruction so I used alternative "apt-get install nginx"

I have skipped the installation in between (had problem with SSL to for unknown reason) and continued from Installing Node.js,  Socket.IO,  node-serialport forward.

Than I try to get some readout from Pi using https://github.com/LowPowerLab/SumpPumpAlert/blob/master/Gateway.py script

But I got the following error
root@Rasbdebian:/home# python gateway.py
Traceback (most recent call last):
  File "gateway.py", line 20, in <module>
    import time, sys, serial, threading
ImportError: No module named serial


Any ideas what I am doing wrong. It frustrates me that when I try to follow clear (copy/paste) instructions things are not resulting as they should.

What are the minimum things that I need to do to get readout like on the Felix's video http://www.youtube.com/watch?feature=player_embedded&v=MErKTQ3HG1c







KanyonKris

I'm not sure why changing the RasPi serial port configuration didn't work.

Quote from: zigam on February 14, 2014, 08:56:46 AM
But I got the following error
root@Rasbdebian:/home# python gateway.py
Traceback (most recent call last):
  File "gateway.py", line 20, in <module>
    import time, sys, serial, threading
ImportError: No module named serial


Looks like the pyserial module isn't loaded in Python.

If you have PiP (Python package manager) installed, do this:

pip install pyserial


To install PiP:

sudo apt-get install python-pip


Other options for installing pyserial - http://pyserial.sourceforge.net/pyserial.html#installation

zigam

Hi Guys,

So I have managed to get some readout from my Moteinos. For now I have abandoned the Raspberry Pi interface with this I will try to solve the problem later.

In terminal I ran
Quotescreen /dev/ttyUSB0 115200,-parenb,-cstopb,cs8
and got nice readings. I connected my "Impulz-Modul PM +m 100l/Impulz" to Moteino PD1(tx) and PD0(rx). Than try to test it to see if I will get water usage readout but it was always showing 0.0 GAL. On powered unit I swapped the cables on PD1(tx) and PD0(rx) and I got some value which had no relation to current water usage.

Where could be the problem in my PIN setting or my Moteino configuration?

Felix

If I'm guessing this right, you are trying to connect the Moteino serial pins to another device's serial port, in that case you have to match [TX to RX] and [RX to TX].
I think whenever you were getting a reading of "0.0GAL" that's when you got the wiring correctly, but you might have had a different problem with the sensor.
What sensor are you using? The EESY310? Are you sure the sensor is picking up the water meter and giving interrupt pulses to Moteino?

zigam

Hi me again :)

This week I have a lot of time dedicating to my water meter project and I have come far but than I realize that I am still at the beginning. Hehe but I am stubborn :)

What I have tried so far:

Installing Debian wheezy from http://www.raspbian.org/ than following instructions from RaspberryPi home automation gateway – Setup http://lowpowerlab.com/blog/2013/10/07/raspberrypi-home-automation-gateway-setup/ here I solved my problem from initial post when PI stopped working after modifying the  /boot/cmdline.txt

The instructions are pretty clear so I don't know why I had this problem in the first place but never the less now it's working. When coming to the end of this instructions I did had some problems with getting the page displayed as in the instructions. When editing chat.html do I use internal or external IP?

My initial goal was to get Emoncms displaying my water meter status. But as I was reading Emoncms are using Apache and in the instructions from Felix he is using Nginx. OK I did find a this post http://www.mylesgray.com/ardunio-hacking/how-to-run-emoncms-on-nginx-and-php5-fpm/ but as for my luck it didn't work.

So I try different options one of them was to create self hosted Emoncms following instructions from http://emoncms.org/site/docs/raspberrypihdd. But for some reason I couldn't get the data displaying on my local Emoncms.

So here a some questions.

Can I rather use Apache instead of Nginx. Or why is Nginx better?

Can you point me to websites instructions for.
Raspberry base (this I mean should I use Debian wheezy PI or for eg. EmonCms PI)

Are instructions from RaspberryPi home automation gateway – Setup mandatory for my water meter to work or can I use simpler  version. Maybe here you will say that SSL here makes the difference. But my PI is behind my router and will not be accessible from outside. I use VPN to connect to my server and than I can connect to any device on my LAN.

Is it enough that I create  /home/ziga/gateway.py add the EMONAPIKEY.

Also if I use the RaspberryPi home automation gateway – Setup with Nginx could you point me to web instructions how to create Local EmonCms or is that not necessary and I can just use the EmonCms Login website for data display.


Thanks again for patience  ;)
Ziga