Author Topic: Backyard WeatherStation for Planting and later Aquaponics.  (Read 16872 times)

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Backyard WeatherStation for Planting and later Aquaponics.
« on: January 01, 2014, 03:53:10 PM »
     Ok, I'm finally getting some me time to get this done.   Looks like I'm not the only one with this idea in mind.  Still very much a work in progress.  Currently looking for a good way to enclose the Moteino, while still allowing for reprogramming as necessary.

     Two things I'd really like to change.
  1) pass the data as either integers, or floats.  Is there a way to make a datatype that is made up of four floats and pass that with the radio? 
  2) figure out why I'm not recieving a ACK from the Node by the Gateway.  I'm guessing it is a timing issue but haven't spent much time with that yet.  My data is getting through for now.   

Here is the actual Node in it's current state.  Just bread boarded for now.  Two DS18b20s, and one DHT22.  Running off of a 9v battery for now. 


IMG_7272 by hexibot43, on Flickr

The Gateway Moteino - not much to this one.  It is basically just acting as a wireless gateway for my laptop at the moment.  Will be changing over to the Raspi soon.  Still working on the web interface.


IMG_7273 by hexibot43, on Flickr

My gateway is getting simple packets of 4 numbers delineated by semicolons.  I wanted to pass them as floats or integers, but haven't been able to get that working so for now I'm just going to stick with text.  I would love to pass an array of floats???


DataComingInToGateway by hexibot43, on Flickr

Here is the data coming from the serial debugger data of the Node. 

TerminalDataFromNode by hexibot43, on Flickr

I now understand how to add those flickr pics - Thanks Felix.

     Here is a link to my code as it is today.  Many thanks for Felix for his Gateway and Node code which I used to create the link between Node and Gateway. 

Here is the Node -

http://codebender.cc/sketch:26389


« Last Edit: January 01, 2014, 07:51:49 PM by hexibot43 »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #1 on: January 01, 2014, 07:24:06 PM »
Cool, hey BTW you can click the sharing button in flickr and grab the [BB] code and paste it here, it will make the pictures show up, like so:


TerminalDataFromNode by hexibot43, on Flickr

A

  • Newbie
  • *
  • Posts: 43
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #2 on: January 01, 2014, 11:58:01 PM »
Currently looking for a good way to enclose the Moteino, while still allowing for reprogramming as necessary.

For my outdoor weather sensor I was planning on something along the lines of the 'Vented Air Thermometer' from this page: http://pond1.gladstonefamily.net/sensors.html but with just the sensors inside the solar shield and the Moteino mounted in some sort of rain proof housing below the 2x4. If reprogramming or battery change is needed, just pop open the Moteino case.

I think abstracting the sensor reporting a bit would be worth the bit overhead. I'm not sure if we'd need to go to the point of using the Adafruit Unified Sensor Driver framework but it might not hurt. A data string would consist of:

nodeid,
millis() for the sensor node,
sensor type (temp, humidity, pressure, light, battery voltage, etc.),
sensor serial number - from the sensor if it has a built in serial like the ds18x20s, otherwise an integer value or a null,
sensor reading

We should also packetize readings from all sensors connected to a node to keep radio transmissions (read as battery life) to a minimum.

LazyGlen

  • Newbie
  • *
  • Posts: 48
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #3 on: January 02, 2014, 12:10:53 AM »
     Ok, I'm finally getting some me time to get this done.   Looks like I'm not the only one with this idea in mind.  Still very much a work in progress.  Currently looking for a good way to enclose the Moteino, while still allowing for reprogramming as necessary.

     Two things I'd really like to change.
  1) pass the data as either integers, or floats.  Is there a way to make a datatype that is made up of four floats and pass that with the radio? 
  2) figure out why I'm not recieving a ACK from the Node by the Gateway.  I'm guessing it is a timing issue but haven't spent much time with that yet.  My data is getting through for now.   

Definitely not the only one with this in mind. And not the only one with exactly the set of problems you describe.

I too spent a lot of time trying to figure out how to pass floats in the Node and Gateway sketch. Then I looked around and found the Struct send and receive sketches. I now have 1 int and 4 floats being transmitted on a regular basis.

I have similar problems with ACK's. I think what I'm seeing is ACK's from the Gateway get through, but when the Gateway tries to ping the Node, I get no response.

My code resides in my Dropbox:
TemperatureGateway.ino
TemperatureNode.ino

It's late now, I'll try to get a serial monitor dump tomorrow to show whats going on.

LG
« Last Edit: January 07, 2014, 02:06:16 PM by LazyGlen »

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #4 on: January 02, 2014, 01:34:05 AM »
     I just found a function atof()  That didn't error out with the compiler.   So this should solve the problem.  I just rewrote the gateway code, but not going to test it until tomorrow.  I don't want to know if it doesn't work, because if it doesn't I won't get any sleep.

     I will have to look at the struct send and receive functions.  That sounds a lot better way of doing it.  Especially when the amount of data changes. 

     I converted to ASCII and then back again on the other side.

     I was just looking at the "Request ACK" function of the gateway, and it seems like unlike the rest of the code where it "sends with retry" the "Request ACK" fuction does not. 

Quote
if (radio.sendWithRetry(theNodeID, "ACK TEST", 8, 0))  // 0 = only 1 attempt, no retries

     I really like the idea of a standard format packet so that any of our node code would be easily added to someone else's network.

    I'll look at that case type tomorrow while I'm at work.  Need to get some sleep. 

