2019-09-17 at 2:20 AM #13149
Hello and greetings from New Zealand,
My work group is developing some mayfly loggers and we have run into a problem using Modbus with a Yosemitech Y4000 sensor, measuring pH, conductivity, temperature, turbidity, and dissolved oxygen. We are attempting to communicate to this device using the WingShield and Modbus (as described on the EnviroDIY github) on the Mayfly. We have were able to successfully read data off of this unit for a while, but then, seemingly with no changes made to the code, we started getting a reading of -9999.00 for all of the sensors.
With additional fiddling, the problem got worse, and now it seems that when the mayfly tries to read and log the sample, the program just restarts from the beginning.
We are able to connect and read values off of the sensors using the GetValues.ino script in the YosemitechModbus library. However when we try to run a logging script based on the ModularSensors library, everything falls apart. I think it has to be a library issue, where my code just isn’t playing nice with one of the libraries in the EnviroDIY universe. I am using platformio with the libraries included in the ‘libraries’ enviroDIY repository.
2019-09-17 at 10:14 AM #13151Anthony AufdenkampeParticipant
@rachel.murray, that’s great to hear that you were able to get the YosemiTech Y4000 sonde working with our Modbus Mayfly Wing Shield and associated documentation. I developed all of that for a team at Winona State University in Minnesota, but I hadn’t been aware of anyone else trying to integrate the Y4000 with our EnviroDIY stack. So that’s satisfying to hear that you got it working, for a while.
BTW, are you working with my friend Troy Baisden?
I will say that the Y4000 sonde is the one sensor from YosemiTech that has given me headaches to get working and also to keep working. Unfortunately I haven’t kept up with documenting everything.
The first challenge with the Y4000 is that it needs a stable and consistent 12V of power with the capacity for high amperage draw during startup and when the brush is spinning. I was able to barely get it to work on the Mayfly with the Modbus Wing + two 680 uF capacitors, but only when no other sensors were attached. The system was browning out when I attached other sensors, and I’m guessing that if the radio were drawing power while the Y4000 is on that would also brown out the system.
The solution was to wire up an independent 2 Amp 12V power supply that is switched on & off by the Mayfly. While the power for the Y4000 system comes from this separate power supply, the Modbus communication still passes through the Wing Shield. None of this is publicly documented yet, but here are my notes:
Redo Y4000 line, with built-in power regulation and switching
Pololu Big Pushbutton Power Switch with Reverse Voltage Protection, HP,
– Vin to battery +, This powers the system
– GND to Battery
Sonde side (via regulator)
– Vout to 12V regulator Vin
– GND to 12V regulator GND
Mayfly Control side
– CTRL to Mayfly switched power (Setting D10)
– GND to system/Mayfly ground
Pololu 12V Step-Up/Step-Down Voltage Regulator S18V20F12
Battery Side (via switch)
– Vin to switch Vout
– GND to switch GND
– Vout to Sonde red
– GND to Sonde black
2019-09-22 at 11:09 PM #13158
Thanks for the reply,
Yes, I am working with Troy :). We have had some success with the decagon CTD, including using a wifibee and portable wifi hotspot to log data to monitormywatershed.org. It would be nice to have turbidity measurements as well, which is one reason we are interested in the Y4000 device.
In our y4000-mayfly setup, I have tried removing the wifibee modem, along with the associated code. I have also tried running with and without other sensors. We are currently testing using an external 12V power supply to power the y4000 (left on constantly for testing purposes). Regardless of the setup, the result is the same – the mayfly can’t seem to communicate with the sensor.
The mayfly reboots right after attempting to activate the brush. This makes a brownout seem like a likely problem, however connecting to an external 12V supply doesn’t seem to help. I’m wondering if there might be some sort of problem with the serial connection using Altsoftserial.
I’m going to try a few more tests and report back – are there any particularly useful debugging flags that could shed some light on the problem?
Thanks for your help,
2019-09-23 at 10:22 AM #13163Shannon HicksModerator
It’s hard to tell exactly what’s going on with your wires from the photo, but you should make sure your separate power supplies are sharing a common ground. If you’ve got 12v going to the sensor and 5v going to the board, you need to have the ground of both of those supplies (or batteries) connected to the same ground as the Mayfly.
2019-10-21 at 8:33 PM #13239
We have made sure that the power supplies are sharing the same ground. There seems to be some issue with the serial connection to the modbus, maybe related to a conflict in the libraries that handle the physical and software serial connections.
We are able to read values using SoftwareSerial as the Modbus serial connection and the ‘GetValues.ino’ script on the EnviroDIY Github (YosemitechModbus/Examples/GetValues), and we can also read values using a similar script with NeoSWSerial as the Modbus serial. However, we are unable to retrieve values using AltSoftSerial at all.
The software serial connections only work when I am running a simple test script that references the YosemitechModbus library. As soon as I try to run a logging script and reference the ModularSensors library, I can’t read any values off the Y4000, using either the modified SoftwareSerial library or NeoSWSerial. The brush is activated and then the serial output has some odd characters (sometimes it says ‘connection failed’) and then the script re-starts.
I have attached the output from the logging script, as well as the outputs from the ‘GetValues.ino’ script.
2019-10-24 at 2:49 PM #13247Sara DamianoModerator
Where is the extra red (5V?) wire in your pictures from September connected? It looks like you have the Yosemetich connected to one 12V power supply (red line at the bottom), the Mayfly powered by second 5V power supply (the black/red twisted pair?) and then the Mayfly also connected to the computer’s USB. But then I can’t figure out the extra wire. You’re sure everyone’s sharing a ground? (I know you already checked, but it’s worth checking again.)
Do you have an RS485 adapter that isn’t attached to a “WingShield” that you could test with? I don’t expect that the wing is the problem, but using the raw adapter would completely eliminate it from suspicion.
If you can use an RS485 adapter that hasn’t been built into a wing, connect it to Serial1. The hardware serial port is *always* better than any software version and using it eliminates any questions the serial libraries. We’ve had some sensors that absolutely refused to talk over anything but hardware serial.
AltSoftSerial should not (generally) conflict with much else. It uses timer capture interrupts rather than pin change interrupts that other software serial libraries use. But using too many libraries that define interrupts of any type can cause some headaches with serial communication because the timing is really important and even well written interrupt routines can throw the timing off enough to cause it to be garbled. In my experience AltSoftSerial *is* the very best alternative to hardware serial. I don’t think I ever succeed in communicating with the Yosemitech’s over the version of SoftwareSerial that’s been modified to play with the rest of ModularSensors – it’s just not accurate enough. I’m really surprised your experience has been the opposite.
Once you can get the GetValues example to run smoothly, try running modular sensors with the build flags for the variable array turned on. (MS_VARIABLEARRAY_DEBUG and MS_VARIABLEARRAY_DEBUG_DEEP) that might give me a better idea of where ModularSensors is crashing.
- You must be logged in to reply to this topic.