Forum Replies Created
-
AuthorPosts
-
I found the issue with the help of a friend. It doesnt work with some board versions. Got it to work with esp8266 version 2.5. The only one ive tested that works but my friend told me that atleast 2 more works. Will update witch ones working!
Do you have any idea what could be the issue? Thanks
I just get 1byte but sometimes i get 2, the read too 0x03. So i dont really know whats wrong now lol.
Thank you very much! I got it to connect but reciving 1 bytes because of (CRC of response is not correct!)
Probably just me doing something wrong with delays!
It would help me to help you if you would be more verbose and detailed in your responses.
Yeah sorry about that will try to answer better. Im really appreciative about your help!
You didn’t answer whether you, yourself, had every succeeded in communicating with the sensor in any other way. I assume that means no.
Yes you are right. Ive never done a sucssesfull communication with the sensor. I just get no response.
You’re using example code that includes code for a small screen? Do you have one? If not, it might be easier to use the “GetValues” example instead of the “DisplayValues” one.
Yes i got a small screen to show me the values.
Up to now you had been telling me you were using a NodeMCU, now you’re mentioning an Arduino Mini. Your picture looks like you’ve cobbled the two together. Is the NodeMCU the main brain? What does the Arduino Mini do?
The arduino mini is just for mfrc and giving voltage to the sensor. Also ground.
An Arduino mini can be either 5V or 3.3V. It should be labeled on the back of the Mini – check. The NodeMCU is always 3.3V. The Yosemitech requires a minimim of 5V power. Most level shifters are either labeled or have an in and out voltage based on what is connected on each side. Trace your wires so you know what voltages you have on both sides of the shifters. Please write it down so you and the next person the project gets dumped on will know.
The adapter you linked, which I’m guessing is the blue board on the top right of your picture, does NOT have automatic flow control. You must connect the DE and RE from your adapter to each other and the two of them together to some pin on your main control board. It looks like you have at least one of them connected to D0 (or D1?), but I can’t tell if you’ve tied them together or left one floating. If one is floating, rewire so they are tied together. You also need to change line 35 of your code to use the correct pin, as it says in the instructions in your code. The code you have now is not correct and would NOT work for your current setup.
De and re is solder’d togheter and connected to D0. But if i try to use D0 in the dere in the code i just get error (28) and the screen wont load.
Whether or not the setup you have worked for someone else before you, it’s apparently yours now, so trace wires and make notes until you understand all of the connections.
I think i understand all the connections now. The picture i attached is one of the sensors that i took apart so see were everything sits.
-
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277/*****************************************************************************GetValues.inoThis prints basic meta-data about a sensor to the first serial port and thenbegins taking measurements from the sensor.The sensor model and address can easily be modified to use this sketch with anyYosemitech modbus sensor.*****************************************************************************/// ---------------------------------------------------------------------------// Include the base required libraries// ---------------------------------------------------------------------------#include <Arduino.h>#include <SoftwareSerial.h>#include <Wire.h> // For the I2C for the OLED display#include <AMAdafruit_GFX.h> // For the OLED display#include <SDL_Arduino_SSD1306.h> // For the OLED display#include <YosemitechModbus.h>// ---------------------------------------------------------------------------// Set up the sensor specific information// ie, pin locations, addresses, calibrations and related settings// ---------------------------------------------------------------------------// Define the sensor typeyosemitechModel model = Y502; // The sensor model number// Define the sensor's modbus addressbyte modbusAddress = 0x01; // The sensor's modbus address, or SlaveID// Yosemitech ships sensors with a default ID of 0x01.// Define pin number variablesconst int PwrPin = D6; // The pin sending power to the sensor *AND* RS485 adapterconst int DEREPin = -1; // The pin controlling Recieve Enable and Driver Enable// on the RS485 adapter, if applicable (else, -1)// Setting HIGH enables the driver (arduino) to send text// Setting LOW enables the receiver (sensor) to send textconst int SSRxPin = D6 ; // Recieve pin for software serial (Rx on RS485 adapter)const int SSTxPin = D5; // Send pin for software serial (Tx on RS485 adapter)// Construct software serial object for ModbusSoftwareSerial modbusSerial(SSRxPin, SSTxPin);// Construct the Yosemitech modbus instanceyosemitech sensor;bool success;// Set up the OLED displaySDL_Arduino_SSD1306 display(-1); // using I2C and not bothering with a reset pin// ---------------------------------------------------------------------------// Main setup function// ---------------------------------------------------------------------------void setup(){pinMode(PwrPin, OUTPUT);digitalWrite(PwrPin, HIGH);if (DEREPin > 0) pinMode(DEREPin, OUTPUT);Serial.begin(57600); // Main serial port for debugging via USB Serial MonitormodbusSerial.begin(9600); // The modbus serial stream - Baud rate MUST be 9600.delay(2000);// Start up the sensorsensor.begin(model, modbusAddress, &modbusSerial, DEREPin);// Start the OLEDdisplay.begin(SSD1306_SWITCHCAPVCC, 0x3C, false);display.clearDisplay();display.setTextSize(1);display.setTextColor(WHITE);display.setCursor(0,0);// Turn on debuggingsensor.setDebugStream(&Serial);// Start up notedisplay.println("Yosemitech ");display.println(sensor.getModel());display.display();display.println(sensor.getParameter());display.println("Sensor");display.display();delay(3000);// Get the sensor's hardware and software versiondisplay.clearDisplay();display.setCursor(0,0);float hardwareV, softwareV;sensor.getVersion(hardwareV, softwareV);display.println("Hardware Version:");display.println(hardwareV);display.println("Software Version:");display.println(softwareV);// Get the sensor serial numberString SN = sensor.getSerialNumber();display.println("Serial Number:");display.print(SN);display.display();delay(3000);// Get the sensor calibration status (pH only)if (model == Y532){display.clearDisplay();display.setCursor(0,0);byte status = sensor.pHCalibrationStatus();display.println("Calibration Status:");display.print("0x0");display.println(status, HEX);display.display();delay(3000);}// Get the sensor's current calibration valuesif (model != Y532){display.clearDisplay();display.setCursor(0,0);float Kval = 0;float Bval = 0;sensor.getCalibration(Kval, Bval);display.println("Current Calibration Equation:");display.print(Kval);display.print("*raw + ");display.println(Bval);display.display();delay(3000);}if (model == Y511 || model == Y513 || model == Y514){display.clearDisplay();display.setCursor(0,0);// Check the wiper timinguint16_t interval = sensor.getBrushInterval();display.println("Sensor auto-cleaning interval: ");display.print(interval);display.println(" minutes");display.display();delay(3000);}// Tell the sensor to start taking measurementsdisplay.clearDisplay();display.setCursor(0,0);display.println("Starting sensor measurements");display.println();success = sensor.startMeasurement();if (success) display.println(" Measurements started.");else display.println(" Failed to start measuring!");display.display();// The modbus manuals recommend the following warm-up times between starting// measurements and requesting values :// 2 s for whipered chlorophyll// 20 s for turbidity// 10 s for conductivity// On wipered (self-cleaning) models, the brush immediately activates after// getting power and takes approximately 10-11 seconds to finish. No// readings should be taken during this time.// pH returns values after ~4.5 seconds// Conductivity returns values after about 2.4 seconds, but is not stable// until ~10 seconds.// DO does not return values until ~8 seconds// Turbidity takes ~22 seconds to get stable values.display.clearDisplay();display.setCursor(0,0);display.println("Allowing sensor to stabilize..");display.display();for (int i = 10; i > 0; i--){display.print(i);display.display();delay (250);display.print(".");display.display();delay (250);display.print(".");display.display();delay (250);display.print(".");display.display();delay (250);}display.display();if (model == Y511 || model == Y513 || model == Y514){display.clearDisplay();display.setCursor(0,0);// We'll run the brush once in the middle of thisdisplay.println("Activating brush.");display.display();success = sensor.activateBrush();if (success) display.println(" Brush activated.");else display.println(" Failed to activate brush!");display.display();}if (model == Y511 || model == Y513 || model == Y514 || model == Y510){display.clearDisplay();display.setCursor(0,0);display.println("Continuing to stabilize..");display.display();for (int i = 12; i > 0; i--){display.print(i);display.display();delay (250);display.print(".");display.display();delay (250);display.print(".");display.display();delay (250);display.print(".");display.display();delay (250);}display.println("\n");display.display();}}// ---------------------------------------------------------------------------// Main loop function// ---------------------------------------------------------------------------void loop(){display.clearDisplay();display.setCursor(0,0);display.setTextSize(2);// send the command to get the valuesfloat parmValue, tempValue, thirdValue = -9999;sensor.getValues(parmValue, tempValue, thirdValue);display.println("Temp (C):");display.print(" ");display.println(tempValue);display.print(sensor.getParameter());display.print("(");display.print(sensor.getUnits());display.print("): ");display.print(" ");display.println(parmValue);if (model == Y532 || model == Y504){display.println("thirdValue:");display.print(" ");display.println(thirdValue);}display.display();// Delay between readings// Modbus manuals recommend the following re-measure times:// 2 s for chlorophyll// 2 s for turbidity// 3 s for conductivity// 1 s for DO// The turbidity and DO sensors appear return new readings about every 1.6 seconds.// The pH sensor returns new readings about every 1.8 seconds.// The conductivity sensor only returns new readings about every 2.7 seconds.// The teperature sensors can take readings much more quickly. The same results// can be read many times from the registers between the new sensor readings.delay(1700);}
Are you using breadboards or have you made a custom circuit of some kind? Post a picture.
Yes i put it in.
- By what is the Yosemitch sensor powered and at what voltage?
Connected in a levelshifter from a arduino mini pro.
- Exactly what RS485 to TTL adapter do you have connected between the A and B (green and white) of your Y500B and your NodeMCU (brand, chipset, etc)
- What powers the RS485 adapter and at what voltage?
- Does the adapter require the use of a pin to change the direction of communication or does it have automatic flow control?
https://www.aliexpress.com/item/32647766464.html I dont think it got flowcontrol. Its powered by the vcc(3.3v) from the nodemcu.
- <li style=”list-style-type: none;”>
<li style=”list-style-type: none;”>- Are there any LED’s on your adapter?
- If so, do you see the power, Tx, and Rx LED’s light up appropriately?
Yes it glows bright red.
- What level shifters are you using (brand, etc)?
- Are your level shifters between the Tx and Rx of your adapter and the pins of your NodeMCU?
- If not, where are they in the chain?
- What voltages are you shifting to and from?
- I have not succeeded in using external level shifters on a breadboard with an RS485 adapter so I am quite skeptical of a set-up that requires them.
Its chinese and honestly i dont know as i said before i just continued someones old project and couldnt find the shifter on the internet.
- Are you sure you have Tx and Rx coming out of the adapter connected appropriately the pins you are assigning as Rx and Tx in SoftwareSerial?
- Have you tried reversing the Tx and Rx?
Everything correctly wired because it worked before i used it.
Attachments:
Got information now that it is the y-500b does that even work with this library?
Yeah i use the arduino ide on my nodemcu. Im testing the sensor with the yosemite displayvalues library.
The thing i meant with own code was that the one working on this project before didnt give me anything like source code or explenation how he did work everything out.
Its searching all the slaveids and cant find the sensor. I use pin D6 for rx and d5 for tx but it just says it cant find the sensor.
The sensor im using is either a y-500b/y-1002 or y-2002. Im not quite sure. Dont really know what to do at this point because i know how modbus works everything is wired correctly and it uses a levelconverter.
1234567891011121314yosemitechModel model = Y502; // The sensor model number// Define the sensor's modbus addressbyte modbusAddress = 0x01; // The sensor's modbus address, or SlaveID// Yosemitech ships sensors with a default ID of 0x01.// Define pin number variablesconst int PwrPin = D0; // The pin sending power to the sensor *AND* RS485 adapterconst int DEREPin = -1; // The pin controlling Recieve Enable and Driver Enable// on the RS485 adapter, if applicable (else, -1)// Setting HIGH enables the driver (arduino) to send text// Setting LOW enables the receiver (sensor) to send textconst int SSRxPin = D6; // Recieve pin for software serial (Rx on RS485 adapter)const int SSTxPin = D5; // Send pin for software serial (Tx on RS485 adapter)I use softwareserial and ive heard that it work but dont really know. But i am continuing some code for a module. As i couldnt download his code i made it from scratch. Acording to how i connected it it seems like its connected to the nodemcu but actually i dont really know sadly
Yeah im sorry was really tired but its working now. Do you or someone know if there is a library for the nodemcu?
-
-
AuthorPosts