Thanks Everyone.  Nobody else here at home has any idea what I'm talking about.  Keeps me sane.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #5 on: January 02, 2014, 08:23:12 AM »
LazyGlen - Don't forget your radio needs to be in RX mode when listening for the requested ACK, and the gateway or other node has the recognize an ACK is requested and respond.

Need to get some sleep.
Thanks Everyone.  Nobody else here at home has any idea what I'm talking about.  Keeps me sane.

I sympathize here, I think most of us are in the same boat ;)

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #6 on: January 02, 2014, 10:02:53 AM »
Definitely not the only one with this in mind. And not the only one with exactly the set of problems you describe.

I too spent a lot of time trying to figure out how to pass floats in the Node and Gateway sketch. Then I looked around and found the Struct send and receive sketches. I now have 1 int and 4 floats being transmitted on a regular basis.

LG

Thanks LG for sharing your code.  Now I have to laugh.  The one part of your code I am truly interested in is the typedef of your struct is the one thing you didn't share.  LOL!  But I must say looking your code over has help me immensely.  I am still learning Arduino and relearning C.  I hadn't written any C for 20 years.   

LazyGlen

  • Newbie
  • *
  • Posts: 48
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #7 on: January 02, 2014, 12:38:52 PM »
Quote
Thanks LG for sharing your code.  Now I have to laugh.  The one part of your code I am truly interested in is the typedef of your struct is the one thing you didn't share.  LOL!  But I must say looking your code over has help me immensely.  I am still learning Arduino and relearning C.  I hadn't written any C for 20 years.   

You had me worried there for a bit, I thought I had posted old code.

The typedef is there, its inline in the code, which I didn't think was going to work, and I don't think is the right way to do it, but I could not figure out how to do it in a .h file. (To be fair, I was working on my Mother In Laws kitchen table over Christmas break after everyone else had gone to bed.)

Code: [Select]
typedef struct {		// payload structure for radio packet 
   int Samples; // Number of samples taken
   float CurrTemp1; // Most current Temperature reading on sensor 1
   float CurrTemp2; // Most current Temperature reading on sensor 2
   float AvgTemp1; // Average temperature over the last numReadings
   float AvgTemp2; // Average temperature over the last numReadings
} TEMPS;
TEMPS theData;

I remember running into this problem previously, I just haven't had the time to chase this loose end down. In fact, from an older version of the code I found a line (commented out because it wasn't working)
Code: [Select]
// #include <TempType.h> // Some web info claims typedefs need to be in their own header files.
Clearly it would be cleaner if the typedef was in it's own file to be #included into each sketch.

For Heavens sake, don't use MY code to learn from! I had to take the one credit C course that was required in college twice to pass it. In ~1992. And I have not written anything in C since, save for dabbling in Arduino for the past few years, and even that I have not been doing for a year and a half or so.

LG

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #8 on: January 02, 2014, 03:24:47 PM »
Thanks LG

     I didn't get enough sleep last night.  And the moment I saw the #include <typedef.h> I was looking for the H file.  I completely missed the fact that it was commented out.  Tired eyes....That's my story and am sticking to it. 

    I am definitely doing a rewrite of the code to move data from Node to Gateway.  I had tried to do a typedef struct without any success myself, and so gave in to ASCII.  That is so much better.  It won't take much work to add more data in later.  Whereas my ASCII just gets more and more complicated.  That PH sensor I've been looking at will be much easier to add in.  The ambient light sensor, etc, etc,..

    Do you know if there is a limit to the packet size?

         

LazyGlen

  • Newbie
  • *
  • Posts: 48
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #9 on: January 02, 2014, 04:03:10 PM »
I didn't get enough sleep last night.  And the moment I saw the #include <typedef.h> I was looking for the H file.  I completely missed the fact that it was commented out.  Tired eyes....That's my story and am sticking to it. 
 ...
Do you know if there is a limit to the packet size?

Well, I hope you saw it and decided to go to sleep rather than fighting more and losing more sleep!

As far as packet size, it didn't even occur to me to question it. I was thinking about it in terms of battery power and transmit time, as evidenced by the packet size count comments of 18 for native int's and floats vs Converting to a comma & spaced string uses approx 35 bytes, rounded to tenth [edit]should be hundredth![/edit] degrees. ;~) Not that that level of precision is even possible with DS18B20's, but the sensors could be swapped out.

A search of the forum indicates that Felix puts the limits on RFM69 at 63 bytes:

Thanks for sharing and formatting the code with the code tags :)
I'm wondering though .. were you able to send an 88 byte packet? Or was it truncated at 63 bytes even if you dumped 88 bytes in the buffer?
The reason I ask is because the chip has a 66 byte buffer of which a few bytes of overhead from the library.

Good to know, but I bet I forget it by the time I get to that amount of data!

