I am desperately trying to get the TCP/UPD Binding to work.
What i want to achieve:
Receive data (in a later use-case maybe send data) from (to) my arduino node mcu wifi board.
I built a small battery powered room sensor for temperature pressure and humidity and now i want to send the values to OH 2.
I created an item as described in the readme to receive the temp for instance:
The first part (127.0.0.1) is the IP Adress of the server created from OH? Is that right? The second part the port?
I also configured the port (80) in the tcp.cfg-file. That was the only thing i wrote into the config file.
I am not getting any data from my arduino client although i am connected to my wifi correctly. Maybe there is an issue with the arduino tcp client. I just want to make sure that OH is configured correctly so i can look for the problems at the right place.
do you send the packet from arduino side? or do you Need polling?
if the string is already formed as you’d like from your arduino, just type “default” (and temperature should be a Number, if you’d like to work with it
be aware, that items, which are not declared properly won’t show in the UI, you’re missing the label, in your case it would be something like String WoZi_String_Temperatur "Wohnzimmertemperatur [%s]" {tcp="<[127.0.0.1:80:default]"}, but if you have an integer already: Number WoZi_Integer_Temperatur "Wohnzimmertemperatur [%.1f °C]" {tcp="<[127.0.0.1:80:default]"}
The ip address in the binding paprameters needs to be the tcp server. ie: where the data is published, your arduino. Is your arduino set-up as a tcp server?
There are much easier and more reliable ways to send data from a nodeMCU.
MQTT comes to mind…
use the pubsubclient library for arduino
Install mosquitto on your openHAB computer
Install the mqtt binding in OH
Hello!
Thanks a lot for your replies!
I thought that i can create a TCP server with the OH 2 binding. I did not know that the server has to be the arduino.
I am open minded for every way to get the data transfer working and i will take a deep look at MQTT! Thanks a lot!
MQTT is arguably the best way to get data from arduino to OH
See this thread:
That’s for OH and the mqtt broker installation
On the arduino side, you need to use the pubsubclient library (Other flavours available). It is available in the arduino IDE library downloads and comes with examples
Follows the link above especially the MQTT essentials to understand how MQTT works (Simple really)
Read the docs, read them again and when you have finished read them one more time.
I’ll second MQTT. In the long run you will have far more capability for far less effort compared to trying to roll your own low level protocol using TCP/UDP.