Measuring internal temp of oysters and mussel

’ I plan to use a setup to monitor the internal temperature of oyster and mussel biomimics (the node will be above water). I plan to use about 20 Adafruit Feather M0 RFM95 nodes each with approximately 15 DS18B20 sensors embedded in shells. So far I have managed to get a node to talk to TTN using an adafruit example sketch (ttn_otaa_feather_us915_dh22).
I can get the node to read DS18B20s on a separate sketch, but I am having trouble incorporating my DS18B20 code into the adafruit sketch.

I went to https://community.hiveeyes.org/ but had trouble finding what I was looking for given that most of the posts are in German.

Any help with code or a point in the right direction would be great.
Thanks so much.

Daniel

1 Like

Dear Daniel,

thanks for your interest in our system. All of our code is on GitHub at [1]. As you might specifically be looking for the Arduino sources, [2] might be the right place to go to. [3] and [4] are the most advanced firmware variants we are keeping around there.

Reading from DS18B20 sensors should be pretty much straight-forward, as e.g. [5] shows.

With kind regards,
Andreas.

[1] https://github.com/hiveeyes
[2] https://github.com/hiveeyes/arduino
[3] https://github.com/hiveeyes/arduino/tree/0.16.0/node-gprs-http
[4] https://github.com/hiveeyes/arduino/tree/0.16.0/node-wifi-mqtt
[5] https://github.com/hiveeyes/arduino/blob/0.16.0/node-gprs-http/node-gprs-http.ino#L291-L299

1 Like

Daniel I opend this Q+A topic for you.

maybe you can explain a bit more about this project, what is the final objective, the duration of the measurements, the interval the samples are transmitted, the distance to the gateway ect ect.
how do you power this sytem (floating solarpannel/batteries ect)

  • mussels/oysters are under water, how deep
  • why did you choose these (relative big) sensors (do they fit?)
  • you probably can’t have 300 wires from the bottom to the floating node(s) ,So I think your nodes should be under water close to the mussels and only an antenna wire goes to the surface ?

also you can’t extend the sensor wires (like to 10 meters) without consequences
57%20PM
source

Thank you @amotl for the GitHub links. I will take a look.

Thank you @BoRRoZ for starting this thread.

In short : I am part of a team interested in using biomimics to monitor the internal temperature experienced by salt marsh mollusks at the Sapelo Long Term Ecological Research (LTER) site in Georgia, USA. Environmental temperature is highly variable. In our tidal system, shade, elevation, shell aggregation and body size all play a large role in the temperatures that these organisms experience. By placing biomimics (mussel, oyster and snail shells filled with silicone with an embedded DS18b20 temperature sensor) at different marsh locations we can get an idea of how habitat variables affect organism temperature. We plan to use Adafruit Feather M0 RFM95 nodes to communicate biomimic temperature data with TTN. This is work in progress so look for future updates and pictures. Also all advice is most welcome.

Background: I have used bare bones arduinos and DS18b20s to log marsh temperature data as part of my dissertation, however there is always the risk that a sensor or whole logging unit will breakdown. Coastal Georgia marsh sites can involve wading through waist deep mud and as a result minimal site visits are preferred. Setting up real time monitoring helps alert technicians of a broken sensor or node and adds the advantage of a real time data stream. Initially I was considering a wifi mesh system using ESP32 boards but then I heard about TTN. Coincidentally I discovered that another local group was using TTN to monitor tidal height (Smart Sea Level Sensors). After reaching out to them they were interested in collaborating and established a TTN gateway on Sapelo Island where we are conducting this work.

20190501_111955
Typical salt marsh habitat. Tide rarely covers the top of the grass

Data Management: This I cannot speak to at the moment as I will not be dealing with this directly. Sapelo LTER has dedicated data management staff and they will be the ones figuring out how best to retrieve data from TTN and storing it.

Gateway: A MultiConnect outdoor gateway (not sure of exact model or antenna model) is attached to a weather tower (~8m) and has good line of sight of the 8km of salt mash between Sapelo Island and the mainland. While this summer I plan to deploy nodes within 3km, in the future we plan to deploy further from the gateway. Initial tests suggest that we should have no problem covering all marsh with line of sight and within 8km.

20190502_115610
Gateway on weather tower

image
8km range with cheap node antenna

Nodes: As I am in the finishing stages of my PhD and may not be around to trouble shoot this project once I get it up and running, I wanted a system with good documentation. While not the cheapest, adafruit products have great documentation and as a result I choose to use Adafruit Feather M0 RFM95 nodes. The nodes will be in water proof housing attached to a 3m support PVC pole that is driven into the ground. The top of the PVC pole where the node housing is attached will be above high tide. I will used about 5m of shielded cable to transfer data from the biomimics on the ground to the node. Given the < 3km distance to the gateway with great line of site I plan to use small <$10 antennas (make and model to be decided).