LG
« Last Edit: January 02, 2014, 04:16:36 PM by LazyGlen »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #10 on: January 02, 2014, 05:14:38 PM »
The packet size is limited by the 66 byte FIFO of the RFM69. 3 bytes are used  by the library for addressing and such. So that leaves the 63 bytes that were mentioned.
If you use structs instead of ASCII that should give you a huge saving of space. Imagine that in a struct a float is 4 bytes, and in ASCII it can be double that, plus you're adding delimiters (ie space or colon or something like that) all of which are avoided using structs. So 63 bytes should be plenty for most sensory type data. And if that's not enough, send 2 packets... I've used to do that for the KAW hack when I was transmitting the full V and A waveforms that would not fit in the RFM12B buffer...

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #11 on: January 02, 2014, 07:50:33 PM »
Thanks again Felix.  That answered that question perfectly.  I like this set up all the more now.  I just wished I had figured out the struct typedef earlier on my own. 

Felix is there a way to add sticky posts at the beginning of a forum category?  I would love to see some place to put answers to such problems for everyone to easily find.  Like a list of all the commands for the rfm69, etc,..  Ways to get data across the transceivers like the typedef struct format .  I'm all for making it easier for the next guy. 

 

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #12 on: January 02, 2014, 08:03:58 PM »
I can mark a topic as sticky, there's a SET TOPIC STICKY button at the bottom but I don't know if you as regular user can see that, I assume not. Maybe there's a way to turn that ON for regular users BUT I'm not sure I want to do that :)

If you'd like I'll be happy to mark a topic as sticky for you, just let me know.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #13 on: January 02, 2014, 10:10:45 PM »
Felix,
     I would agree that you should hold the ability to mess with the forum yourself.  But perhaps as things here progress we can get you to make some stickies out of important posts.

Thanks,

Marcello

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #14 on: January 03, 2014, 01:36:55 AM »
LG -

     I'd like to ask you about your code -

if (radio.sendWithRetry(GATEWAYID, (const void*) (&Temps), sizeof(Temps)))

I don't understand "(const void*) (&Temps)?  Can you explain that one to me?  This is some way of pointing to the structure yes?  Do you have any links that led you to this? 

Thanks,

Mab

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #15 on: January 03, 2014, 07:59:43 AM »
He's basically casting the Temp struct variable to a byte pointer. So the Temp struct variable is somewhere in memory and it's of type Temp (same name as variable .. a bit confusing but possible). The sendWithRetry function has no idea what Temp is and expects a very basic byte pointer (pointer to a bunch of bytes in memory) and the # of bytes to read from that location. So the casting syntax is just taking that Temp and casting it's address to a byte pointer so the function can look at it as an array of bytes. The last argument is just getting the size of the Temp variable so the function knows how many bytes to read after the initial location.

LazyGlen

  • Newbie
  • *
  • Posts: 48
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #16 on: January 03, 2014, 08:05:06 AM »
if (radio.sendWithRetry(GATEWAYID, (const void*) (&Temps), sizeof(Temps)))

I don't understand "(const void*) (&Temps)?  Can you explain that one to me?  This is some way of pointing to the structure yes?  Do you have any links that led you to this? 


Truth be told:
  • That part isn't my code, it was copied directly from Felix's Struct_send example code.
  • I didn't really understand it either, but since you asked the question I looked it up.

From http://www.learncpp.com/cpp-tutorial/613-void-pointers/
Quote
The void pointer, also known as the generic pointer, is a special type of pointer that can be pointed at objects of any data type! A void pointer is declared like a normal pointer, using the void keyword as the pointer’s type:
The sendWithRetry function's job is simply to send to another radio with a given ID number (arg1), data from a section of memory (arg2), some number of bytes (arg3). To avoid having to write a different send function for each type of data, Felix wrote it as taking a pointer to the data, and since it could be data of any type, it is a generic pointer.

From http://stackoverflow.com/questions/5547131/c-question-const-void-vs-void
Quote
As a general rule, if a function you write takes in a pointer to a value that you're not going to modify, then the function signature should use a const pointer. Using a pointer that isn't declared const means that the memory you're pointing to is allowed to be modified.

So, the way I understand it, if we were to send data to the function as a 'regular' variable, a copy would be sent to the function and we have no worry that it will modify the original data, But we would need to have different functions for different types, or cast the data from one type to another which is not really good programming practice. So we are instead sending a pointer to the location of the actual data. This means the function has the opportunity to modify the data (whether it does or not), which could lead to unexpected results. To keep this from being an issue, the function call is written with the const to tell both the programmer and the compiler that the data will not be modified by the function.

Please, any of you who actually speak C, confirm or clarify.

LG

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #17 on: January 03, 2014, 08:20:56 AM »
I think we both replied at the same time and mine went through first :P
But you're spot on, just another way of putting it, more documented I suppose, thanks :)
I love how C really forces one to understand memory allocation and pointers, the bare metal of computer programming.
That's why C is the border between copy and paste programmer land, and true computer science land, no offense intended ;)
« Last Edit: January 03, 2014, 08:23:11 AM by Felix »

LazyGlen

  • Newbie
  • *
  • Posts: 48
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #18 on: January 03, 2014, 08:36:32 AM »
I think we both replied at the same time and mine went through first :P
But you're spot on, just another way of putting it, more documented I suppose, thanks :)
I love how C really forces one to understand memory allocation and pointers, the bare metal of computer programming.
That's why C is the border between copy and paste programmer land, and true computer science land, no offense intended ;)

Yeah, I got the "another reply was posted" warning, but I had spent 20 minutes figgering it out for myself and writing it up well enough so that I thought I understood it and I'll be durned if I aint gonna post it!

