Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RAK12035VB Soil Moisture Sensor support #6259

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fifieldt
Copy link
Contributor

@fifieldt fifieldt commented Mar 7, 2025

Introduce the RAK12035 sensor as an environmental telemetry sensor, including necessary calibration checks and default values. Update relevant files to integrate the sensor into the existing telemetry system.

This hardware is not just one module, but a couple.. RAK12023 and RAK12035 is the component stack, the RAK12023 does not seem to matter much and allows for multiple RAK12035 devices to be used.

Co-Authored-By: @Justin-Mann

@fifieldt fifieldt marked this pull request as draft March 7, 2025 12:26
@fifieldt fifieldt force-pushed the RAK12035VB branch 8 times, most recently from 5ad280f to fee9166 Compare March 7, 2025 13:19
@fifieldt fifieldt changed the title [WIP] Add RAK12035VB Soil Moisture Sensor support Add RAK12035VB Soil Moisture Sensor support Mar 7, 2025
@fifieldt fifieldt marked this pull request as ready for review March 7, 2025 13:37
@Justin-Mann
Copy link

working with your code rn... still running into the same issues I was before, but just looking at what you were doing I understand more about the proto code generation and where it is coming from.. also the separate repository makes more sense to me now..

at any rate I'm still running into the same issue when the codebase is actually flashed to the device.

------------------- partial log -------------------------------------------

