Forum Replies Created
-
AuthorPosts
-
We typically code our stations to cutoff modem transmissions at 3.45v, and file operations at 3.4v. The Mayfly will stop operating around 3.35v, so if you set your modem cutoff too low, then you’ll stop transmitting AND stop collecting data on the memory card at the same time. By setting the modem cutoff a little above the memory card logging cutoff, then you’ll have time to visit the station to swap batteries before you start losing data on the card. But in general, the station shouldn’t be falling that low repeatedly. Use a larger solar panel and make sure the battery pack is matched to it, based on the amount of sunlight you get on a typical day. Most of our stations stay in the 3.7v-4.0v range without user intervention to replace dying batteries.
The jumper for selecting whether the I2C grove port is constantly powered or switched powered was not intended to allow the user to turn off I2C devices on that Grove port. I designed the board that way because I wanted to give users at 2 separate Grove ports that could be powered either continuously or switched, because the other 4 Grove ports only give you the option of 3v-switched or 5v-switched. To avoid confusion, I probably should have only allowed people to choose switched power on the D4-5 Grove port and made the I2C Grove port be always on, but on earlier versions of the board, I was using a sketch that turned on and off the power to the I2C Grove jack because of a certain peripheral I was using on that jack. So the jumper is basically a relic from an earlier iteration of the Mayfly that has limited functionality to most people, but it’s there if you need it for a specific reason. Almost all users will leave it in the default 3.3v constant position.
2021-02-01 at 1:06 PM in reply to: Availability Grove 6-Pin Screw Terminal Stereo Jack Adapter #15097Right, that’s why I’m thinking you just need a screw terminal to Grove board, and since you only need 4 wires, you can use something like this: https://solarbotics.com/product/29118/
2021-01-29 at 4:50 PM in reply to: LTE-M1: Bluetooth, Cellular 4G LTE CAT-M1 (AT&T/Verizon) Availability #15088All bare-board electronics such as the Digi LTE cellular board and the EnviroDIY Mayfly are sensitive to static electricity and theoretically they could be damaged if you aren’t careful. That said, the Mayfly is pretty hardy and I haven’t experienced any problems after handling multiple thousands of boards over the last few years in all sorts of environments. However, the LTE module is more sensitive because of its exposed pins and more-sensitive electronics. You shouldn’t put it in your pocket or carry it around in your hand while walking around, especially on carpet in low-humidity environments. But you should be safe to remove it from the package and examine it if you’re careful, and you can connect it to the Mayfly board (using the LTEBee adapter board) at any time. Just be careful that you don’t damage the small header pins since they are easy to bend, especially when removing the Bee module from the adapter board.
Another thing to note, we usually ship most of the items EnviroDIY makes (like the Mayfly, the LTEBee adapter, and other accessories) inside a foil bag that has a “static sensitive” warning on it. Those are just the default bags that the manufacturer uses, and isn’t an actual warning. Just be careful with the boards like you would any sensitive electronic device: avoid moisture and physical damage.
2021-01-29 at 4:37 PM in reply to: Availability Grove 6-Pin Screw Terminal Stereo Jack Adapter #15087We used to sell the 6-pin screw terminal boards on Amazon, but don’t anymore. We do offer a 5-pack in our EnviroDIY ship page if you want to buy 5 all at once: https://www.envirodiy.org/product/envirodiy-grove-6-pin-screw-terminal-adapter-pack-of-5/
Otherwise as Beth said, you might be able to use a regular 4-pin screw terminal board that is widely available from lots of different vendors. We made the 6-pin version specifically for interfacing with the Campbell Scientific OBS-3+ turbidity sensors that have 6 wires and require 3 ground connections. It’s easier to use this 6-pin board with those sensors than trying to fit 3 ground wires into one single screw-terminal on regular boards.
Your sensor probably has a power wire, ground, and two data lines (analog or digital). If you have anything other than that, you might want to double-check before connecting it to the Mayfly.
The link Beth posted above is a 4-position, 3.5mm headphone jack adapter board made by someone else. We have a 3-position headphone jack in our shop, but you don’t need a headphone jack if your sensor has bare wires on it. You’d only use a headphone jack if you bought a sensor that comes with a 3.5mm plug on the end of the cable, like what Meter Group does.
2021-01-18 at 4:42 PM in reply to: LTE-M1: Bluetooth, Cellular 4G LTE CAT-M1 (AT&T/Verizon) Availability #15025Yes, Digi-Key has over 4,500 of them in stock right now: https://www.digikey.com/en/products/detail/digi/XB3-C-A2-UT-001/7932027
Mouser only has ~350 right now and is slightly more expensive than Digi-Key, so that’s why we recommend Digi-Key.
Note that Digi (makers of the cellular modem) and Digi-Key (an electronics distributor) have very similar names, but are completely unrelated.
Here’s an update for this topic: we’ve implemented the online shop here on EnviroDIY to sell 5-packs of various products, including the vertical microSD card adapter board. All prices include shipping (to US addresses only). Restocking items on Amazon has been extremely slow lately, so if anyone wants to buy Mayfly boards, kits, or accessories in multiples of 5, please use our EnviroDIY shop instead of Amazon. You’ll also save 10% that way too. We will continue to sell on Amazon as well, but this shop allows us to fulfill bulk orders quicker and without emptying our Amazon inventory as frequently.
After thinking about this old code yesterday, I was curious about what actually happens if a tip occurs during a long delay period, like the 2-second delay on line 123 and and 2.5-second delay on line 125 (which are delays to give the Xbee 900mhz radio module time to successfully wake up and then finish its routine before sleeping). I programmed a test board with the sketch from above, but increased the delay time to 10 seconds for each of those lines, to give me enough time to experiment. What I found was that if a simulated bucket tip on pin D10 happens anytime during a 10-second delay, the delay instantly ends and the interrupt routine successfully gets executed (meaning a tip gets counted) and then the sketch moves on with the next line of code (either line 124 or 126, depending on which delay the tip happened in). So this shows that no tips will get missed by the Mayfly, but the delay period gets instantly cut short. If you’ve got a radio or cell module that needs multiple seconds of uninterrupted wait times before doing the next step, then care should be taken about how you handle interrupts from D10 during that time. You could unattach the D10 interrupt during those important delay times, and then reattach it when you’re done, or find another way to handle either the interrupt or the telemetry delays.
Below is the code I wrote several years ago that is still running on all our local tipping buckets. This was way before all the ModularSensors libraries and MMW portal, so things could be written differently now, but it can give you and idea on how the Mayfly handles the interrupt signal from the tipping bucket. There’s a 1-second delay after a tip is sensed to filter out any switch bouncing that sometimes occurs when a tip happens.
First you need to enable the pullup resistor on pin D10, which is already built in to the Mayfly board, you just have to close jumper SJ12 on the back of the Mayfly. Then this snippet of the code shows how to set up your sketch to look for a low trigger from the tipping bucket switch:
Arduino1234//enable the D10 pullup jumper on Mayfly solder jumper SJ12 in order for the next 2 lines to workpinMode(10, INPUT); //sets pin 10 as an inputattachInterrupt(2, pin10interrupt, LOW); //sets up an interrupt looking for a LOW trigger//connect one terminal of tipping bucket to Mayfly pin D10, connect other side of bucket switch to Mayfly groundI’ve sent the full sketch code to various people in the past few years who have requested it, and I thought it was already posted somewhere here on the forum, but if not, here’s the entire sketch. The biggest weak point is probably the delays that surround the Xbee radio wakeup and sleep, totaling 5 seconds. If a bucket tip were to happen during these delays, they don’t always get counted. A better option would be to use a milli timer to let the Mayfly go back to looking for tips and then execute the radio on and off functions independently, without using delays. But missing 5 seconds out of a 5 minute period isn’t too bad. (We’ve got Hobo event loggers on these rain gauges to record the actual data, these Mayfly boards are just there to transmit the live tips to our in-house data viz page for realtime viewing.) If the Mayfly has to do even more time-consuming things like cellular transmissions, then having the secondary device like the Trinket would ensure that no tips are missed. There are certainly more efficient ways to build a simple counter, but cost-wise, it’s hard to beat a $7 Trinket. If someone simply wants to count tips of a rain gauge (or any switch close/open event), then this code minus the telemetry stuff works great as an event counter/logger.
Arduino123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371#include <Wire.h>#include <avr/sleep.h>#include <avr/wdt.h>#include <SPI.h>#include <SD.h>//SODAQ libraries#include <RTCTimer.h>#include <Sodaq_DS3231.h>#include <Sodaq_PcInt_Mod.h>String targetURL;#define READ_DELAY 1//RTC TimerRTCTimer timer;String dataRec = ""; //a string to hold the data recordint currentminute, currenthour;long currentepochtime = 0;float boardtemp = 0.0;int daily_tips = 0; //the number of tipsvolatile int TipFlag = 0; //flag indicating that a tip has occurredvolatile int AlarmFlag = 0; //alarm flagint midnightflag = 0; //flag showing that it's midnightint batteryPin = A6;int batterysenseValue = 0;float batteryvoltage;#define XBEE_SleepPin 23 // sleep pin of the Xbee 900mhz radio module//RTC Interrupt pin#define RTC_PIN A7#define RTC_INT_PERIOD EveryMinute#define SD_SS_PIN 12//The data log file#define FILE_NAME "RainLog.txt"//Data header#define LOGGERNAME "Mayfly Rain Logger"#define DATA_HEADER "DateTime_UTC,TZ-Offset,Loggertime,BoardTemp,Battery_V,RainTips"void setup(){//Initialise the serial connectionSerial.begin(57600); //computer connectionSerial1.begin(9600); //xbee 900mhz radio module in bee headerrtc.begin();delay(200);pinMode(8, OUTPUT); //green LEDpinMode(9, OUTPUT); //red LEDgreenred4flash(); //blink the LEDs to show the board is onsetupLogFile();//Setup timer eventssetupTimer();//Setup sleep modesetupSleep();//Make first callSerial.println("Power On, running: mayfly_rain_1.ino");//enable the D10 pullup jumper on Mayfly solder jumper SJ12 in order for the next 2 lines to workpinMode(10, INPUT); //sets pin 10 as an inputattachInterrupt(2, pin10interrupt, LOW); //sets up an interrupt looking for a LOW trigger//connect one terminal of tipping bucket to Mayfly pin D10, connect other side of bucket switch to Mayfly ground}void loop(){//Update the timertimer.update();if (AlarmFlag == 1) {// Serial.println(" DS3231 Alarm ");AlarmFlag = 0;if (currenthour == 23 && currentminute == 59) {midnightflag = 1;digitalWrite(8, HIGH);dataRec = createDataRecord();logData(dataRec);assembleURL();delay(500);wakeXbee();delay(3000);sendviaXbee();delay(2500);sleepXbee();delay(500);String dataRec = "";digitalWrite(8, LOW);midnightflag = 0;daily_tips = 0; //start the daily total back to 0delay(200);}if (currentminute % 5 == 0) {digitalWrite(8, HIGH);dataRec = createDataRecord();logData(dataRec);assembleURL();delay(500);wakeXbee();delay(2000);sendviaXbee();delay(2500);sleepXbee();String dataRec = "";digitalWrite(8, LOW);delay(100);} //end if minute % 5 = 0rtc.clearINTStatus(); //This function call is a must to bring /INT pin HIGH after an interrupt.AlarmFlag = 0;} //end " if alarm_flag=1"if (TipFlag == 1) {// Serial.println(" TIP! ");daily_tips++;delay(1000);TipFlag = 0;}//Sleep//Serial.println("Going to sleep");systemSleep();// Serial.println("AWAKE!");}void showTime(uint32_t ts){//Retrieve and display the current date/timeString dateTime = getDateTime();//Serial.println(dateTime);}void setupTimer(){//Schedule the wakeup every minutetimer.every(READ_DELAY, showTime);//Instruct the RTCTimer how to get the current time readingtimer.setNowCallback(getNow);}void wakeISR(){AlarmFlag = 1;}void setupSleep(){pinMode(RTC_PIN, INPUT_PULLUP);PcInt::attachInterrupt(RTC_PIN, wakeISR);//Setup the RTC in interrupt modertc.enableInterrupts(RTC_INT_PERIOD);//Set the sleep modeset_sleep_mode(SLEEP_MODE_PWR_DOWN);}void systemSleep(){//Wait until the serial ports have finished transmittingSerial.flush();Serial1.flush();//The next timed interrupt will not be sent until this is clearedrtc.clearINTStatus();//Disable ADCADCSRA &= ~_BV(ADEN);//Sleep timenoInterrupts();sleep_enable();interrupts();sleep_cpu();sleep_disable();//Enbale ADCADCSRA |= _BV(ADEN);}String getDateTime(){String dateTimeStr;//Create a DateTime object from the current timeDateTime dt(rtc.makeDateTime(rtc.now().getEpoch()));currentepochtime = (dt.get()); //Unix time in secondscurrentminute = (dt.minute());currenthour = (dt.hour());//Convert it to a Stringdt.addToString(dateTimeStr);return dateTimeStr;}uint32_t getNow(){currentepochtime = rtc.now().getEpoch();return currentepochtime;}void greenred4flash() //fast blinks the LEDs 4 times{for (int i=1; i <= 4; i++){digitalWrite(8, HIGH);digitalWrite(9, LOW);delay(50);digitalWrite(8, LOW);digitalWrite(9, HIGH);delay(50);}digitalWrite(9, LOW);}void setupLogFile(){//Initialise the SD cardif (!SD.begin(SD_SS_PIN)){Serial.println("Error: SD card failed to initialise or is missing.");//Hang// while (true);}//Check if the file already existsbool oldFile = SD.exists(FILE_NAME);//Open the file in write modeFile logFile = SD.open(FILE_NAME, FILE_WRITE);//Add header information if the file did not already existif (!oldFile){logFile.println(LOGGERNAME);logFile.println(DATA_HEADER);}//Close the file to save itlogFile.close();}void logData(String rec){//Re-open the fileFile logFile = SD.open(FILE_NAME, FILE_WRITE);//Write the CSV datalogFile.println(rec);//Close the file to save itlogFile.close();}String createDataRecord(){//Create a String type data record in csv formatString data = getDateTime();data += ",0,"; //adds UTC-timezone offset if your RTC is set to something other than UTCrtc.convertTemperature(); //convert current temperature into registersboardtemp = rtc.getTemperature(); //Read temperature sensor valuebatterysenseValue = analogRead(batteryPin);batteryvoltage = (3.3/1023.) * 4.7 * batterysenseValue;data += currentepochtime;data += ",";addFloatToString(data, boardtemp, 3, 1); //floatdata += ",";addFloatToString(data, batteryvoltage, 4, 2);data += ",";data += daily_tips;//Serial.print("Data Record: "); //if you want to print to the serial port//Serial.println(data);return data;}static void addFloatToString(String & str, float val, char width, unsigned char precision){char buffer[10];dtostrf(val, width, precision, buffer);str += buffer;}void assembleURL(){targetURL = "";targetURL = "http://somewebsite.com/capturescript.php?"; //put a php script on a server with mySQL database to capture the datatargetURL += "LoggerID=SL053&Loggertime=";targetURL += currentepochtime;targetURL += "&BoardTemp=";addFloatToString(targetURL, boardtemp, 3, 1); //floattargetURL += "&Battery=";addFloatToString(targetURL, batteryvoltage, 4, 2); //floattargetURL += "&RainTips=";targetURL += daily_tips;targetURL += "&Summary=";targetURL += midnightflag;}void sendviaXbee() {Serial1.println(targetURL);}void sleepXbee() {delay (1000);pinMode (XBEE_SleepPin,OUTPUT); // put XBee to sleepdigitalWrite(XBEE_SleepPin,HIGH);}void wakeXbee() {pinMode(XBEE_SleepPin,OUTPUT); // Set the "wake-up pin" to outputdigitalWrite(XBEE_SleepPin,LOW); // wake-up XBeedelay(500); //make sure that XBee is ready}void pin10interrupt(){TipFlag = 1; //a tip was detected, set the tip flag}Meter Group sensors like the Teros 12 come with either bare wires or 3.5mm stereo headphone jack plugs. Have you already purchased your sensors? If not, you can choose that option when you order. You can also request a custom cable length if you need longer cables than the default length, which I think is usually 3 meters on their soil sensors. Having them manufacture the sensors with extra cable length is highly preferred to splicing your own extensions on them. So depending on which cable termination you have on your sensor, you’ll need to figure how you want to connect them to your Arduino board. Are you using this setup indoors in a lab setting, or outside in the weather? How many sensors do you want to hook up to one Arduino board? How often are you going to take sensor readings? Are you going to be logging the data somehow? When you used the 10HS, did you use that with the Mega 2560, or something else?
-
AuthorPosts