No offense taken. I was always better at hardware than software through college. I wish now that I had forced the issue and REALLY learned C.

LG

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #19 on: January 03, 2014, 10:21:21 PM »
Thank you both, LG and Felix,

     I've got it now. I'm starting to remember things now.  I remember at the time I was writing C code and this wasn't a very long time at all that Void pointers were taboo.  I was working on a Sparc workstation in a Unix environment.   I remember we had just got 16 colors!  It was amazing at the time.  You could do it but you had to force the compiler to let you do it.  I've got to forget some of the rules from the past. 
    Going on Felix's idea of getting closer to the computer.  I think that is why I've written in Assembly since then.  You know exactly what is going on.  You are in control of all timing.  The higher the level of language the harder it is to keep track of such things.  I am enjoying this though.  It takes much less time to code.  I feel as LG too.  I wish I hadn't walked away from C.  I'm amazed how far it has come with micros.  The wealth of libraries, and available functions for Ardiuino is really nice.
     I'm looking forward to being able to help you guys out.  Perhaps one day. 
     

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #20 on: January 04, 2014, 12:29:44 AM »
     Got it up and running.  I'm glad to have changed to the packet format.  I'm seeing what looks like an obvious pattern here.  I'm getting an invalid packet after pinging the Node from the Gateway.  I don't receive a reply to the ping....but...I get an invalid packet.  Perhaps I am getting the reply but I'm interpreting it wrong?
     Now I've just got to box this thing up and put it in place.  Oh forgot to finish the Raspi part of it. :o 



TerminalDataNoPingReturn by hexibot43, on Flickr

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #21 on: January 04, 2014, 09:49:16 AM »
Thanks for attaching a link and not embedding the pictures .. helps with keeping my backups smaller even though they keep growing and growing and taking longer to generate and copy.

I've done a fair share of assembly in university courses and I have to say it's not the answer to my prayers in terms of productivity. It's great and probably required to understand computer architecture but I'll prefer compilers and assemblers to do the hard work.

On your ACK issue ..
I think you're getting back an empty message with the ACK flag set. Not sure if you posted code (sorry about being too lazy to check) but unless you send the ACK message with an actual payload, you will get just that ... an empty message (length 0) but with the ACK header flag=1, enabling to you check whether an ACK was received. So instead of trying to match your real expected payload to the ACK, just check whether it's an ACK. Look at the struct send/receive examples where I send with ACK:

https://github.com/LowPowerLab/RFM69/blob/master/Examples/Struct_send/Struct_send.ino
https://github.com/LowPowerLab/RFM69/blob/master/Examples/Struct_receive/Struct_receive.ino

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #22 on: January 14, 2014, 01:08:56 AM »


Quote
I think abstracting the sensor reporting a bit would be worth the bit overhead. I'm not sure if we'd need to go to the point of using the Adafruit Unified Sensor Driver framework but it might not hurt. A data string would consist of:

     The idea of a Unified sensor driver is really growing on me. 

     Things are really starting to work now that I've actually got the radios working.  And working really well.  I can't believe how well these Moteinos are working.  I can communicate from one corner of my property to the other without a hitch.  Somehow I had it in my head that I'd bought them with just RFM69w radios instead of the RFM69hw which I have.  I'm getting old.

     I spent this last Saturday setting up a web server on a Raspberry Pi.  Took me two tries to get it up and running with Apache2+php+mysql.  Actually got a couple webpages up and running locally.  For some weird reason my ATT router doesn't seem to want to allow me to provide a port forwarding to it.  It won't list the Raspberry PI as an available device for port forwarding ?!?!  I've got it hooked up via wifi to an access point on my network.  I'm guessing I'm going to have to wire it.  Well once I get it connected to the NET I'll post a link.

     Now I've just got to figure out the part in between.  Can Node.js, and socket.io be easily installed into Apache2 with PHP and Mysql? 

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #23 on: January 14, 2014, 09:44:04 AM »
Now I've just got to figure out the part in between.  Can Node.js, and socket.io be easily installed into Apache2 with PHP and Mysql?
Node.js is standalone and doesn't depend on the LAMP stack. But they can work together of course. Socket.io piggy backs on node.js (think module). I stopped using Apache and moved to Nginx since it's much lighter on the Pi. But Apache works too..

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #24 on: January 14, 2014, 11:34:28 AM »
Quote
I stopped using Apache and moved to Nginx since it's much lighter on the Pi. But Apache works too..

Yes, I think I'm going to try your approach.  It will make things easier to ask questions if I have problems.  I attempted to add socket.io and node.js to the server I had already installed.  I was able to verify installation of all of it, but when I went to go run the the Chat.html code it looked like it couldn't interpret the first part of the code and so just pumped it as text to the web server.  I will try and get a screen dump of it when I get home.  Perhaps someone has some insight.  But I will be buying another SD card on my way home to give Nginx a try.  Thanks Felix for everything.  This is a fun journey.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #25 on: January 16, 2014, 02:39:26 AM »
Quote
// During this time power consumption is minimized
   radio.sleep();  // Put radio to sleep      This worked
