AVR Microcontroller temp sensor communication over LAN - java

Hello infinitely more skilled people than me ;-),
I have a question for my Brothers School project and I want to help him.
He has a micro-controller board with a LAN port and wants to attach a temperature Reader to it.
Has anyone a Suggestion on How to communicate this data let's say for example to an Android app that can Display the temperature graph or just the temp at the current Moment?
If not Android he wants to Display it via a Java app on a desktop that displays a temp graph and average temps.
I tried to Google it but I haven't found anything that describes this case. Maybe I don't know how to formulate it.
I know it super vague to describe it but maybe some nice guy can send me code example how it would look like, since I am a total beginner.
Here is the AVR board (it has a LAN port)
http://www.pollin.de/shop/dt/MTQ5OTgxOTk-/Bausaetze_Module/Bausaetze/Bausatz_AVR_NET_IO.html
Thank you :)
Thanks and have a nice day :)

As far as I can see, the board features an ATmega32 controller and an ENC28J60 Ethernet controller (with SPI!).
It seems they provide some sort of server application that communicates with the board (via Ethernet/LAN). The app is not trivial, as I see it also has firmware update feature (so the AVR chip has also a bootloader in its flash).
Anyway, an interesting approach would be to connect your temperature sensor on one analog input, then start the board and the net-server app (connected to LAN). You'll see the related measurements on some ADCx (in Volts).
After that, using Wire-Shark or similar tool, you could spy the communication messages between the board and the server (knowing their IPs, to filter out all other crap lurking on the LAN).
Next step would be to find out the specific message server sends to request the ADCx, and also the related answer from the board. Not trivial, yet doable I guess :)
Finally, knowing what messages are exchanged (I here assume you don't have the specs for the protocol or the source code), you should replicate/implement something similar in your Windows/Android application (further conversion from voltage to °C temperature to be displayed is yet another thing to be done by your app - the easiest part, I suppose :).
With the data you provided, I think this is the best suggestion I can make.
Best luck with your project!
BTW: Best place where you can find help (and source code examples, compilers and related stuff) for AVR is: www.avrfreaks.net

Did you see the software and firmware that comes with the board (download...)?
It pretty much has everything you'd need, i.e. TCP/IP stack, simple command/response server to access digital and analog IOs &c.
See the documentation: https://www.pollin.de/shop/downloads/D810058B.PDF, esp. "Protokollaufbau und Kommandos AVR-NET-IO", e.g. "GETADC 3 (ruft den akt. Wert des ADC-Eingangs 3 ab)"
Hence, you should be able to use the stock firmware and talk to it from your app/whatever via simple commands over TCP. You can query the boards input states and do any calculations on that in the app before displaying the result.
(Edit: You did not state what kind of sensor he wants to use. If the sensor's output is not an analog voltage but some digital protocol, the stock firmware in fact won't get you far.)
The boards firmware is written in C (closed source, I believe), but as I said, you'd probably not have to bother with that. However, if you want, there are alternative firmware versions available as open source from the 'net; and if you're inclined to a greater experience, you can also create your own, possibly building on an available TCP/IP stack and ENC28J60 libraries (readily available too). You could also add a simple HTTP server on top of that &c, &c.
Some links that instantly turned up when I googled for "avr net io firmware":
http://www.fhemwiki.de/wiki/AVR-NET-IO
http://engelhuber.de/blog/2013/10/29/pollin-avr-net-io-mit-e2000-firmware-ueber-php-ansteuern/
http://netio.davideickhoff.de/de/
http://son.ffdf-clan.de/

Related

Is there a way to create keyboard macros through an android app?

First of all, I am extremely new to coding and I just learned the basics of java. I want to do an android app as my first project. The idea of the app would be to have buttons on your phone which would work as keyboard macros. I was wondering if I also needed to create specific windows drivers for it or if I could just make it run on the default windows keyboard drivers? As I said I am super new to all of this (about 10hrs of programming experience), so feel free to correct me and educate me as much as you want! I won't take it personally, I'm looking to learn :)
You would need to set up some sort of communication between the app and your PC. You wouldn't need to do anything with the keyboard drivers. Java has something called the "Robot class" which allows you to simulate a keypress.
Here is the documentation on the robot class: https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html
As for the communications, you will need to create a server/client connection. One of your devices will act as the client (probably your phone) and one will act as the server (probably your PC).
This is just a rough idea of how it would work but:
When you tap the button on your phone, it would send some specified data to your server that is running on your PC. You should set the data that gets sent from the client to the server as the key(s) keycode that you would like it to simulate so it will be easier to implement. When the server gets data from the client, it should send that data to the robot.keypress(data) function.
This honestly sounds like it will be a big project for your skill level but I wish you the best of luck on this. This will probably be a frustrating experience but don't let it get the better of you.

How to communicate with a device?

I am a web programmer and I am just wondering how software and hardware can communicate. I have basic knowledge in Java but I am not an expert.
Let's make it simple. I have a device which is just a simple lamp that can get switched on and off and it is connected via USB. My software has only one function - pressing enter.
By pressing enter I want the software to communicate with the USB port and tell it to activate the device. How would that be possible? Where do I have to start and what do I need to learn?
I understand that my question and my example sound silly but I am just trying to understand how it works.
I appreciate any help!
I think that if you using arduino or other prototyping board you might use rxtx serial library.
If I answer simply, then I should tell, you need to have microcontroller to do this by your own.
A microcontroller is a small computer on a single integrated circuit. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable input/output peripherals. So, there are input, output pins for different operations you want to do with your physical hardware and also a memory to store the commands or program. That means a microcontroller is a third party which keeps communication active between the hardware and software in this case.
In the market, you can find many microcontroller integrated boards for building digital devices and interactive objects that can sense and control objects in the physical world.
To make your work easy as a beginner, I suggest you to buy an arduino board from the market. If you google it and search for arduino tutorials in youtube, you will find how they work. Hope these help you.

how to use java sockets to connect to an online server

I have spent some time learning Java and in doing so have built myself a rather complex game. My game is a desktop ran swing app which after play results in a score value that gets entered onto a leaderboard. The game is pretty much complete, except a few security mechanisms.
At first I never intended to have my game connected to the net as the phrase 'networking' has always put me off. Now that my game has slowly developed, it has actually turned out far better than I had imagined which has kinda twisted my arm into wanting to learn how to network.
After lots of research into the subject, I decided to have a look into sockets and build myself a simple client/socket server. Both programs connected on my local machine which has bought me here.
I already know that allowing the client to send the score to the server is always vulnerable to cheats, but originally this game was never intended for online score posting. Instead I have decided to make my game code so damn unreadable and messy that it may just be easier to cheat/crack someone elses program. (wishful thinking).
This game is only a learning curve, so abuse of the score system in my eyes will only serve to teach.
My questions may seem silly, but its only trying to get a fuller understanding.
I'm wanting to use a socket to send a number, lets say 2371 from my desktop game to a java server that is hosted on a random webserver. I then want the java server to find the position of this players score (2371) and then print the score on a website leaderboard.
Is it really as simple as adjusting the code URL and then uploading the socketServer code to webhosting space?
If it is, what am I uploading..... a .java file, or any other?
I have also read many times in my research that alot of webhosts dont allow the uploading of java files with open ports. Is this correct?
Many thanks guys, this is a subject that I have always steered clear of, so all and any advice would be appreciated.
What you need is a computer on the internet that can run a process (your Java server application), that your Java client applications can connect to. So you would upload the file(s) (maybe it's a jar, or some class files), and tell the server through whatever interface you have to run the process. This server application can then hold everyone's scores and save them to disk and whatever else you need.
I have also read many times in my research that alot of webhosts dont allow the uploading of java files with open ports. Is this correct?
This is correct. You'll need to rent a server (if you don't have one yourself that you can put on your own internet connection), a simple web hosting companies will not allow you to host your own running process.
Instead I have decided to make my game code so damn unreadable and messy that it may just be easier to cheat/crack someone elses program. (wishful thinking).
I'm not sure if this a joke but there's source code obfuscators out there like ProGuard which do exactly this.
If you really want to protect against people simply writing scores out to the server with their own modified client then you'll have to have some of the logic of the game be handled by the server process itself. Of course someone could still go further and create a bot or whatever else they need to cheat and get their bogus score listed.

communication project using android

