Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] creating IoT apps

Author
Message
vertigon
4
Years of Service
User Offline
Joined: 22nd Jun 2019
Location:
Posted: 22nd Jun 2019 23:25
hi so i grabbed the basic thing during the free steam weekend, figured i would do something with it eventually. are there any tutorials or other resources available for how to make an app that can send and receive small packets of data from the local wifi or bluetooth, say display a reading from a weather station or control an led strip? kinda-sorta-basically recreate the blynk app, but specfic to whatever project? i know its possible but im so new i dont even know what parts i still need to learn. im getting pretty good at the hardware part, sensors, microcontrollers, etc, but i need a better way to interface with them, just basic gui level stuff, in theory i could make things all html and use browsers, but that can complicate things as it cant connect to the device and the internet at the same time. id rather learn more and have a better looking app when im done. maybe somebody could even just break down the basic flow i should be looking at? endgoal i guess is make a phone app as the remote contoller for an R/C car or tank with an esp8826-01 or similar on it

The author of this post has marked a post as an answer.

Go to answer

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Jun 2019 11:38
Sending packets via sockets is very easy and is just a case of opening the socket and then sending a packet. You can then use AppGameKit to control a ESP8266 or A raspberry PI or arduiono using standard methods. Ive done this and its not too hard.

You have no control over bluetooth communication though (No SPP side channel). This isnt built into AppGameKit at all.

You can also send HTTP commands if you want to run your IOT device as a web host with either HTTP or FTP commands.


In the case of controlling a ESP8266 , write the custom ocde to connect to a wifi access point then check for incoming packets on a port...if you recieve a valid command then control your output pins etc... This all occurs on the ESP8266.

All you have to do in AppGameKit is attampt to open a socket to the device...you need to know the device IP address and then you connect to it and send a packet.
xtremi
5
Years of Service
User Offline
Joined: 26th Aug 2018
Location:
Posted: 25th Jun 2019 14:10
This post has been marked by the post author as the answer.
@Bengismo, do you have by any chance some example code of how you interfaced the ESP8266 with AppGameKit?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 26th Jun 2019 08:55
Its the code you need to run on the ESP8266 or on the microprocessor that is the much harder bit.

The code that you need to write in AppGameKit is very simple. Its the same code you would write to connect to another PC using sockets.

You create a socket connection to the ESP8266 device:

sid = ConnectSocket( szIP$, 8080, 3000 )
szIP$ = "192.168.0.37"
<- this has to be the IP address of the ESP8266 device
You can get this manually by hardcoding it on the ESP8266 or by using MDNS or a proprietary multicasting or even checking your local router for IP's

Check that it connects ok and if it has, then send a packet if a key is pressed

if GetRawKeyPressed(87) and GetSocketConnected(sid)

// Create a packet
SendSocketByte(sid,20) // start byte
SendSocketByte(sid,dataval) // data value could be whether to turn on an LED or set PWM value etc....
SendSocketByte(sid,dataval2)
SendSocketByte(sid,checksum)
FlushSocket(sid)
endif



This would then send a packet of data (just 4bytes in this case) to the ESP8266. It can then interpret this packet however you want to depending on what code you have written on the module itself. Most of the work is writing the code to run on the ESP8266 device itself to interpret packets of data to do something useful like turn on a relay or set a LED colours etc.... The ESP8266 can have the standard AT firmware on it or custom code written by a user so its on that device where most of the work is. Its the same with most IOT devices. Sending HTTP requests is another way and you use the HTTP commands to do that.
xtremi
5
Years of Service
User Offline
Joined: 26th Aug 2018
Location:
Posted: 26th Jun 2019 09:29
Thanks Bengismo, that's very useful.

I've used the ESP8266 to transfer data to/from Android and Raspberry using MQTT. But now I'll probably try to connect to an AppGameKit app with direct TCP connection.

Login to post a reply

Server time is: 2024-03-29 00:57:30
Your offset time is: 2024-03-29 00:57:30