Home › Forums › Mayfly Data Logger › How to handle the variables with sensors
Tagged: library's, mayfly, PlatformIO, variables, yosemitech
- This topic has 0 replies, 1 voice, and was last updated 2021-07-19 at 4:49 PM by Liz.
-
AuthorPosts
-
-
2021-07-19 at 4:49 PM #15711
Hello, My name is Liz and I am working on integrating two yosemitech sensors (Y510/ y504) into the mayfly. Right now I am trying to get just one working. I am starting with the Y510 sensor and copied the text from the “menu la carte” and see that they have their own variables, I am unsure where these listed variables go in my program.
for my board set-up I have the sensor running through through a terminal screw grove connected to the 5V on the mayfly and through the A/B on the Rs485 then the Rs485 is connected to the board.
Methods:
-
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869#include <AltSoftSerial.h>AltSoftSerial altSoftSerial;#if defined MS_BUILD_SENSOR_Y510// ==========================================================================// Yosemitech Y510 Turbidity Sensor// ==========================================================================/** Start [y510] *///#include <sensors/YosemitechY510.h>#include <ModSensorDebugger.h>AltSoftSerial &modbusSerial = altSoftSerial; // For software serial if needed// NeoSWSerial &modbusSerial = neoSSerial1; // For software serial if needed//#endif// NOTE: Extra hardware and software serial ports are created in the "Settings// for Additional Serial Ports" sectionbyte y510ModbusAddress = 0x0B; // The modbus address of the Y510const int8_t y510AdapterPower = D10; // RS485 adapter power pin// (-1 if unconnected)const int8_t y510SensorPower = D6; // Sensor power pinconst int8_t y510EnablePin = -1; // Adapter RE/DE pin (-1 if not applicable)const uint8_t y510NumberReadings = 5;// The manufacturer recommends averaging 10 readings, but we take 5 to minimize// power consumption// Create a Y510-B Turbidity sensor objectYosemitechY510 y510(y510ModbusAddress, y510AdapterPower, modbusSerial, y510SensorPower, y510EnablePin, y510NumberReadings);___// Create turbidity and temperature variable pointers for the Y510 ** Do these varibles go in the varible list or are they listed like this???Variable* y510Turb =new YosemitechY510_Turbidity(&y510, "12345678-abcd-1234-ef00-1234567890ab");Variable* y510Temp =new YosemitechY510_Temp(&y510, "12345678-abcd-1234-ef00-1234567890ab");/** End [y510] */#endif__^^^// ==========================================================================// Creating the Variable Array[s] and Filling with Variable Objects// ==========================================================================/** Start [variable_arrays] */Variable* variableList[] = {new ProcessorStats_SampleNumber(&mcuBoard),new ProcessorStats_FreeRam(&mcuBoard),new ProcessorStats_Battery(&mcuBoard, "vbat"),new MaximDS3231_Temp(&ds3231, "airtemp"),// new YosemitechY510_Turbidity(&y510, "12345678-abcd-1234-ef00-1234567890ab"),// new YosemitechY510_Temp(&y510, "12345678-abcd-1234-ef00-1234567890ab"),// Additional sensor variables can be added here, by copying the syntax// for creating the variable pointer (FORM1) from the// <code>menu_a_la_carte.ino</code> example// The example code snippets in the wiki are primarily FORM2.};// Count up the number of pointers in the arrayint variableCount = sizeof(variableList) / sizeof(variableList[0]);// Create the VariableArray objectVariableArray varArray;/** End [variable_arrays] */
this method let me build and compile however in the serial monitor it notes nothing of the sensors, does not seem to recognize them. I don’t get an error but it only spits out data for the on board sensors.
2.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667#include <AltSoftSerial.h>AltSoftSerial altSoftSerial;#if defined MS_BUILD_SENSOR_Y510// ==========================================================================// Yosemitech Y510 Turbidity Sensor// ==========================================================================/** Start [y510] *///#include <sensors/YosemitechY510.h>#include <ModSensorDebugger.h>AltSoftSerial &modbusSerial = altSoftSerial; // For software serial if needed// NeoSWSerial &modbusSerial = neoSSerial1; // For software serial if needed//#endif// NOTE: Extra hardware and software serial ports are created in the "Settings// for Additional Serial Ports" sectionbyte y510ModbusAddress = 0x0B; // The modbus address of the Y510const int8_t y510AdapterPower = D10; // RS485 adapter power pin// (-1 if unconnected)const int8_t y510SensorPower = D6; // Sensor power pinconst int8_t y510EnablePin = -1; // Adapter RE/DE pin (-1 if not applicable)const uint8_t y510NumberReadings = 5;// The manufacturer recommends averaging 10 readings, but we take 5 to minimize// power consumption// Create a Y510-B Turbidity sensor objectYosemitechY510 y510(y510ModbusAddress, y510AdapterPower, modbusSerial, y510SensorPower, y510EnablePin, y510NumberReadings);// // Create turbidity and temperature variable pointers for the Y510 ** Do these varibles go in the varible list or are they listed like this???// Variable* y510Turb =// new YosemitechY510_Turbidity(&y510, "12345678-abcd-1234-ef00-1234567890ab");// Variable* y510Temp =// new YosemitechY510_Temp(&y510, "12345678-abcd-1234-ef00-1234567890ab");// /** End [y510] */#endif// ==========================================================================// Creating the Variable Array[s] and Filling with Variable Objects// ==========================================================================/** Start [variable_arrays] */Variable* variableList[] = {new ProcessorStats_SampleNumber(&mcuBoard),new ProcessorStats_FreeRam(&mcuBoard),new ProcessorStats_Battery(&mcuBoard, "vbat"),new MaximDS3231_Temp(&ds3231, "airtemp"),new YosemitechY510_Turbidity(&y510, "12345678-abcd-1234-ef00-1234567890ab"),new YosemitechY510_Temp(&y510, "12345678-abcd-1234-ef00-1234567890ab"),___^^^ adding them to variable list// Additional sensor variables can be added here, by copying the syntax// for creating the variable pointer (FORM1) from the// <code>menu_a_la_carte.ino</code> example// The example code snippets in the wiki are primarily FORM2.};// Count up the number of pointers in the arrayint variableCount = sizeof(variableList) / sizeof(variableList[0]);// Create the VariableArray objectVariableArray varArray;/** End [variable_arrays] */with this method, it makes more sense to me to do it this way however I get an syntax error which I do not understand what it wants me to fix.
error in serial monitor
123456789Building in release modeC:/Users/Lizzy/Documents/Arduino/LearnEnviroDIYcode-master/Deployments/Test1/simple_logging.ino:163:9: error: expected type-specifier before 'YosemitechY510_Turbidity'new YosemitechY510_Turbidity(&y510, "12345678-abcd-1234-ef00-1234567890ab"),^~~~~~~~~~~~~~~~~~~~~~~~C:/Users/Lizzy/Documents/Arduino/LearnEnviroDIYcode-master/Deployments/Test1/simple_logging.ino:163:9: error: expected '}' before 'YosemitechY510_Turbidity'C:/Users/Lizzy/Documents/Arduino/LearnEnviroDIYcode-master/Deployments/Test1/simple_logging.ino:172:1: error: expected declaration before '}' token};^*** [.pio\build\mayfly\src\simple_logging.ino.cpp.o] Error 1If anyone could guide me towards which is the right method if either and if the second method is correct how to fix the error.
I had gotten it to recognize the sensors at one point where in the serial monitor it would say, this system has 6 sensor of which 0 are calculated and list the sensors but not take any significate data however through trying to fix that one issue I can’t get back to the program even recognizing the sensors.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.