DEBUG | 19:53:19 8 [Router] Module 'PowerTelemetry' wantsPacket=1
INFO | 19:53:19 8 [Router] Received PowerTelemetry from=0x66148e90, id=0x36268372, portnum=67, payloadlen=28
DEBUG | 19:53:19 8 [Router] Module 'PowerTelemetry' considered
DEBUG | 19:53:19 8 [Router] Module 'routing' wantsPacket=1
INFO | 19:53:19 8 [Router] Received routing from=0x66148e90, id=0x36268372, portnum=67, payloadlen=28
DEBUG | 19:53:19 8 [Router] Routing sniffing (id=0x36268372 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=3 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.25 rxRSSI=-51 hopStart=3)
INFO | 19:53:19 8 [Router] Rebroadcast received floodmsg
DEBUG | 19:53:19 8 [Router] Use AES256 key!
DEBUG | 19:53:19 8 [Router] enqueue for send (id=0x36268372 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x6e encrypted len=50 rxtime=1741377199 rxSNR=6.25 rxRSSI=-51 hopStart=3 r
DEBUG | 19:53:19 8 [Router] txGood=0,txRelay=0,rxGood=2,rxBad=0
DEBUG | 19:53:19 8 [Router] rx_snr found. hop_limit:1 rx_snr:-1.500000
DEBUG | 19:53:19 8 [Router] rx_snr found in packet. Setting tx delay:504
DEBUG | 19:53:19 8 [Router] Delivering rx packet (id=0x36268372 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=3 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.25 rxRSSI=-51 hopStart=3)
DEBUG | 19:53:19 8 [Router] Update DB node 0x66148e90, rx_time=1741377199
INFO | 19:53:19 8 [Router] Heard new node on ch. 0, send NodeInfo and ask for response
DEBUG | 19:53:19 8 [Router] cancelSending id=0xe7dd6c41, removed=1
DEBUG | 19:53:19 8 [Router] Skip send NodeInfo since we sent it <5min ago
DEBUG | 19:53:19 8 [Router] Forwarding to phone (id=0x36268372 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=3 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.25 rxRSSI=-51 hopStart=3)
DEBUG | 19:53:19 8 [Router] Module 'routing' considered
WARN | 19:53:19 8 [RadioIf] Can not send yet, busyRx
DEBUG | 19:53:19 9 [RadioIf] rx_snr found. hop_limit:1 rx_snr:-1.500000
DEBUG | 19:53:19 9 [RadioIf] rx_snr found in packet. Setting tx delay:1540
DEBUG | 19:53:19 9 [RadioIf] Lora RX (id=0xae5f4f71 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x6e encrypted len=39 rxSNR=6.75 rxRSSI=-46 hopStart=3)
DEBUG | 19:53:19 9 [RadioIf] Packet RX: 526ms
DEBUG | 19:53:19 9 [RadioIf] rx_snr found. hop_limit:1 rx_snr:-1.500000
DEBUG | 19:53:19 9 [RadioIf] rx_snr found in packet. Setting tx delay:2212
DEBUG | 19:53:19 9 [Router] Add packet record fr=0x66148e90, id=0xae5f4f71
DEBUG | 19:53:19 9 [Router] Use channel 0 (hash 0x6e)
DEBUG | 19:53:19 9 [Router] Use AES256 key!
DEBUG | 19:53:19 9 [Router] decoded message (id=0xae5f4f71 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.75 rxRSSI=-46 hopStart=3)
DEBUG | 19:53:19 9 [Router] handleReceived(REMOTE) (id=0xae5f4f71 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.75 rxRSSI=-46 hopStart=3)
DEBUG | 19:53:19 9 [Router] Module 'DeviceTelemetry' wantsPacket=1
INFO | 19:53:19 9 [Router] Received DeviceTelemetry from=0x66148e90, id=0xae5f4f71, portnum=67, payloadlen=17
DEBUG | 19:53:19 9 [Router] Module 'DeviceTelemetry' considered
DEBUG | 19:53:19 9 [Router] Module 'EnvironmentTelemetry' wantsPacket=1
INFO | 19:53:19 9 [Router] Received EnvironmentTelemetry from=0x66148e90, id=0xae5f4f71, portnum=67, payloadlen=17
INFO | 19:53:19 9 [Router] (Received from ): barometric_pressure=0.000000, current=0.000000, gas_resistance=0.000000, relative_humidity=1.000000, temperature=23.000000
INFO | 19:53:19 9 [Router] (Received from ): voltage=0.000000, IAQ=0, distance=0.000000, lux=0.000000, white_lux=0.000000
INFO | 19:53:19 9 [Router] (Received from ): wind speed=0.000000m/s, direction=0 degrees, weight=0.000000kg
INFO | 19:53:19 9 [Router] (Received from ): radiation=0.000000##R/h
DEBUG | 19:53:19 9 [Router] Module 'EnvironmentTelemetry' considered
DEBUG | 19:53:19 9 [Router] Module 'PowerTelemetry' wantsPacket=1
INFO | 19:53:19 9 [Router] Received PowerTelemetry from=0x66148e90, id=0xae5f4f71, portnum=67, payloadlen=17
DEBUG | 19:53:19 9 [Router] Module 'PowerTelemetry' considered
DEBUG | 19:53:19 9 [Router] Module 'routing' wantsPacket=1
INFO | 19:53:19 9 [Router] Received routing from=0x66148e90, id=0xae5f4f71, portnum=67, payloadlen=17
DEBUG | 19:53:19 9 [Router] Routing sniffing (id=0xae5f4f71 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.75 rxRSSI=-46 hopStart=3)
INFO | 19:53:19 9 [Router] Rebroadcast received floodmsg
DEBUG | 19:53:19 9 [Router] Use AES256 key!
DEBUG | 19:53:19 9 [Router] enqueue for send (id=0xae5f4f71 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=1 Ch=0x6e encrypted len=39 rxtime=1741377199 rxSNR=6.75 rxRSSI=-46 hopStart=3 r
DEBUG | 19:53:19 9 [Router] txGood=0,txRelay=0,rxGood=3,rxBad=0
DEBUG | 19:53:19 9 [Router] rx_snr found. hop_limit:1 rx_snr:-1.500000
DEBUG | 19:53:19 9 [Router] rx_snr found in packet. Setting tx delay:2044
DEBUG | 19:53:19 9 [Router] Delivering rx packet (id=0xae5f4f71 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.75 rxRSSI=-46 hopStart=3)
DEBUG | 19:53:19 9 [Router] Update DB node 0x66148e90, rx_time=1741377199
INFO | 19:53:19 9 [Router] Heard new node on ch. 0, send NodeInfo and ask for response
DEBUG | 19:53:19 9 [Router] cancelSending id=0xe7dd6c41, removed=0
DEBUG | 19:53:19 9 [Router] Skip send NodeInfo since we sent it <5min ago
DEBUG | 19:53:19 9 [Router] Forwarding to phone (id=0xae5f4f71 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x0 Portnum=67 rxtime=1741377199 rxSNR=6.75 rxRSSI=-46 hopStart=3)
DEBUG | 19:53:19 9 [Router] Module 'routing' considered
DEBUG | 19:53:20 9 [RadioIf] Lora RX (id=0x36268372 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x6e encrypted len=50 rxSNR=7 rxRSSI=-46 hopStart=3)
DEBUG | 19:53:20 9 [RadioIf] Packet RX: 608ms
DEBUG | 19:53:20 9 [RadioIf] rx_snr found. hop_limit:1 rx_snr:-1.500000
DEBUG | 19:53:20 9 [RadioIf] rx_snr found in packet. Setting tx delay:1064
DEBUG | 19:53:20 9 [Router] Found existing packet record for fr=0x66148e90,to=0xffffffff,id=0x36268372
DEBUG | 19:53:20 9 [Router] Add packet record fr=0x66148e90, id=0x36268372
DEBUG | 19:53:20 9 [Router] Ignore dupe incoming msg (id=0x36268372 fr=0x66148e90 to=0xffffffff, WantAck=0, HopLim=2 Ch=0x6e encrypted len=50 rxSNR=7 rxRSSI=-46 hopStart=3)
DEBUG | 19:53:20 9 [Router] cancelSending id=0x36268372, removed=1
DEBUG | 19:53:20 9 [Router] Incoming msg was filtered from 0x66148e90
ERROR | 19:53:21 10 [RadioIf] Ignore received packet due to error=-7
DEBUG | 19:53:21 10 [RadioIf] Packet RX (noise?) : 526ms
DEBUG | 19:53:21 10 [RadioIf] rx_snr found. hop_limit:1 rx_snr:-1.500000
DEBUG | 19:53:21 10 [RadioIf] rx_snr found in packet. Setting tx delay:2016
INFO | 19:53:21 11 [EnvironmentTelemetry] Environment Telemetry: init
INFO | 19:53:21 11 [EnvironmentTelemet <-------------- this is point of failure. no idea why otherwise I would fix the thing properly..

So ... things I noticed when I flashed the code with your changes

  • gps worked again so obviously new codebase
  • RAK12035 was being identified and established again... this was a new behavior to me.. basically it was working again. BUT...
    it was only working again because the config had been reset... I did not know this yet so I continued...
  • As stated config was wiped so those were my next steps...
  • 1> set region, reboot
  • 2> set device name and static bluetooth pin, reboot
  • 3> set device to 'SENSOR' type, reboot
  • 3> set telemetry for every 120 seconds and turned on everything but the air quality metric, reboot
  • 4> failure state seen above.. behavior is constant reboot cycle.. this began happening when I enabled environmental telemetry.

Any thoughts? this is the same behavior I was running into before.. but I never understood it was not an issue UNTIL environmental telemetry was enabled... I just kept seeing the behavior as all my raks have telemetry enabled in the configs.


@Justin-Mann
Copy link

gonna take a break and look at EnvironmentTelemetry in a bit... see if I can sort out what it going wrong.

@fifieldt
Copy link
Contributor Author

fifieldt commented Mar 8, 2025

Wow, thanks for the lightening-fast response @Justin-Mann ! I'm glad the code was helpful.

Good to know the RAK12035 was identified in the I2C scan!

I haven't got to the actual sensor code you wrote. Things I noticed so far:

  • There's a bugfix release of the RAK12035 library in github (1.0.4) that is not yet in platformio (1.0.3)
  • The RAK12035 library does a bit more toggling of GPIOs than I would expect it to do. Appears to make some assumptions about the RAK environment that may not hold in ours. eg toggling the 3.3V rail. Assuming your sensor code is flawless, my guess is that the cause of the restart is probably this behaviour in the RAK12035 library.

@fifieldt
Copy link
Contributor Author

fifieldt commented Mar 8, 2025

Created an issue to try and get PlatformIO updated: RAKWireless/RAK12035_SoilMoisture#1

@Justin-Mann
Copy link

Justin-Mann commented Mar 8, 2025 via email

@fifieldt
Copy link
Contributor Author

fifieldt commented Mar 8, 2025

@Justin-Mann , the protobufs were merged :)

@Justin-Mann
Copy link

I do the testing thing again soon as i finish my noodles man.

@Justin-Mann
Copy link

Justin-Mann commented Mar 8, 2025

@fifieldt Really do appreciate your work here.. helps me understand the repo topology and went a long way yowards me understanding where the codegen was actually happening and what defines it. Need to read a lil more.. but ill keep trying to help after this go around. See if i can continue to add support for other rak wisblock style sensors.

@fifieldt fifieldt force-pushed the RAK12035VB branch 2 times, most recently from 37e6769 to 0c41f90 Compare March 11, 2025 00:40
@fifieldt
Copy link
Contributor Author

@Justin-Mann , did you get any further?

@Justin-Mann
Copy link

Justin-Mann commented Mar 21, 2025 via email

@fifieldt
Copy link
Contributor Author

fifieldt commented Mar 22, 2025

So, looking at your log above, it seems that the execution dies within:

int32_t RAK12035Sensor::runOnce()

Probably at one of these lines?

sensor.set_sensor_addr(RAK120351_ADDR);

    sensor.begin(nodeTelemetrySensorsMap[sensorType].first);

Introduce the RAK12035 sensor as an environmental telemetry sensor,
including necessary calibration checks and default values. Update
relevant files to integrate the sensor into the existing telemetry system.

This hardware is not just one module, but a couple.. RAK12023 and
RAK12035 is the component stack, the RAK12023 does not seem to matter
much and allows for multiple RAK12035 devices to be used.

Co-Authored-By: @Justin-Mann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants