LowPowerLab Forum

Hardware support => Moteino => Topic started by: Kilo95 on August 29, 2015, 04:42:52 PM

Title: Programming moteino
Post by: Kilo95 on August 29, 2015, 04:42:52 PM
How can I see what files/libraries are loaded on the moteino? What do I need to do to get the oled to work?
Title: Re: Programming moteino
Post by: luisr320 on August 29, 2015, 08:14:12 PM
Once the sketch is uploaded into the Moteino, there is no way to get the source code back. You can, however, dump the HEX code loaded and try to figure out a way of reading it back into something usefull.
Read this:
http://forum.arduino.cc/index.php?topic=6150.0 (http://forum.arduino.cc/index.php?topic=6150.0)

What is the brand/model of oled you have?
Title: Re: Programming moteino
Post by: Kilo95 on August 29, 2015, 09:02:05 PM
Ok.  Thanks. The oled is the one from felix's store. https://lowpowerlab.com/shop/oled
Title: Re: Programming moteino
Post by: Kilo95 on August 29, 2015, 10:09:45 PM
I was able to get the moteino attached to my sonarmote programmed and reading distances (showing up in "serial monitor" in Arduino. Not too bad I guess for a really green newbie. Still waiting on my Pi. Still working on getting the node on the sonarmote and the gateway moteino to communicate. I appreciate all the help everyone has given
Title: Re: Programming moteino
Post by: luisr320 on August 30, 2015, 10:52:55 AM
If you have the latest Arduino.cc IDE, go to the libraries Management menu and install the U8glib library. If you are using the "other" Arduino.org IDE, Google the library and install it.
Get the Lowpower librarie from here: https://github.com/lowpowerlab/lowpower (https://github.com/lowpowerlab/lowpower)
Then restart the Arduino IDE and open the motion oled mote sensor sketch from here:
https://github.com/LowPowerLab/RFM69/blob/master/Examples/OLEDMote/OLEDMote.ino (https://github.com/LowPowerLab/RFM69/blob/master/Examples/OLEDMote/OLEDMote.ino).
Change the sketch setup to reflect your network, encryption, radio type, baud rate, etc.
Connect the SDA pin of the oled to A4 of your Moteino and the SCL pin from the oled to the A5 pin of the moteino. Connect the GND pin to the GND and Vcc to 3.3v pin of the Moteino.
If you want to connect the LED and buttons just look into the example where they connect to. But to see your oled working, just upload the sketch like that and something should come up. Then go from there with sensor, leds, buttons and buzzer.
Good luck


Title: Re: Programming moteino
Post by: Kilo95 on August 30, 2015, 02:08:22 PM
Awesome. Thanks
Title: Re: Programming moteino
Post by: luisr320 on August 30, 2015, 02:31:13 PM
Is it working?
Title: Re: Programming moteino
Post by: Kilo95 on August 30, 2015, 02:48:42 PM
i've gotten it to light up. just black and white static though. the board was a sonarmote board with presetup slot for the OLED that I got from Felix
Title: Re: Programming moteino
Post by: luisr320 on August 30, 2015, 03:24:41 PM
That happened to me when I set the data pins in the wrong orientation. Try to connect the oled directly to the Moteino without any shield.
Title: Re: Programming moteino
Post by: Kilo95 on August 30, 2015, 03:27:40 PM
Ok. I may just fly without it. It's on the bottom side of the sonarmote board. I'd have to cut a hole in the case and get a 4 pin ribbon cable to move it. A second newbie question...should I be uploading multiple sketches to the moteino or should I compile them into one and upload one
Title: Re: Programming moteino
Post by: luisr320 on August 30, 2015, 03:37:15 PM
Looks like the pins are reversed on the library. I'm out of my depth here.

Regarding your question, there can be only one sketch in any Moteino at any time. So you compile and upload it and if you want to change it you have to do it all over again
Title: Re: Programming moteino
Post by: Kilo95 on August 30, 2015, 03:38:22 PM
That's what I had decided. Makes sense why I could only get one thing at a time to work. That helps a lot ;D
Title: Re: Programming moteino
Post by: Kilo95 on September 08, 2015, 12:02:59 PM
ok, so how do I compile the sketches? I admit to being VERY new to this. Had a friend over last night who is very familiar with programming/linux/etc and he wasn't sure how to do it. I have ArduinoIDE and have uploaded one sketch at a time and I works great. I can't load the Node.ino and sonarmote.ino to the sonarmote. Do i have to load the sonarmote.ino to the miniusb on the sonarmote and load the node.ino via a ftdi adapter to the node moteino? I really appreciate everyone's help.
Title: Re: Programming moteino
Post by: Felix on September 08, 2015, 12:20:02 PM
Kilo95,
There's a basic programming guide here (https://lowpowerlab.com/programming/).
For the SonarMote, the FTDI chip is already onboard so you program it after it's fully assembled and Moteino plugged into it, via the mini USB connector (which also charges the LiPo battery which should be attached).
Title: Re: Programming moteino
Post by: Kilo95 on September 08, 2015, 01:47:43 PM
I've tried to follow that guide but I can only get either the node sketch or the sonarmote sketch loaded separately to the sonarmote. It won't measure distance and transmit without both, is that correct? Someone on here said I should combine the two but I haven't seen anywhere that says how to do that
Title: Re: Programming moteino
Post by: Felix on September 08, 2015, 01:50:12 PM
What are you trying to do with the SonarMote?
Title: Re: Programming moteino
Post by: Kilo95 on September 08, 2015, 01:52:55 PM
I have two moteinos. One for the sonarmote and one to connect to my Pi. I want to set it up on my sump pump and have it email me if the water level gets too high
Title: Re: Programming moteino
Post by: Felix on September 08, 2015, 02:15:17 PM
Ok, this is the sketch (https://github.com/LowPowerLab/RFM69/blob/master/Examples/SonarMote/SonarMote_DistanceTracker/SonarMote_DistanceTracker.ino) you need for that.
Make sure to verify the sketch settings to match your Moteino.
See the SonarMote page (https://lowpowerlab.com/sonarmote/) for more examples.
Title: Re: Programming moteino
Post by: Kilo95 on September 08, 2015, 02:32:58 PM
Awesome! I really appreciate it. I was able to configure the freq and encryption details so that should wrk great. Thanks
Title: Re: Programming moteino
Post by: luisr320 on September 08, 2015, 04:05:31 PM
I haven't seen the Sonarmote sketch yet, but I'm pretty sure that the Sonsrmote sketch is all you need to upload into the Sonarmote. Conceptually, you think of it as a node in your Moteino network. What you need now is to program another Moteino as a Gateway in order to receive the traffic from your Sonarmote. The Gateway sketch will allow a Moteino to interpret some incoming traffic received by its radio and either activate a digital output or send some message to an oled display connected to it.
So, first load the Sonarmote sketch on a Sonarmote node, then load a Gateway on another Moteino.
Make sure the network is is the same on both as well as the encryption key that must be the same on both.
Check the Sonarmote sketch and look for the gateway ID number and make sure that it points to the correct gateway ID number.

I'll look into the Sonarmote sketch later and see what needs to be done.
Don't give up, never surrender ;-)
Title: Re: Programming moteino
Post by: Kilo95 on September 08, 2015, 05:07:54 PM
The sonarmote sketch Felix gave me the link to just above in this post worked. The other one I had gotten off of GitHub wouldn't work. All is up and well now. Just have to set up the Pi. Btw, I don't give up easily
Title: Re: Programming moteino
Post by: luisr320 on September 10, 2015, 12:09:27 PM
Never mind my post. For some reason I only read the last message of the 1st page, so I didn't see that your problem was already resolved.
How about some pics of your project to inspire us to turn that soldering iron on?
Title: Re: Programming moteino
Post by: Kilo95 on September 10, 2015, 08:43:02 PM
I'll try to post when I'm done. I didn't have to do much as Felix had a few that were complete. I got the sonarmote and gateway moteino to work properly. Almost done now. I do have a question though. I downloaded the Pi gateway image (the complete one). Do I still need to download the other files from github? For port forwarding, i use ports 80 and 444, is that correct? Thanks
Title: Re: Programming moteino
Post by: Felix on September 11, 2015, 07:40:58 AM
Quote from: Kilo95 on September 10, 2015, 08:43:02 PM
I'll try to post when I'm done. I didn't have to do much as Felix had a few that were complete. I got the sonarmote and gateway moteino to work properly. Almost done now. I do have a question though. I downloaded the Pi gateway image (the complete one). Do I still need to download the other files from github? For port forwarding, i use ports 80 and 444, is that correct? Thanks
Everything is on the image ready to go. However sometimes i update the files at Github for bugs so it's good to check if there's a newer version there.
Ports are 80 and 443.
Title: Re: Programming moteino
Post by: Kilo95 on September 11, 2015, 08:29:03 AM
Ok. Thanks
Title: Re: Programming moteino
Post by: Kilo95 on September 12, 2015, 12:10:05 PM
ok, I downloaded the pigateway image and installed it to my sd. I setup and connected the wifi and forwarded ports 80 and 443 on my router. My question...how do i setup the .htpasswd file? I did the following from the manual install guide:

sudo echo -e "USERNAME:`perl -le 'print crypt("PASSWORD","SALT")'`"
sudo nano /var/www/default/.htpasswd

I just get "Pi:lettersandnumbers"

I also tried in the sudo echo line putting my own username and password, but still cant connected over my home wifi with those credentials. suspecting I don't have the user/pwd formatted correctly in the .htpasswd file. how do i fix it?

Also, I saw felix's comment about setting up the gateway moteino on the serial port. I just have usb. how do I set that up in the settings.js file? btw, i did do the upgrade, etc for raspbian before I started
Title: Re: Programming moteino
Post by: Kilo95 on September 12, 2015, 12:59:44 PM
ok. so i realized after running the first command that the output was an encrypted password and put that it. putting the Ip into a browser, it doesn't ask for the password but pulls up the gateway page and says "waiting for socket connection"...still need to know about how to tell the pi which port is the moteino (if i need to tell it)
Title: Re: Programming moteino
Post by: Kilo95 on September 12, 2015, 08:02:43 PM
I installed from the pigateway rasbian image, updated, etc. set email, username, password. I can't get the chat.js to work and when I try to "node gateway.js &" I get an error. I'll post a screen shot in a few minutes. I saw one post about a similar problem and I tried changing the socket.io path that was suggested. Still get this. When I connected via web browswer, I get the gateway page but it says "waiting for socket connection". I also went back through and did the install manually. Same result. Need help (imagine that ;))
Title: Re: Programming moteino
Post by: Felix on September 14, 2015, 08:39:11 AM
If you install the image it should work. You can skip the chat.js, thats only for reference.
Otherwise follow the guide step by step and you should get the same results.
There are no guarantees though, I've done my best to provide both an image and a guide :)
Title: Re: Programming moteino
Post by: Kilo95 on September 18, 2015, 09:42:40 AM
ok. I got it to connect via web browser to the gateway page. It still says "Nodes Count: 0". I assume its not recognizing my usb moteino. can you tell me how to set it so it will recognize it on usb? I didnt see any instructions on the setup guide for that. pardon me if i missed it
Title: Re: Programming moteino
Post by: Felix on September 18, 2015, 10:20:07 AM
What is the serial port of your MoteinoUSB?
Something like /dev/ttyUSB0 ?
Can you open minicom -b 115200 -D /dev/ttyUSB0 and make sure you're receiving data from remote Moteinos?
Did you setup that serial port (and everything else) in settings.js?
Title: Re: Programming moteino
Post by: Kilo95 on September 18, 2015, 11:51:18 AM
I think I may have missed setting the serial port up in settings .js. I did set up the other stuff. Will ifconfig show me which port its on?
Title: Re: Programming moteino
Post by: Felix on September 18, 2015, 12:41:55 PM
Can you just follow my steps please?
Title: Re: Programming moteino
Post by: Kilo95 on September 18, 2015, 02:20:53 PM
ok, i set the serialport for usb and ran minicom. It receives the distance and battery voltage from the sonarmote. it still shows "nodes count: 0" in the web browser. also, I noticed that it only sends one measurement. I waited 5 minutes or so and never saw another measurement. if I log out of minicom and back in, it'll send a new single measurement from the sonarmote.
Title: Re: Programming moteino
Post by: Kilo95 on September 18, 2015, 02:24:00 PM
disregard about it not updating measurements. i moved it and it correctly updated. i do still need to get the web interface to show the node
Title: Re: Programming moteino
Post by: Felix on September 18, 2015, 03:24:46 PM
You cant have a serial port in 2 places, only 1 can have it active. While in minicom the other place will freeze.
Title: Re: Programming moteino
Post by: Kilo95 on September 18, 2015, 04:11:54 PM
so whats the fix for the web interface? i logged out of everything else and it still doesn't show the node. the serial port is setup in settings.js along with the other settings. i have the gateway.ino on my gateway moteino (connected to the RPi). I tried to load the pigateway.ino but it flagged multiple errors.
Title: Re: Programming moteino
Post by: Felix on September 21, 2015, 03:44:42 PM
You need this sketch (https://github.com/LowPowerLab/RFM69/tree/master/Examples/PiGateway) on your gateway, not gateway.ino.
Title: Re: Programming moteino
Post by: Kilo95 on September 23, 2015, 04:35:51 PM
I tried uploading it to the Moteino but I got multiple errors related to wirelesshex69. I commented out the "include wirelesshex69" at the top and get these errors. (I don't plan on wireless programming right now). Suggestions?

PiGateway.ino: In function 'void loop()':
PiGateway:69: error: 'readSerialLine' was not declared in this scope
PiGateway:111: error: 'CheckForWirelessHEX' was not declared in this scope
'readSerialLine' was not declared in this scope

Title: Re: Programming moteino
Post by: luisr320 on September 23, 2015, 05:02:57 PM
Did you install the WirelessHex69 library? You can find it here: https://github.com/LowPowerLab/WirelessProgramming (https://github.com/LowPowerLab/WirelessProgramming)
Title: Re: Programming moteino
Post by: Kilo95 on September 23, 2015, 05:26:39 PM
yes.  i reinstalled it for kicks. now I'm getting this error when I verify it in Arduino IDE

PiGateway.ino:13:78: fatal error: RFM69.h: No such file or directory
compilation terminated.
Error compiling.

I reinstalled the RFM69 library into the /Arduino/library/RFM69 folder but get the same result. I feel like i'm pretty close finally. lol
Title: Re: Programming moteino
Post by: luisr320 on September 23, 2015, 06:22:54 PM
Every time you install a library, you have to restart the Arduino IDE for the new library to be used.
Title: Re: Programming moteino
Post by: Kilo95 on September 23, 2015, 06:51:28 PM
I did restart arduino ide after the reinstall
Title: Re: Programming moteino
Post by: luisr320 on September 23, 2015, 07:19:25 PM
What is your Arduino IDE version? 1.6.5?
Title: Re: Programming moteino
Post by: Kilo95 on September 23, 2015, 07:36:14 PM
I'll have to look when I get home. I downloaded it within the last 4-5 weeks
Title: Re: Programming moteino
Post by: luisr320 on September 23, 2015, 08:26:35 PM
Make a backup of your libraries, erase all libraries in Documents/Arduino/libraries and paste all libraries in the Program_Files/Arduino/libraries folder.
Title: Re: Programming moteino
Post by: Kilo95 on September 23, 2015, 10:31:13 PM
Did that just now and set preferences in Arduino to reflect correct library. Now
It can't find wirelesshex69. Maybe I'll play with it more tomorow
Title: Re: Programming moteino
Post by: luisr320 on September 24, 2015, 07:01:48 AM
Here you go:
https://github.com/LowPowerLab/WirelessProgramming/archive/master.zip (https://github.com/LowPowerLab/WirelessProgramming/archive/master.zip)
Title: Re: Programming moteino
Post by: Kilo95 on September 24, 2015, 08:10:14 AM
Thanks. I have the wireless hex library installed. It just can't find it for some reason
Title: Re: Programming moteino
Post by: luisr320 on September 24, 2015, 08:47:32 AM
Instalo the library directly from the IDE using the ZIP file. Then restart the IDE
Title: Re: Programming moteino
Post by: Kilo95 on September 24, 2015, 07:56:55 PM
ok. finally got the gateway GUI to work. everything is reading fine through there. my router is set to forward ports 80 and 443 on the static ip for my RPi but i can't get it to pull up from outside my home network using my public ip address. still working on that. thanks for all the help
Title: Re: Programming moteino
Post by: luisr320 on September 25, 2015, 05:22:31 AM
Can you ping your Rpi static IP?
Open a cmd window on your Windows and enter ping 192.168.0.100, replacing the ip numbers with the correct ones, of course.
Do you get any reply?
Title: Re: Programming moteino
Post by: Kilo95 on September 25, 2015, 08:41:50 AM
yep. worked fine. tx/rx all 4 packets without problem. double checked my router config and i DO have it forwarding 80 and 443 internal to 80 and 443 external on my RPi's static ip. double checked my public ip and entered that. still not working. what am i missing?
Title: Re: Programming moteino
Post by: Kilo95 on September 25, 2015, 09:15:16 PM
Ok. So my isp was blocking most ports. I asked nicely and they opened the ports I wanted. I have to adjust the placement a little. It's measuring to the top of the pump which is 20cm down. Still have to get the messaging alert working. In which file is the distance set at which it sends an alert? I may need to drop the distance down to 12-15cm
Title: Re: Programming moteino
Post by: Kilo95 on September 26, 2015, 12:37:37 PM
Ok everything is working except text/email alerts. I can log in from remote network and see the gateway GUI working. (My isp was blocking ports. They are open now). I double checked my email, password, and cell address in settings.js. Is there anything I need to configure with Google? Any suggestions how to get the text alerts to work? (Gmail is my email)
Title: Re: Programming moteino
Post by: Kilo95 on September 27, 2015, 08:05:03 AM
If it's easier to use an aol email address I can make
A new one. I tried to look and see how to change that but wasn't successful. Could someone vel me out with that?
Title: Re: Programming moteino
Post by: luisr320 on September 27, 2015, 02:10:37 PM
Sorry, but you'll have to wait for someone to get you going on that project. I never used a Raspbarry Pi so I have no idea why you are stuck now.
Title: Re: Programming moteino
Post by: Felix on September 27, 2015, 10:41:24 PM
Kilo95,
You can use your gmail account. I would not put my straight password in there, instead i would generate a specific app password, here's a guide (http://www.shoutmeloud.com/how-to-generate-google-app-specific-password-2-step-verification.html)
Then you send email using your own gmail account to anywhere you want. To get SMS you send an email to your phone's associated SMS address (it's an email at your carrier, usually your [email protected]).
Title: Re: Programming moteino
Post by: Kilo95 on September 28, 2015, 07:33:26 AM
Ok. I tried it with the straight password and used my @vtext.com address and it didn't work. I'll try making an app specific password. Which file do I adjust the distance in which it'll alert?
Title: Re: Programming moteino
Post by: Felix on September 28, 2015, 09:19:42 AM
google your carrier for the email address. I don't have instructions for every carrier in the world, i just know what works for at&t and verizon.
What distance are you measuring for?
Title: Re: Programming moteino
Post by: luisr320 on September 28, 2015, 09:24:13 AM
How about using Twitter? I created a Twitter account for my home automation system, which I follow, and when required, my house sends me all kinds of notifications with a simple Tweet.
Title: Re: Programming moteino
Post by: Kilo95 on September 28, 2015, 09:52:52 AM
I have my Verizon email. I believe the default to alert on the sump pump is 20cm. My water level runs from 14-21cm. I just need to know where to alter it so I'm not alerted when I don't need to be
Title: Re: Programming moteino
Post by: TomWS on September 28, 2015, 10:11:45 AM
Quote from: luisr320 on September 28, 2015, 09:24:13 AM
How about using Twitter? I created a Twitter account for my home automation system, which I follow, and when required, my house sends me all kinds of notifications with a simple Tweet.
Do you use the TwitterAPI?  If so, which version?

In my experience there ain't no such thing as a simple Tweet with that API!  Once you have all the code, it's sort of, kind of easy, but lots of code behind each tweet.

Tom
Title: Re: Programming moteino
Post by: Kilo95 on September 28, 2015, 10:59:02 AM
I'm not on Twitter.
Title: Re: Programming moteino
Post by: Felix on September 28, 2015, 11:38:09 AM
Quote from: Kilo95 on September 28, 2015, 09:52:52 AM
I have my Verizon email. I believe the default to alert on the sump pump is 20cm. My water level runs from 14-21cm. I just need to know where to alter it so I'm not alerted when I don't need to be

It's on this line in metrics.js (https://github.com/LowPowerLab/RaspberryPi-Gateway/blob/master/metrics.js#L161):

sumpSMS : { label:'SumpPump : SMS (below 20cm)', icon:'comment', descr:'Send SMS if water < 20cm below surface', serverExecute:function(node) { if (node.metrics['CM'] && node.metrics['CM'].value < 20 && (Date.now() - new Date(node.metrics['CM'].updated).getTime() < 2000)) { sendSMS('SUMP PUMP ALERT', 'Water is only 20cm below surface and rising - [' + node._id + '] ' + node.label + ' @ ' + (new Date().toLocaleTimeString() + (new Date().getHours() > 12 ? 'PM':'AM'))); }; } },

I do hope you can do this change yourself.
Title: Re: Programming moteino
Post by: Kilo95 on September 28, 2015, 11:39:30 AM
Yep. Thanks. I set the app specific password up.
Title: Re: Programming moteino
Post by: luisr320 on September 28, 2015, 12:20:21 PM
It's not really complicated to setup a way to sent Tweets via the Moteino, directly, if it is connected to a Ethernet shield, or from a command line. I send them trough a VB script in a Windows machine. If there is any interest on this I can show you guys how it's done. But since the intention is to use a RPI, it must be done with Linux. Can Linux handle a VB Script or is it only for a Windows machine? I think I can setup a simple Tweet gateway connecting a Moteino to an ENC28J60.
It doesn't matter that you do have a tweeter account. You simply create one for yourself and another for your system. Them you install the official Tweeter APP on your phone, and set it up so that you follow all the tweets your system posts.
I'm trying to narrow down the easiest way to do it and will post here soon.

Title: Re: Programming moteino
Post by: TomWS on September 28, 2015, 12:33:54 PM
Ok, your setup is different than mine.  I use TwitterAPI and the underlying code uses curl from PHP.  Works on any webhost that supports PHP, but you need a developer account.  But this is getting off topic so sorry for the distraction.

Tom
Title: Re: Programming moteino
Post by: luisr320 on September 28, 2015, 05:44:01 PM
There is a Python library, tweepy, that will allow anyone to send a simple Tweet with a command like tweet.py "message".
I have never used a RPI, so I have no idea if this is possible, but can you have an event run a command like that? That would send a Tweet to you. By event I mean, a Digital Input on the Moteino sending its status to the RPI status and the RPI would run that command line.
If this is possible, I can post how to make it run.
Title: Re: Programming moteino
Post by: Kilo95 on September 28, 2015, 07:27:48 PM
Does the email alert require a different port to be open? I've checked all my settings and still nothing comes through. I know they had 22, 80, and 443 blocked so I was starting to wonder if that's why the email isn't coming through
Title: Re: Programming moteino
Post by: Kilo95 on September 29, 2015, 04:13:27 PM
I changed the line in metrics.js to <50cm (water level is 20-21cm) to see if it'll trigger it. Checked in gateway.sys.log like someone suggested and it's not trying to send a SMS or email. I made sure the security in Gmail is set for low level apps. What am I doing wrong? Everything is showing up fine on the Moteino Gateway GUI online
Title: Re: Programming moteino
Post by: Kilo95 on October 01, 2015, 08:47:08 AM
I got it. It'll send SMS but not email but that's ok. I did a fresh install with the v6 image. thanks for all of the help and being patient with a newbie
Title: Re: Programming moteino
Post by: Felix on October 01, 2015, 08:51:36 AM
Great, but that's strange.
When you say email doesn't work, can you give more details?
The SMS mechanism uses email as a means to send the SMS. You're basically relaying that SMS via email. So it does send email, otherwise you could not get the SMS on your phone.
Title: Re: Programming moteino
Post by: Kilo95 on October 04, 2015, 06:52:10 PM
 I set up an email address and my mobile number email address to receive email and text alert. The text alert comes through but not the other email