Android Question n.1 rs232 server ==>> n.X rs232 client - via internet communication

amorosik

Well-Known Member
Licensed User
I have a device, a weighing scale with rs232 output
In several different geographical places (therefore not connectable via cable) there are led numeric displays that must show information such as when it is produced by the scale
I would like to connect the 'producer' scale to the 'user' display using common Android smartphones, with otg cable and usb to rs232 converter, both on the scale side and on the display side
Basically I would like to create a system that simulates a cable and obtains the same effects that would be obtained by physically connecting the tx pin of the rs232 balances with the rx pins of the numerous displays.
What code to use to acquire the information from the source rs232, transmit it using the telephone data network, and emit it on numerous rs232 recipients?

BILANCIA_RS232_TEL_TO_DISPLAY.jpg
 
Last edited:

hatzisn

Well-Known Member
Licensed User
Assuming that they will be always in a WiFi enabled place I would use first an app in each receiver phone that updates a no-ip account every time it "senses" a change in the external IP (to be able to call it from outside). I would create a port forwarding from each local router to the receiver phone (which should have a static IP in the local WLAN) and in which you would select the ports of communication and I would handle communication this way. Actually I have created a class which handles two way communication (if you want it or one way if you choose so) for B4X apps over the Internet in different ports defined by you. If you want it for a fair price for what it does send me a private message in Messenger (as seen in the signature of this message). See this thread to see the use of this class: https://www.b4x.com/android/forum/threads/dhqi-video-voicer.123093/
 
Last edited:
Upvote 0

amorosik

Well-Known Member
Licensed User
No, it is not possible to use no-ip or similar services, because the phones come out on the internet with their telephone module, and their wan ip addresses are of type 10.xxx therefore like a local network, and are not reachable from the external
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Thinkabout mqtt for the comunication between the Devices

I 'll second that. Further more you don't have to pay at all for MQTT service. Just use a Ruspberry Pi as a server (again with the same solution - no-ip) with a B4J MQTT broker and connect to it from the outside phones. The RasPi has to be in the weighting scale place.
 
Upvote 0

LucaMs

Expert
Licensed User
Upvote 0

amorosik

Well-Known Member
Licensed User
This is probably your local network. You probably need to do that on the router and add portforwarding to the device

No, is not an office lan
There is no router on the schema, each smartphone connects to the internet using its own telephone module
 
Upvote 0

amorosik

Well-Known Member
Licensed User
Thinkabout mqtt for the comunication between the Devices

It would mean having a 'third' system in addition to the sender phone and recipient phones
If it is absolutely essential to do so, I will adopt this possibility
I would first like to see if there is a way to do what is required without using systems other than those illustrated in the example diagram
 
Upvote 0

amorosik

Well-Known Member
Licensed User
I 'll second that. Further more you don't have to pay at all for MQTT service. Just use a Ruspberry Pi as a server (again with the same solution - no-ip) with a B4J MQTT broker and connect to it from the outside phones. The RasPi has to be in the weighting scale place.

No, the problem is not the mqtt server on pc or Raspberry or on smartphone
The problem is that that mqtt server, if connected to the internet using a mobile device, will NOT be traceable from the internet as most of the telephony operators make the ip wan of mobile device connections fall within classes of lan private of type 10.xx .. and these addresses are not accessible from the internet
 
Last edited:
Upvote 0

hatzisn

Well-Known Member
Licensed User

Hey Luca, come va? The jMQTTBroker2 is based on Moqeute 0.12 and is not compatible with B4A. Version one will have to be used but it will have to be runnning in a foreground service which will restart every 30 minutes otherwise it might be killed. Another possibility is to KeepAwake the phone and run it wherever he wants within the app.

 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Very bad; the reason? I am still alive 😄:confused:
I hope you are all well.

I don't know what to say regarding this statement. Maybe you should talk to a friend and share with him your concerns. We Greeks say: "a shared pain is half a pain and a shared joy is a double joy".
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
@amorosik the way MQTT works is that outside devices connect to the MQTT server. The connection is kept alive constantly. There is no concern whether it is a mobile data connection or a WiFi connection (for the clients). If your server (weighting scale) is in WiFi then no concerns. The mobile companies for security reasons do not allow incoming connections to the mobile phones (for the common mortal people only 😂 😂 😂 ) but outgoing connections are definetelly allowed.
 
Upvote 0
Top