Narcoleptic.delay(60000); // this should be 1 minute?   This didn't
   radio.wake();  // Turn Radio back on  This didn't work.

     The radio sleep function was accepted by the compiler.  But I couldn't seem to get the wake function to be accepted.  Is there a wake function in the RFM69 libraries?  And for some reason my call to the Narcoleptic library was a bust too.  There was no delay.  I put a delay call in its place and that works just fine as a time delay.  But no sleep for the Moteino.  Is this library compatible with the Moteino?  The Naro delay only lasts about 9 millis.  Watching the serial out confers this.  If I put a simple delay(60000); in it's place I get the full 1 minute delay.  I know the Millis() function timer is suppose to be stalled when you call Naroleptic.delay but it doesn't seem to be doing that either.

Quote
https://code.google.com/p/narcoleptic/issues/detail?id=3
 

Has anybody else tried this library?

   
« Last Edit: January 16, 2014, 02:57:46 AM by hexibot43 »

LazyGlen

  • Newbie
  • *
  • Posts: 48
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #26 on: January 16, 2014, 09:05:46 AM »
[Yoda voice]Felix say, wake, there is not, send, there is.[/Yoda voice]

...
I was wrong about wake. There is no wakeup in RFM69, only a sleep() function. When you want to wake the radio, you don't have to do anything, just use send() or sendWithRetry() directly and the radio will wake up. ...

I had some wonkyness using the LowPower.powerDown() function as well, it did not seem to be sleeping the way I expected, I did not debug this. I have not tried the Narcoleptic library.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #27 on: January 16, 2014, 10:00:42 AM »
I have used narcoleptic and it works fine.
There is no radio.wake() function for RFM69. The radio will wake whenever you will try to do anything else other than sleep with it.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #28 on: January 16, 2014, 10:12:01 AM »
Thanks LG

I had feeling that was what you were going to say about the radio library.  Half my problem solved.  I get the power usage down and I'm ready to deploy my first Moteino to the backyard for good! 

Did you ever find a good way to sleep the Moteino?  I was going to try the LowPower library next to see what happens.  Now I'm wondering if that is the right move.....

Alright Felix - I will look for something else wrong with my copy of the Narcoleptic library and try again.  Thanks

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #29 on: January 17, 2014, 10:05:02 AM »
     Wasn't having good luck with the Narcoleptic Library.  For some reason I wouldn't get the delay.  My code ran like the call to the library wasn't even there.  8 millis time to run the call to the library.  Not sure what was going on there.  Switched to

https://github.com/n0m1/Sleep_n0m1

And now I've got what looks like a shutdown, and an actual sleep time of 1 minute for the time being.  Looks like even the Millis counter is being shut down.  By the count about 100 millis tick off in the course of a minute. 

Not sure what my problem with the Narcoleptic library.  If anyone has any insight I'm all ears. 

Time to remove all the serial debugging code, box it up, and put it in place.

Code for my Node as it is now.

http://codebender.cc/sketch:26389

Learning a lot here.  The next nodes should be a lot easier now.  Thanks everyone for all the help.  I'm really impressed with the Moteino.  It is exactly what I need, and no more. 

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #30 on: January 29, 2014, 08:36:16 PM »
     Finally got a web server up and running, and live online.  Just a set of static pages for now.  Still trying to learn how to push the data received by my gateway Moteino, and dump it into a Mysql database on the Raspberry PI.  I think I've got NodeJs up and running and socket.io.  Yeah right.  I've got them both stating their current update level.  So they are there.

     I'm guessing the next thing I need to do is point socket.io to the comm port of my USB connection.  I haven't tried programming the Moteino from the PI.  I'll try that tonight to verify connection.  I've had the gateway connected to my laptop while getting the Moteino part of the system up.

     Looking forward to having the connection between Moteino and RaspberryPI done and over with....Then all I need to do is code on the PI.  Push incoming data to the Mysql Database, and provide data for the webpages from the Database.  Can't wait to have live data on my webpages.

http://mabs.ghostnation.org:8888/index.php

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #31 on: March 25, 2014, 11:47:21 AM »
     I've been slowly continuing to work on this project.  Ok, very slowly.  I had to learn Python, and Mysql, and I think I'm getting old.  It doesn't come as fast as it use to.  Anyway, I just got the mysql database working correctly, with data coming in from the Moteino network.

    I'm still having problems with my power consumption.  My battery is not lasting as long as my predictions....  Could you all look at my code and see if you see anything that stands out.  I can't see any consumption on my Multimeter during the off time at all.  It is currently set to provide info every 5 minutes and shut down the rest of the time.  It is doing that.  I am not powering the sensors off a I/O pin as I was doing before.  I've just got them hooked to the output of the regulator.  So that is on DHT22, and 2 DS18b20s.  Nothing else.  All powered by a single Duracell Procell 9v.  I don't even have a circuit to measure battery power hooked up.  I've just been taking readings of Open Circuit Voltage with a multimeter once, or twice a day. 

     Battery Voltage starts at 9.62 volts on 3.16.14  by Today I'm at 9.12 volts.(3.25.14).  I'm just waiting for it to stop functioning to get an idea of longevity...but I don't think it is looking good.
   
     Here is my code as it is today.  I've turned off all my debugging. 

https://codebender.cc/sketch:26389

     Any ideas or insight? 

Thanks,

Mab



Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #32 on: March 25, 2014, 01:02:44 PM »
Your sensors is probably where current is being leaked if they are permanently powered. To get real power savings you should sleep EVERYTHING including sensors since EVERYTHING uses power.

