i have the sensor connected to the sdi12 to usb adapter and the adapter connected to the esp32 via uart.
and yes i would like the esp32 to send the read and retrieve data comands and to relay it back to homeassistant.
do you mean i should replace the original untemplated SDI-12 string code in your original config.yaml with the yaml code from the custom UART device link?.
like i said im a complete novice at this so please bare with me.
The first thing to do after you connected the ESP to the SDI-12 modbus (Liudr board) is to get a sensor reading on the ESP. I’m not very familiar with ESPs connected via UART, but you might be lucky on other forums for setting up such a connection. Googled a bit, you are not the first one thinking in this direction: ESP32 as Converter between modbus and SDI - Using Arduino / Project Guidance - Arduino Forum
Out of curiosity, what is your usecase? What is the added value in setting up the Raspberry Pi separated from the SDI-12 modbus?
hi Rik, i have the esp32 connected to the serial conections sdi-12 lidur board, i am pretty sure the connections are correct.
why do you think i might need aditional hardware?, i was under the impression that the liudr board would interface with the acclima sensor and then connect with the esp32 via tx rx pins then relay the readings wirelessly to my rp4.
its very similar to your setup, you have your teros sensors connected to the sdi-12 liudr board, i have my acclima sensor connected the same.
your data is traveling via the usb serial port on the liudr board direct to your rp4, my data is traveling via the serial connections on the liudr board into the uart connections on the esp32 then transmitted wirelessly to my rp4.
i thought that our projects were similar enough that your original code could be adapted to account for the differences in how we send and recieve the data, yours serial usb, mine uart, without to much work.
the only reason the rp4 is seperate from the sdi-12 adapter is because the rp4 is in use in an existing set up and the sensor will be a few rooms away.
i thought it would be straight forward using the esp32 to transmit the data to homeassistant wirelessly.
it dosent quite work… my buttons on the dashboard are not correct (not the same as the example in the link) so i cant input any comands for the sensor so i dont get any readings, but im trying and i feel i have made some progress.
honestly im green as grass when it comes to this stuff so any help much appreciated.
I don’t think you need additional hardware, you are already putting in an ‘in between ESP’
I think you are on the right track templating the ESP via ESPhome following that thread. Although these lambda templates are hard to troubleshoot, especially since they are C++ and do not 1 to 1 match with Home Assistant templates. I’m afraid I’m also not much of a help on those templates.
Setting up some working switches an text inputs in ESPHome to see whether it connects to Home Assistant shouldn’t be to difficult though, maybe try adding a simple switch first to see if that works, then you are down to troubleshooting these lambda templates to get a reading.
Also I don’t know if you already found the ESP log, inside Home Assistant you can open the ESPHome tab and click your ESP there. From that screen you can open a live log, it might help reading this log while trying to input text.
-edit: Adding a few lines in your ESPHome config for debugging UART communication might also be a good idea UART Bus — ESPHome
Keep us posted on your findings, I’m interested on the outcome
Connection is good, ESP reacts to HA switch, so I guess you are close. Two things
Did you check that your SDI-12 sensor has adress ‘1’ and is actually working?
I think you need to feed the modbus with ASCII? Try data: '49 77 33' for your read sensor
Edit: You might need to play around with the ASCII formatting: Convert a String to ASCII Code - Online String Tools
I haven’t looked into the serial connection of the Liudr board for compatibility (maybe Liudr has some documentation about this on his website?)
yes i have confirmed the sensor is working and i have changed the sensor address to 1. i used an android app “usb serial terminal” connected via the usb.
i tried the ‘49 77 33’, no luck, logs look the same as the ones i posted above.
liudr sell a version of his board without the usb port and chip (so only has the serial port for coms) called the SDI-12 TTL adapter, so i presume compatibility shouldnt be an issue?.
I guess that TTL serial is also on your SDI-12 board? Maybe ask Liudr what protocol is used for TTL coms, he seems responsive to these kind of questions.
ok quick update, i have been in contact with dr liu about using the serial connectror on his board as opposed to the usb and it turns out there are a couple of extra steps to hopefully get this to work.
first there is a couple of pads that need bridgeing on the pcb labled “FT_RST” to disable the usb serial port so the uart serial port can be used instead.
next the serial connection on the liudr board has both 3.3v tx and 5v tx pins, the esp32 wants 3.3v but on the usb version of the liudr board the 3.3v tx is not fully populated with the required components it is missing 2 10k resistors, so you need to add 2 resistors or use a seperate logic level converter and use the 5v tx on the uart serial port.
i have went with the level convertor and i am now pretty confident that everything is wired correctly, i have not had chance to try it out yet but fingers crossed this should work.
starting to get somewhere, using the code below i have managed to get two basic switches on the dashboard sending the commands 1M! and 1D0! and finally have a response from the sensor!!!.
does everthing look correct?.
any pointers on how i go about seperating out the different data from the sensor and how do i save the data to a csv file to log?.
Looking good @sar1! Can you find the ‘tdr_wc_ec_uart’ sensor in home assistant? And does it’s value update with lines like ‘1+0.0+23.0+1.1+0+0’? Than you can point my code towards that sensor. If you go into developer tools in home assistant, and check your entities you should find the full name of your sensor. Probably something like ‘sensor.tdr_wc_ec_uart’
If you look back at my first post, at the configuration.yaml; you can edit the template and use the rest of my code.
So change sensor.serial_sensor to your SDI-12 output sensor here:
This particular code looks for a ‘1’ inside the SDI-12 raw output from your ESP, then creates another sensor named ‘Sensor Adress 1’ that will simply display the sensor address, since this is the first thing to be extracted from the raw SDI-12 string. Later I repeat these steps with volumetric water, temperature and EC, I basically extract the value between the + signs in the raw string, and convert these to new home assistant sensors seperately. So you do have to change the same sensor for volumetric water content, temperature or which ever value your sensor puts in the SDI-12 string.
Later I combine all the newly created sensors in a home assistant automation, and group them in a message to log them. You can copy the automation and see if it works for you.
hey rik, i had put this on the back burner for a month or two but now i have found some time i am back on it.
i havent done anymore since your last post, only installing all the components in box ready for use.
i did add a 2 channel relay board to control 2 24v irrigation valves and have managed to add the code to get 2 bottons on the home assistant dashboard and they control the valves fine.
once i had everything wired up in the new box i checked the logs from the esp32 and its now no longer displaying the readings from the acclima sensor correctly anymore?, the data is still returned sometimes but now comes in with more odd data?.
i have included some pics of the new logs so you can compare to the old ones, i havent changed any code since our last conversation when it was working correctly?, only adding a little bit of code for gpio pins for the valve relays?.
also in your last post you asked if the ‘tdr_wc_ec_uart’ sensor shows up in home assistant/developertools/entities, the answer is no it does not show up?.
any light you could shed on this would be very much appriciated.
I have an Sdi12 Sk16 from Dr Lui And is this the code i would put in to make my teros 12 get readings? I am really new to all of this and just need some help.
i have the device hooked into the sdi12 usb adapter and thats plugged into my rpi400. I just need help converting it to ec, moisture %, and temp and then that data somehow being read in HA.