i'm doin my project in 8th sem telecomm engineering, and i'm plannin to create a DUPLEX(not confident whether it'd be full or half) communication app using bluetooth and wifi as channels,something more advanced than a simple walkie talkie, and i was wondering if this is possible for a one man army??? also i was wondering if it is possible to do so with android versions 2.2 and above... can i just program the bluetooth settings in app in such a way, that, it doesn't pop up for user permission to accept a voice message from the calling party??
and is there a possibility for creating multiple channels(one for Forward Voice Channel and one for Reverse Voice Channel) using bluetooth or wifi?? here's a list of few knowledge i possess:
JAVA: basics, done some gui in desktops, know some imp classes,only SE6...
WIRELESS COMMUNICATION: learning it this semester, stuff like how base station accepts incoming mobile station request and redirects it to dest, mostly 1g in our portions...
OPERATING SYSTEMS: general, looking forward to learning android and linux os...
C,C++,DSP,and SOME ELECTRONICS...
oh, and iwoul like to implement these well within 7 months duration...
people please ENLIGTHEN me with your wisdom and references to useful websites ASAP...
my THANKS AND WISHES to thee...:)
The first big problem i see is that on using wifi for this, and as i understood it is some sort of (advanced) walkie-talkie app with no rooter inbetween the communicating phones, you have to implement adhoc-wlan on your android device, which is not supported by android, so you will need a rooted device for that, and the implementation of adhoc-wlan on android is definitve possible (have a look at this code: http://code.google.com/p/android-wifi-tether/) but nothing easy (i have done it myself for an university project).
And you asked if you can avoid the permission pop-up for an incoming message, but on an android phone activating your bluetooth or pairing it with an other device will always ask for permission from the user.
I cant help about the multiple channels you were asking for.
As Answer to your big Question: "is it possible for a one man army?" i would say generelly yes, but it depends on how much other stuff you have to do. Since you were writing this is an project for university, i dont know if this is your only project and you can invest a lot of time in it. If so i guess it is possible, but it will be an quite big project and you should be willing to work yourself relativly deep into networking stuff.
On google.Code you can find some projects similar (at least the wifi part) to what you think about to do, take a look at them...

Make a USB Device, Control It In Java

I'm thinking about making a physical controller (device?) with knobs, buttons, and LEDs. I'd like to interact with it using Java (respond to the knobs, light up LEDs, etc). The reason I mention Java is two-fold: first, I know Java well1. Second, I've written the rest of the program I need to interface with in Java (though there are ways to talk to the Java program from another language).
I would like the device to connect via USB and be (computer-)platform independent.
I haven't the slightest idea of where to start, except to start reading the Arduino website. Is this my best/only option? Is there something better suited for communicating with Java?
Note: I know that Arduino has something to do with Java (not sure what), but it seems like code must be written in a subset of C.
How would I get moving on this topic?
1 - No laughter, please.
The Arduino development environment is written in Java.
But the standard language you write a program for the Arduino platform is effectively C++.
The Arduino platform is based on an Atmel AVR chip. There is at least one Java VM for AVR chips. There are other languages available for the AVR such as Forth and BASIC (although I could only find commercial versions, so I'll if you want to find them, search for "AVR BASIC").
The Arduino uses a virtual COM port to communicate between the host computer and it. A virtual COM port emulates an old style serial line but is done with USB. You can use the Java communication API to then have a Java program running on the host computer communicate with your physical device.
For some encoders and buttons, you probably want to implement a USB HID device. If you're going to produce more than a couple of them, you'll want to do a custom board. Check out V-USB, an open-source library for making USB HID devices using Atmel microcontrollers. They have a bunch of examples of projects that use this library.
You could probably make this look like a HID joystick, using the encoders to produce X/Y axis information and having the buttons act like buttons. They you could use standard Java gaming APIs to read the joystick values.
Can you expand on your need for a custom device? It seems to me that designing hardware has a pretty high barrier to entry and that most applications I can think of would be better resolved by repurposing an existing piece of game controller hardware. If you really need new hardware, then i suggest you start by googling 'USB development kit' or
'USB development board' which will get you links like this, this and this.
As for working with USB hardware from Java, I've played around with the JUSB library a bit and it looks promising, but appears to be limited to Linux only because the Windows version of the native library half of the library hasn't been written. Alternatives can by found by googling 'HID java'.
Ok, computer-platform independant? What platforms are you targetting? That would depend on the driver and support for that said platform, what does the usb device do? Is it a mass storage device...You may have to look around and see if you can find a device driver that can talk to the device...
Hope this helps,
Best regards,
Tom.
I know for the serial port there were libraries that existed for interacting with it (rs232 library). Googling for java and USB returned several answers (the first was called jUSB). That would be the first type of thing I would be looking for.
sample for java usb connection to freescale microcontroller:
http://javausbapi.blogspot.com/

Categories

Resources