egzumer / arduino-lacrosse-tx23-library Goto Github PK
View Code? Open in Web Editor NEWLa Crosse RX23 wind speed and direction sensor library
License: Other
La Crosse RX23 wind speed and direction sensor library
License: Other
Hi,
I just trying to recompile my ESPhome custom sensor for ESP32 based on your lib. It used to work perfectly just before the last PR. Now I got the following error ;
src/tx23_custom_sensor.h:19:51: error: converting overloaded function 'delay' to type 'LaCrosse_TX23::DelayFunc' {aka 'void (*)(unsigned int)'} is ambiguous
I guess it's more related to plateformio/ESP32 but you have to know a lot of users use ESP chip instead or arduino.
Here is the .h file I am using to link with your lib:
#include "esphome.h"
#include "LaCrosse_TX23.h"
#include "esphome/core/version.h"
/*
#if ESPHOME_VERSION_CODE >= VERSION_CODE(2021, 10, 0)
#define DELAY delay
#else
#define DELAY delay
#endif
*/
#define DATAPIN 2
#define OFFSET_TX23 90.0
class TX23CustomSensor : public PollingComponent, public Sensor
{
public:
LaCrosse_TX23 anemometer = LaCrosse_TX23(DATAPIN);
Sensor *speed_sensor = new Sensor();
Sensor *direction_sensor = new Sensor();
TX23CustomSensor() : PollingComponent(2500) {}
void setup() override {
pinMode(DATAPIN, OUTPUT);
digitalWrite(DATAPIN,LOW);
//delay(5000);
// esphome::delay(5000);
// DELAY(5000);
digitalWrite(DATAPIN,HIGH);
pinMode(DATAPIN, INPUT);
}
void update() override {
static const char *dirTable[] = {"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"};
float speed;
// float direction;
uint16_t direction;
bool reading;
reading = anemometer.read(speed, direction);
//if(reading)
//if(anemometer.read(speed, direction))
speed_sensor->publish_state(speed);
//direction_sensor->publish_state(direction*22.5);
direction_sensor->publish_state( float( ( (direction*22.5) + OFFSET_TX23) - 360.0*int(((direction*22.5) + OFFSET_TX23)/360.0) ) );
ESP_LOGD("custom", "reading is: %d", reading);
ESP_LOGD("custom", "speed is: %3.2f", speed);
ESP_LOGD("custom", "direction is: %s", dirTable[direction]);
}
};
Hello,
I cannot compile my TX23 sensor in homeassistant with ESPHome.
I get this error here. Unfortunately I have no idea about c++.
`In file included from src/main.cpp:39:
src/tx23_custom_sensor.h: In member function 'virtual void TX23CustomSensor::update()':
src/tx23_custom_sensor.h:21:35: error: cannot bind non-const lvalue reference of type 'uint16_t&' {aka 'short unsigned int&'} to an rvalue of type 'uint16_t' {aka 'short unsigned int'}
21 | reading = anemometer.read(speed, direction);
| ^~~~~~~~~
In file included from src/tx23_custom_sensor.h:2,
from src/main.cpp:39:
/data/esp-wetter/.piolibdeps/esp-wetter/La Crosse RX23 Library/LaCrosse_TX23.h:41:39: note: initializing argument 2 of 'bool LaCrosse_TX23::read(float&, uint16_t&)'
41 | bool read(float &speed, uint16_t &direction);
| ~~~~~~~~~~^~~~~~~~~
Compiling /data/esp-wetter/.pioenvs/esp-wetter/FrameworkArduino/MD5Builder.cpp.o
Compiling /data/esp-wetter/.pioenvs/esp-wetter/FrameworkArduino/Print.cpp.o
Compiling /data/esp-wetter/.pioenvs/esp-wetter/FrameworkArduino/Schedule.cpp.o
*** [/data/esp-wetter/.pioenvs/esp-wetter/src/main.cpp.o] Error 1
Thank You`
Can you please clarify which BSD license version you are licensing this library under? I'm interested in integrating this into the Meshtastic project however only certain versions of BSD are compatible with GPL v3. Thank you!
Success finally. Got it working. I plugged the RJ11 plug into a surface mount phone jack then wired the color coded wires as is to the Arduino to no avail. I finally opened up the LaCrosse TX23 and checked continuity from the circuit board numbered 1 - 4. Matching the colors on my phone jack they are in reverse order. Yellow - data, Green - VCC, Red N/C, Black - gnd. I used 5VDC on the Arduino as 3.3 didn't work and put a pullup 10k resistor between VCC and DATA. The web site I got this info from is the one in the readme and it says to temp tie DATA to GND to get a reading. It appears that this code takes care of that. I believe it didn't work when I lifted the pullup resistor. Just thought this would help anyone having these same issue. There is a Raspberry PI project that uses a different unit that doesn't send a data stream like this one but contact closures from reed switches and resistors for speed and direction. It includes some math formulas that may help some experiment here. Sorry if this is the wrong place to comment, please copy and paste if needed to proper place. Cool project.
Compiling /data/central_vento/.pioenvs/central_vento/lib29f/La Crosse RX23 Library/LaCrosse_TX23.cpp.o
In file included from src/main.cpp:30:
src/tx23_custom_sensor.h: In member function 'virtual void TX23CustomSensor::update()':
src/tx23_custom_sensor.h:25:35: error: cannot bind non-const lvalue reference of type 'uint16_t&' {aka 'short unsigned int&'} to an rvalue of type 'uint16_t' {aka 'short unsigned int'}
reading = anemometer.read(speed, direction);
^~~~~~~~~
In file included from src/tx23_custom_sensor.h:2,
from src/main.cpp:30:
/data/central_vento/.piolibdeps/central_vento/La Crosse RX23 Library/LaCrosse_TX23.h:41:10: note: initializing argument 2 of 'bool LaCrosse_TX23::read(float&, uint16_t&)'
bool read(float &speed, uint16_t &direction);
^~~~
*** [/data/central_vento/.pioenvs/central_vento/src/main.cpp.o] Error 1
I can´t compile it, i try it using it ESP compiler in homeassistant
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.