+3 votes

Is it possible for Godot apps running in Android to communicate with an Arduino via local wifi?
Or do I need to install 3rd party libraries for that?

I have a school project and I'm trying to create a program an app that gets information from an Arduino device, illustrating a graph of information/data/recordings from the Arduino device itself, and I don't know where to start. Where should I start?

thank you in advance for responding

asked Aug 3, 2019 in Engine by Mike Trevor (18 points)

2 Answers

+2 votes
Best answer

I quite succesfully managed to do this with PacketPeerUDP,
I had a rather complex network of arduinos all connected together. One had either wifi / ethernet shield attached (it didnt matter which) and was designated master.
The Master arduino would monitor devices joining / leaving this network and report back to the godot app which devices were connected and allow basic messages to be sent back to the arduinos.
Godot side is very simple, Arduino side was basic UDP listener example.

extends Node
var UdpSocket = PacketPeerUDP.new()
var port = 9000
var ip = ""
func _process(delta):
    if UdpSocket.get_available_packet_count() > 0:
        var array_bytes = UdpSocket.get_packet()
        print("Server says "+array_bytes.get_string_from_ascii())
func setupUDP():
    if (UdpSocket.listen(port) != OK):
        print("Error listening on port: " + str(port))
        print("Listening on port: " + str(port))
func sendData(data):
    if UdpSocket.is_listening():
        UdpSocket.set_dest_address(ip, port)
        var pac = data.to_ascii()
        print("send data via UDP! "+data)
answered Aug 4, 2019 by Squatnet (200 points)
selected Aug 5, 2019 by Mike Trevor
0 votes

Godot provides network functions so it should be possible.

answered Aug 3, 2019 by BraindeadBZH (1,015 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.