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 (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
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.
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
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.
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.
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.
I will try to make some time later today to port the WaterMeter to RFM69. Stay tuned...
Hi Felix I really appreciate your effort
Best regards, Ziga
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.
Hi Felix,
I will give it a try. Thanks again for your fast responds,
Cheers Ziga
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/ (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 (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 (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 (http://www.youtube.com/watch?feature=player_embedded&v=MErKTQ3HG1c)
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 pyserialTo install PiP:
sudo apt-get install python-pipOther options for installing pyserial - http://pyserial.sourceforge.net/pyserial.html#installation
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?
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?
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/ (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/ (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 (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
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.
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
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.
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.
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 (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 (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
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.
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?
One more thing
How can I erase to 0 or modify the GAL value
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);
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.
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
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.
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.
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 :)
Hm .. I believe you're using a sensor that I'm not familiar with. Could you provide more details about it? Any datasheet?
Currently I am not using any sensors for testing purpose I am using push button to create interrupt.
Yes, a datasheet or any tech specs would help.
Only other thought I've had: perhaps the contacts of the flowmeter need to be debounced?