Also to reduce the output power on a HW you will have to keep in mind that the HW power scale is not linear but rather divided into 2 scales: 0-15 and 16-31 which are equivalent (they do the same thing, ie 15 has the same effect as 31). See this post for explanations: http://lowpowerlab.com/forum/index.php/topic,362.msg2043.html#msg2043

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #33 on: March 25, 2014, 03:41:34 PM »
Felix - So having set my power to 16 (or 1) will be at the lowest power output, and so I will hope the least power usage as well.  But this is in combination with the High Power registers.  I have them on so I'm at +5db.  If I turned them off I could get down to +2db output gain.  I think I got it.  Why is there always some little strangeness to everything.  Why do they even have 16-31.  Why not just 1-15 and leave it at that?  I know you didn't build it.  For every rule there is an exception. 

Will go back to driving all the sensors via I/O pins from the Moteino.  I just couldn't even read the at rest load on my Ammeter.  Nor my MilliAmp meter.  I think the DS18b20 at rest drain is measured in NanoAmps, and the DHT22 is in MicroAmps.  But it is easy to go back to driving them from an I/O so tonight we'll make a change and try again....Thanks   

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #34 on: March 27, 2014, 01:57:55 AM »
     Alright, changed the code, and the hardware.  Driving the DHT22, off one pin, and the two DS18b20s off another.  The DS18b20s worked right away.  Bad data from the DHT22.  To test my code and hardware, I just remarked out turning off the power pin for the DHT22, and it started working again.  I really hate to have to turn it back on, and wait for it to warm up before using it again.  I had noticed that when starting up the Moteino that the DHT22 would usually give me bad data the first time I used it, but after that it would work fine. 

Any suggestions?  Is there a good Humidity sensor that I could use instead?  The Ds18b20s work so well, and I bought a lot of them so adding another one of those is no big deal.


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #35 on: March 27, 2014, 08:10:03 AM »
A good humidity sensor that is battery friendly? I'm not sure. I haven't used humidity sensors much. There are some more expensive sensors like this: http://www.adafruit.com/products/1638
I can't speak to whether they work better though. Quite pricey!

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #36 on: March 27, 2014, 10:00:35 AM »
Been doing some looking myself too.  Looks like I've found something to try..  Still looking but this one uses 240uAs during conversion.  Very Battery friendly.  And only about $10 each.  I will just need to figure some way to mount it.  Still looking...though.  I would much rather have a package like the DHT22 which is easily connected without making a PCB.

http://www.mouser.com/new/Silicon-Laboratories/silabs-si7005/

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #37 on: March 27, 2014, 11:25:58 AM »
Ok it takes about 500 250 milliseconds for the DHT22 after being powered on to provide valid data.  I wish that was in a datasheet.  Maybe it was, but I didn't see it.  Seems there is a lot of controversy with these sensors.  Lots of different wiring, etc,..

Since I was always noticing that my first conversion was always bad data, going to move my delay from the end of the code to the beginning where it should have been in the first place.  I'll just power the DHT22 up and go back to sleep (not delay) for 500 250 mills.  So instead of it being on all the time, it will be on for about .2 .1 seconds longer than my original up time.  And off for 5 minutes completely.  Will be putting a new battery in tonight and start the clock again.  Crossing my fingers.  Of note, the DS18b20s don't seem to need this time at all.  They worked without any delay after powering them up.   hmmmm, I am going to re-verify they, the DS18b20s, aren't getting power from the signal line to the Moteino.
 
« Last Edit: March 28, 2014, 12:31:11 AM by hexibot43 »

A

  • Newbie
  • *
  • Posts: 43
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #38 on: March 27, 2014, 12:02:46 PM »
Been doing some looking myself too.  Looks like I've found something to try..  Still looking but this one uses 240uAs during conversion.  Very Battery friendly.  And only about $10 each.  I will just need to figure some way to mount it.  Still looking...though.  I would much rather have a package like the DHT22 which is easily connected without making a PCB.

http://www.mouser.com/new/Silicon-Laboratories/silabs-si7005/

Si has come out with a second generation of humidity sensors that use even less power. I use the si7021 on my WeatherShield and I've been quite happy with the performance. http://www.silabs.com/products/sensors/humidity-sensors/Pages/si7013-20-21.aspx

If you want a breakout board that is code compatible with the Si702x, though not quite as energy efficient, you can get one from SparkFun. If you're dead set on the Si7005 and you're willing to wait 3 weeks, there is a breakout board for it on Tindie.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #39 on: March 27, 2014, 08:11:19 PM »
Thanks A,

     I'm going to get one of the ones you mentioned, and give it a try.  I'll know in a week how my battery is lasting.  Code modified to conform to the wait  time of the DHT22.  At least I figured out why when rebooting my first conversion would not be good.  Only has to be on .2 .1 of a second instead of on the whole time so that should help.  .2 .1 seconds for every 5 minutes.... 

    As soon as these rains stop here my greenhouse will be going in.  Managed to get 15 55gallon barrels so far.  I've been luckily getting them for free.  And I have managed to score a glass roof with the chicken wire in it for free too.  Well the glass is suppose to be free.  We'll see how much free costs me.  I'm sure quite a bit of beer at least.  Looking forward to posting pictures of everything once it gets moving.       
