I'd like to do a project, here is the description: if the smartphone is away from home for a certain distance, the heaters at home should be switched off. The purpose is to save energy.
Hardware needed: android smartphone, Raspberry Pi, motor.
It's generally composed of three parts:
1. App calculates the distance between current location and home. If the distance is beyond the range, a bool variable is true, otherwise false.
2. Raspberry Pi (a small computer running on Linux OS) is at home, it's connected to the Internet and acts as a controller. If the variable is true, then motor shuts down the heater. Otherwise keeps the heater on.
3.Communication between the smartphone and the Raspberry Pi.
Regarding to the third part, my question is about the communication protocol. It's a point to point communication. Is that TCP/IP protocol over Internet? Does App Inventor have such block access to the network?
Thank you for your suggestions!
There are potential issues with your project
1) AI2 apps can not run in the background. Unless the app is continuously on by using 'tricks' your AI2 built app can not communicate with you mini computer.
2) AI2 can communicate with Bluetooth devices (at least some of them). Can you control the PI with Bluetooth?
3) AI2 does not have the ability to do TCIP.
Someone in the forum's was attempting to use his Android to open a garage door ... you might search and see if you can find that thread. I think he was using an arduino controller.
Good news, your item #1 is easy with the LocationSensor and if you write an algorithm to do Haversine with blocks ... doable.
Visit here frequently, someone might have other ideas.
thanks very much! It's pity that AI2 apps couldn't run in background and doesn't support TCP/IP.
Via the bluetooth I've done a small project. I can control a Lego car with my smartphone.
Hardware: Lego car, two small DC-motors, one bluetooth module as a receiver, Arduino Mega microcontroller.
Software: AI1 app, small control software for Arduino.
In that app an accelerometer war used for sensing the tilting angle of the smartphone. If the smartphone is tilting to the left side, then a number is transmitted via Bluetooth. The Bluetooth module receives that number, then send that number to Arduino via serial communication. The Arduino is running a small if-else programm. Depending on the received value, it decides what to do: drive the two motors in the same direction, in the different direction, or do not drive. It's open loop, doesn't have a sensor to measure the speed.
I came to this idea from the internet, Someone has done similar things, using an app to control a motor's speed and direction. Maybe some other open source software support TCPIP protocol. Thanks for mentioning the garage project, I've take a look.
Other free Android compilers (that will support TCIP I believe) are the Java based Eclipse and Android Studio Professional compilers. It is more difficult to program with those two compilers, however they are more flexible, have better layout controls and have large libraries of routines available. However, you will have to learn to program in Java.
Programming Lego is built into AI2, the components are there, just no TCIP.
댓글 없음:
댓글 쓰기