Power: I am still figuring out the best way to power the node. In the interest of time and cost I may just go with regular 1.5v batteries, but ideally I would like to use solar and 18650s. I also thought about a solar power bank like this, but at least with my cheap eBay one, when the node goes to sleep, the power bank cuts power and as a result the node does not have power to wake up (or at least that is what I think is happening). I am sure there are many work arounds, but I think I will save that for version 2.0. Also it remains to be seen whether these solar power banks recharge fast enough.

Biomimics: DS18b20 chips easily fit into oyster and mussel shells. The fit is a bit tight in Littoraria snail shells, but doable in the larger shells. Obviously smaller sensors like thermocouples would be nice, but they are more expensive, involve more complicated code and need a lot of pins. Multiple DS18b20 chips can be connected to one pin, cost less than $2 and have decent accuracy. We plan to deploy around 300 biomimics this summer. For these reasons I think they are the best choice for this project.

Balancing number of sensors/pin and sensors/node: This is work in progress. Based on projects that I done using 5v Arduino Unos, 5 DS18b20s on a 5 meter cable should work unless this changes with a 3.3V Feather M0. At the moment I am shooting for 5 sensors per pin and 15 sensors per node (300 sensors = 20 nodes).

Long term goals: While this is a 1 year proof of concept project, I think it will likely get extended and incorporated intro long term monitoring (>5 years) on Sapelo. I also think related projects monitoring other environmental variables such as tide height and flow are likely to spin off this one.

4 Likes

source

which one do you want to use, the left one should be waterproof (really?), the other you need to make a sensor yourself for under water.

Hi there,

All other problems like proper SPI configuration or appropriate TTN-Cayenne en-/decoding aside, but specifically regarding a possible

when reading from sensors while there’s something running side-by-side like the LMIC runtime.

It might imagine that - while appropriately handling the interrupts like already depicted above - you might also want to do the reading in an asynchronous way in order not to block the LMIC machinery.

When doing this in a way like depicted at getTemperature, you are in control of handling the conversion time required for reading the sensor and thus you can feed other runtimes or watchdogs appropriately in order not to block them. While this gains more flexibility, it is your responsibility then to apply a minimum time of 750ms for conversion between requesting the reading and actually reading it.

With kind regards,
Andreas.


P.S.: This answer was originally intended to be addressed to you over at Conflict between RFM95W/LMIC and DS18B20 temperature, @TijnOnlijn. So, if you still experience such timing problems you were talking about, this might help you along.

1 Like

Dear Daniel,

thanks for sharing such detailed information about your project. Good luck with everything!

Referring to all topics would require a really extensive answer, so I would like to pick just two things out of the topics you are listing which might help you and your colleagues.

Power

This is exactly what is happening.

Data management

About

We might have conceived the backend system of your dreams already by building an accessible open source data historian within the Hiveeyes Project. While originally built for the purpose of beehive monitoring, the whole system has been designed to be operated in arbitrary environmental monitoring projects of its kind - mostly in the field of academics as we are currently doing within the Bee Observer Project.

The system cares about data acquisition from multiple measurement nodes with easy onboarding, stores measurement data in a timeseries database (InfluxDB) and yields rich visualizations by building upon Grafana.

Details

For more details, you might want to have a look at

Example

As data telemetry and acquisition is rather invisible, I would like to share some of our most recent efforts on the visualization side.

Enjoy visiting Hive overview & Bee weather @ ZK/U Statista. As you can see there, we are also funneling data from the national weather service into the system in order to be able to correlate observations with weather conditions.

Bottom line

Please let us know if some of the things we are working on will spark your interest.

We recognize the forum is a jungle, so we are happy to help you navigate it or better pinpoint to specific software- and hardware-artefacts we are working on and which might be ready to apply them to your endeavor.

Also, I might translate content where appropriate. However, you are welcome to join the forum at https://community.hiveeyes.org/ which will enable you to use the online translation feature provided through https://meta.discourse.org/t/discourse-translator/32630.

With kind regards,
Andreas.

The ones on the left work just fine in saltwater conditions (at least for a 4 month deployment), but I have never come across ones that use shielded cable. I have seen the stainless steel caps for sale somewhere, so one could easily make their own with shielded cable. For this biomimic project we will be using the chips on the right and sealing them in silicone inside mollusk shells.

Thanks so much. I may well take you up on that offer as I work through this project. Cheers!

I modified the adafruit ttn_otaa_feather_us915_dh22 code. I used pin 10 as they use it in their sketch. I am guessing that the issues that @jdelaet and @galagaking mention are for a different board. I am using the Adafruit Feather M0 RFM95. I would prefer to go the DS18b20 address route given the large number of sensors I am going to be using, but failing that I will try the index method that @Ashi14 uses (@Ashi14 do you mind sharing your full code).