« Last Edit: March 27, 2014, 11:10:03 PM by hexibot43 »

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #40 on: March 28, 2014, 12:49:52 AM »
Changes made to software. 

Confirmed 250ms wait time sufficient to provide valid data from DHT22 sensor after re-powering unit up. 

Powering DHT22 up 250ms before the rest of code loop starts running, and going back to
sleep for 250ms.  Also added 250ms sleep after powering up for the first time  in the Dht22 setup routine, which got rid of my bad data at first conversion.  Appears to be providing valid data at all times now.

Starting with fresh battery @ 9.62Volts  @ 9:15pm 3.27.14 Recorded while in sleep mode.

Crossing my fingers that I don't see such a rapid fall off in voltage.

 
 

Appears to be working well.  Time will tell.  Back to working on Web Interface. 
« Last Edit: March 29, 2014, 10:07:22 AM by hexibot43 »

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #41 on: April 04, 2014, 11:29:58 AM »
Well after  almost a week I am seeing no improvement in battery performance.  It looks about even. 4-5 days I'm down from 9.62 to 9.21 volts.


         Moteino Battery Life using 9 volt battery Starting with fresh Duracell Procell               
                        
1st Run with all three temperature sensors connected directly to regulator output                        
                        
03/16/14   02:00:00 PM   9.62                  
03/17/14   07:12:00 AM   9.44                  
03/17/14   06:37:00 PM   9.41                  
03/18/14   07:20:00 AM   9.38                  
03/18/14   06:40:00 PM   9.35                  
03/19/14   07:20:00 AM   9.33                  
03/19/14   08:40:00 PM   9.31                  
03/21/14   07:05:00 PM   9.25                  
03/22/14   08:14:00 AM   9.21                  
03/25/14   07:10:00 AM   9.12                  
                        
                        
2nd Run with all sensors being powered via I/O pins of Moteino – allowing them to be shut off during sleep time                        
Note:  The DHT22 sensor had to be started up 250 milliseconds early to allow for proper conversions with this setup.                        
                        
03/27/14   09:15:00 PM   9.62                  
03/28/14   07:21:00 AM   9.55                  
03/28/14   08:00:00 PM   9.48                  
03/30/14   08:40:00 AM   9.29                  
03/31/14   07:20:00 AM   9.22                  
04/02/14   11:59:00 AM   9.07                  


     I think it is time to just bail on trying to use a 9 volt battery.  Time to break down and buy that Lipo battery and solar panel I've been thinking about.  I've been looking at all they have at www.voltaicsystems.com.  I can't make up my mind.  I didn't want to get anymore than I need, but at the same time want to ensure that I've got it covered. 

   How long are the batteries lasting on the Mail Mote?  I'm thinking they aren't doing the same thing though.  Only once an event has occurred do they have to turn on.  My weather Mote is ON every 5 minutes, along with three temperature sensors.   

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #42 on: April 04, 2014, 11:40:50 AM »
FWIW the battery will drop rapidly towards 9V then the rate of drop will slow down. That's like when you drink out of a bottle with a long neck. Those first sips will seem like will empty the bottle by a third, then it gets better. I've seen the same behavior in my duracell 9V batts.
Of course depending on how much power you actually draw when not sleeping will be a factor in how fast the batt will ultimately drain...

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #43 on: April 04, 2014, 08:05:49 PM »
Jing-Jing!

     The information I could find was leading me to believe that my battery was at almost a 0% state of charge when it reached 9 volts.  I will leave this unit up and running to see when it finally just stops producing data.  Any idea of what battery voltage you'd see when the Moteino is close to stopping to function?   

     I got a Weather shield from A for my birthday on Wednesday.  And I've still got one Moteino that I haven't yet used, which is already nicely soldered in place.  I'll just leave the other and start playing with this to keep myself busy.

     The weather hasn't been playing nice and I'm not so into construction in the rain.  I've now got something like 15 55 gallons plastic drums ready to be turned into a Aquaponics system.  We are currently in Drought here in California.  I think they just said we have 33% of the snow pack we need in the sierra to carry us through to the next season.  And yet it hasn't stopped raining here?!?  Supposedly Aquaponics only uses about 20% of the normal water used to producing vegetation.  Here's to hoping Aquaponics will allow me to keep growing all the Genovese Basil, Thai Basil, Red Peppers and San Marzano Tomatoes we can eat without the water company shutting me down. 

     I guess I'll have to throw in a simple voltage divider to track the  battery voltage.  I've been walking out and taking  readings with a voltmeter, which has already gotten tedious. 

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #44 on: April 05, 2014, 01:17:25 PM »
I've used a 9V for my mailbox notifier and I've seen some crazy swings in voltage. The issue is we've had a brutal winter here and cold really takes a hard toll on the 9v cell. Warm temperatures will always bring voltage up and cold will kill it. Still it lasts for many months, transmitting every 16sec.
The voltage will drop to as low as 5.xV before it will finally die. The lower the voltage gets the less waste there is in the 3.3V regulator. So if you're at 9V or even below your battery is very alive and well, still going to last for months if you only draw a few uA most of time and transmit every half minute or so.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #45 on: April 05, 2014, 05:31:35 PM »
    Thank is lot Felix, that is what I needed to hear.  Going to just install a simple voltage divider to measure the battery state and walk away from this for a while.  I'm feeling much better about the battery now.  I had got some bad data off the net. 

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #46 on: April 11, 2014, 11:36:58 AM »
I know it's me but can someone set me straight here.  I've been doing a lot of reading, and a lot or trail and error...more error getting a reading of my battery voltage.  I've attached the battery voltage positive to A0 pin through a voltage divider.  1 MOhm  to the B+,  470KOHM to Ground with a 1uf ceramic cap in parallel, and finally A0 connected to the center of the circuit.  The voltage divider part of the circuit appears to be working perfectly.  With 5.12 Volts at Vin, I'm seeing 1.575 volts at A0 to ground.  Where the problem is coming into the circuit is what I'm reading at the ADC.  I wrote a very very simple test program that is just accessing the ADC at A0 and spitting out a reading.

