Author Topic: Backyard WeatherStation for Planting and later Aquaponics.  (Read 27966 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: 6866
  • 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

  • NewMember
  • *
  • 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

  • NewMember
  • *
  • 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: 6866
  • 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

  • NewMember
  • *
  • 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

  • NewMember
  • *
  • 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: 6866
  • 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: 6866
  • 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