In the code bellow can anyone see what I am doing wrong. Thanks so much!

I altered the beginning of the code by adding

// include OneWire and Sensor Library
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 9 on the feather
#define ONE_WIRE_BUS 10

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Addresses of 2 DS18B20s
uint8_t sensor1[8] = { 0x28, 0x00, 0x09, 0x00, 0x18, 0x97, 0x21, 0x52 };
uint8_t sensor2[8] = { 0x28, 0x00, 0x09, 0x00, 0x91, 0x00, 0x22, 0xF1 };

and

// payload to send to TTN gateway
static uint8_t payload[5];
static osjob_t sendjob;

Then I altered the void do_send function like this


> void do_send(osjob_t* j){
>     // Check if there is not a current TX/RX job running
>     if (LMIC.opmode & OP_TXRXPEND) {
>         Serial.println(F("OP_TXRXPEND, not sending"));
>     } else {
> 
>         float sensor1 = sensors.requestTemperatures();
>         Serial.print("Temperature 1: "); Serial.print(sensor1);
>         Serial.println(" *C");
>         // adjust for the f2sflt16 range (-1 to 1)
>         sensor1 = sensor1 / 100; 
> 
>         float sensor2 = sensors.requestTemperatures();
>         Serial.print("Temperature 2: "); Serial.print(sensor2);
>         Serial.println(" *C");
>         // adjust for the f2sflt16 range (-1 to 1)
>         sensor2 = sensor2 / 100;
>         
>         // float -> int
>         // note: this uses the sflt16 datum (https://github.com/mcci-catena/arduino-lmic#sflt16)
>         uint16_t payloadsensor1 = LMIC_f2sflt16(sensor1);
>         // int -> bytes
>         byte temp1Low = lowByte(payloadsensor1);
>         byte temp1High = highByte(payloadsensor1);
>         // place the bytes into the payload
>         payload[0] = temp1Low;
>         payload[1] = temp1High;
> 
>         // float -> int
>         uint16_t payloadsensor2 = LMIC_f2sflt16(sensor2);
>         // int -> bytes
>         byte temp2Low = lowByte(payloadsensor2);
>         byte temp2High = highByte(payloadsensor2);
>         payload[2] = temp2Low;
>         payload[3] = temp2High;
> 
>         LMIC_setTxData2(1, payload, sizeof(payload)-1, 0);
>     }
> }

And added

sensors.begin();

to void setup. After compiling I get this error.

test:217:53: error: void value not ignored as it ought to be
float sensor1 = sensors.requestTemperatures();
^
test:223:53: error: void value not ignored as it ought to be
float sensor2 = sensors.requestTemperatures();
^
exit status 1
void value not ignored as it ought to be

Full code can be seen here

Feather MO with DS18b20.txt (12.2 KB)

if you publish code… please read this :wink:

The ‘pin 10’ issue is software related in the SPI software, so could indeed be the problem. requestTemperatures() is a function to get ALL the vallues, it will not return any value so you can not use float sensor1= to get the values. Take a look at examples like https://lastminuteengineers.com/multiple-ds18b20-arduino-tutorial/ to get the right values of your sensors.

2 Likes

one wire ‘hub’ / network ?

Thanks everyone for all your help. I managed to get my setup to transmit data from two DS18b20s to TTN, using pin 9 and some tweaks to my code. Next step is to get it to read data from multipule sensors on multipule pins. I will publish code here when I get it all worked out. Thanks again!!!

2 Likes

Hey
Have a look at my « chickens on TTN » project in this section, I believe it does what you want although it uses the TinyLora library (which I find simpler but more limited) instead of the LMIC

TinyLoRa doesn’t implement receiving at all. That not only means it cannot do downlinks or OTAA, it also means it cannot use Adaptive Data Rate and so must have its air settings manually tuned for the distance between the node and the gateway.

Something like LMiC is indeed complex, because LoRaWAN is complex.

Yes I know those limitations which I don’t mind in this particular case. The node is in a fixed location, very close to my gateway, so I have set the Data Rate to SF7BW125 and that works just fine. Also I don’t need receiving downlinks but that might change in the future.

Simpler and limited libraries which hide the complexities are a good thing as it enables beginners like me to get started and have results rapidly. That is motivating

It is not motivating when not LoRaWAN compliant. If you want to use LoRaWAN then it will be better to use a microcontroller that can handle a compliant LoRaWAN stack, or use a certified LoRaWAN module like RN2483 that handles the LoRaWAN protocol all by itself if you want to keep things simple.

Ok sounds lile a bas choice.
I am interested to understand better why this library (and/or chip) is not a good idea, in practical terms.
Thank you