https://codebender.cc/sketch:33493

     I'm getting a value returned somewhere around 98-100.  If I calculate that out  98 * 3.3 Volts / 1023 =   .316 volts.....  I checked my Regulated voltage and 3.3v out is 3.3 volts and not something else. 

     Where am I going wrong here? 

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #47 on: April 13, 2014, 11:24:33 PM »
     I just got it working, but really want to know why it wasn't working when using A0.  The only thing I did to get it working was to change from A0 to A7.  Is there something I need to know about the A0-A5 to use them as analog instead of Digital?  My ADC test program is now working well.  The only thing I had different than what I had been reading was the Analog pin I was using. 

    So what is the Deal-i-o?  I couldn't find anything.  But it works on A7 and not on A0.

 

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6370
  • Country: us
    • LowPowerLab
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #48 on: April 14, 2014, 12:41:36 PM »
Perhaps a damaged IO pin?

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #49 on: April 14, 2014, 09:46:10 PM »
Why that thought never occurred to me I'm not sure.  But all is good.  Now deployed and we'll wait until no more data is being reported to give get a true determination of battery life.  At least it has kept me from the website design end of it all.  I don't have any more excuses for not finishing it now.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #50 on: April 22, 2014, 12:53:11 AM »
     I'm realizing I need to add some kind of light sensor into my project.  I'm making my third attempt at growing Bell Peppers.  I've had very little luck.  I've been doing a lot of reading and want to gather as much empirical data as I can.  All the temperature sensors are working really well. 

     This is what I've looked at so far.

http://www.adafruit.com/search?q=light+sensor

     Anybody have any suggestions here. 

Thanks,

Mab

jra

  • Jr. Member
  • **
  • Posts: 81
  • Country: us
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #51 on: April 22, 2014, 10:07:21 AM »
You're further along than I am.  My ultimate goal is to deploy a sensor/control system in my cold frame that will allow me to measure the basics (temperature, humidity, light, soil moisture) and minimize the temperature swings by controlling  a small space heater and an exhaust fan.  I've gotten as far as deploying solderless  breadboard prototype 0.1 to monitor temperature and humidity and transmit the information to a RPI for logging .  To measure light, I would use a sensor that has a logarithmic output.  Adafruit has one for $3.95 http://www.adafruit.com/products/1384 which is probably less expensive than starting with a dollar photocell and building/tweaking your own log amp.  I've not had much luck with sweet peppers either, they seem to require a very long growing season.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Backyard WeatherStation for Planting and later Aquaponics.
« Reply #52 on: April 22, 2014, 10:13:31 PM »
You're further along than I am.  My ultimate goal is to deploy a sensor/control system in my cold frame that will allow me to measure the basics (temperature, humidity, light, soil moisture) and minimize the temperature swings by controlling  a small space heater and an exhaust fan.  I've gotten as far as deploying solderless  breadboard prototype 0.1 to monitor temperature and humidity and transmit the information to a RPI for logging .  To measure light, I would use a sensor that has a logarithmic output.  Adafruit has one for $3.95 http://www.adafruit.com/products/1384 which is probably less expensive than starting with a dollar photocell and building/tweaking your own log amp.  I've not had much luck with sweet peppers either, they seem to require a very long growing season.

     Ordered a couple of those Sensors just this moment.  I'm having much better luck listening to everyone's good advice rather that bumbling through it myself.

     I did some ( A Lot ) of reading last night on growing Peppers.  First thing that was said was never use peet pellets.  Or peat period!  Peppers don't like it.  I've had such good luck starting other vegetables in those peat pellets on my kitchen window sill I never thought that would be an issue. 

http://www.ecoseeds.com/Pepper.growing.tips.html

   Doing a little research last night came up with a company right in my town.  They had lots of tips.  I love roasted bell peppers, and want to can my own so that I'll have them all year.  I've got friends who have them coming out their ears and they are only 10 miles away from me.  I think that it is even colder in San Mateo than here in Redwood City.  I've a south facing wall that is painted white.  I've decided to put a couple planter beds right there and see what happens.  I'll be placing another Moteino there as soon as those sensors from Adafruit show up. 

    I've never done a cold frame before either.  I think you are way ahead of me.  That looks like it might be a good way to keep the heat up.  I'm just really worried when, or if Summer ever gets here it would be too much.  My backyard gets to 100F.  A lot of people I talk to say that my Greenhouse will be too hot.  I'm planning on having a curtain system that will move to help control temperature.  But I'm no where near any of that yet.  First I have to complete the Green House. 

    Thanks for the input.  Let you know if I stumble on something that works with the Peppers.

Mab