External ADC with Raspberry Pi.

           Really I tried a lot with MCP3208 external ADC to interface with the Raspberry pi. Searched for various codes but nothing was available in JAVA. So after some research i got some python code and modified that to JAVA.  in this i have used the Pi4J library. /*****Author : Bikash Narayan Panda*Use : This is used to read ADC data foem the MCP3208 SPI based ADC.*Date :19/Nov/2014*Tags: Please Include the Pi4J Library.****/import java.io.IOException;import com.pi4j.io.gpio.GpioController;import com.pi4j.io.gpio.GpioFactory;import com.pi4j.io.gpio.GpioPinDigitalInput;import com.pi4j.io.gpio.GpioPinDigitalOutput;import com.pi4j.io.gpio.PinPullResistance;import com.pi4j.io.gpio.PinState;import com.pi4j.io.gpio.RaspiPin;public class SensorTest {    public static int readadc(int adcnum, GpioPinDigitalOutput…

Read More

Modify your old PC SMPS to BenchTop Power Supply Unit

Many time we do have old SMPS of no use to the computers. Those SMPS can be modified as bench-top power supply system providing -12,+12,+5,+3.3 volts. I have used one to power my all arduino based home automation modules and the Raspberry Pi. Here  i am going to post how to mod an old SMPS . You just need following components along with some  basic tools                                              1.Screw Terminals.                                             2.Switch (On/Off).                                             3.10Watt Resistive load (May be 5K or 10K i have used 4.7K working fine)

Read More

Using Raspberry Pi Serial Port

             By default the Raspberry Pi’s serial port is configured to be used for console input/output, it means you can’t use the Serial Port in your programs and  needs to be disabled.To enable the serial port for your own use you need to disable login on the port. There are two files that need to be edited The first and main one is                     /etc/inittab This file has the command to enable the login prompt and this needs to be disabled. Edit the file and move to the end…

Read More

Algotithm to Convert 4 byte Hex to 32 bit float

 I really struggled hard to find out some sorts of algorithm to convert 4 hex bytes to 32 bit float for my requirement on some analysis of MODBUS protocol. I didn’t find it and it tok me nearly 2 days to design this. Here is the algorithm.. float ModbusRead(byte id,byte msbAddress,byte lsbAddress,byte msbCrc,byte lsbCrc){ num=1.00; Serial.write(id); Serial.write(0x03); Serial.write((byte)msbAddress); Serial.write((byte)lsbAddress); Serial.write((byte)0x00); Serial.write(0x02); Serial.write(msbCrc); Serial.write(lsbCrc); delay(1000); for(i=0;i<9;i++) { if(!Serial.available()) { for (int x=0;x < 9;x++) { reply[x]=0x00; } while(Serial.available()){} break; } reply[i]=Serial.read(); } while(Serial.available()){} if((reply[3] & 0x80)!=0) num=num*-1; reply[3]=reply[3]<<1; if((reply[4] & 0x80)!=0x00)…

Read More

Running particular application when Rspberry Pi boots up

              While using Raspberry Pi you might not be interested to take  a mouse and keyboard to run certain application when the Pi reboots. To avoid this many procedures are available . In this post i have used crontab to run a JAVA based application each time the Pi reboots. Actually crontab provides many more features. First login to your pi. Change yourself to root user. Command is  sudo -s After that to edit the crontab type crontab -e At the beginning of the file append  @reboot /usr/bin/java -classpath /home/pi/:/home/pi/Desktop/DisplayOne_lib/*.jar…

Read More

Run GUI based application on raspberry Pi Startup

          Belief me i went through several websites and tested many proposals to run my JAVA based GUI application on Raspberry Pi start-up. Finally the following worked out First check inside the .config folder if it contains autostart folder or not , if not then create a folder named as autostart. Create a myApp.desktop file inside the autostart folder.The myApp.desktop file should contain the following [Desktop Entry]Encoding=UTF-8Typr=ApplicationName=ndscomment=Exec=sudo /usr/bin/java -classpath /home/pi/:/home/pi/Desktop/Display_lib/*.jar -jar /home/pi/Desktop/Display.jarStartupNotify=falseTerminal=falseHidden=-false Thats all reboot your pi and your application should run now….. You can also…

Read More

Power Over Ethernet (For Ethernet Connected Devices)

         Power Over Ethernet is a widely used concept to power up remote devices like Arduino, Raspberry pi or any other embedded devices working on low voltage and power.There are ready made modules available in the market but are expensive so in this tutorial i will show you to make the cable modified to work for POE.           Ethernet cable uses 4 pairs of wires but out of them only 2 pairs are used and the remaining are unused so those can be used to carry power to the end…

Read More

Cheap Ethernet connection to Arduino using ENC28J60 module

      While working on Ethernet projects with Arduino the basic hardware we require along with Arduino is the Ethernet Shield. But the problem is that in a constrained budget the buying one Ethernet Shield is not possible which leads to other options and a good one is ENC28J60 Ethernet chip by Microchip.This is not as smart as the Wiznet W5100 chip based Ethernet shields but are quite useful as those.This post i am going to write all about interfacing the ENC28J60 module to Arduino UNO as well as Arduino mini…

Read More

Room temperatuer logger using arduino and JAVA

 This post is all about a temperature logger module using two sensors(LM35) and uses serial communication to log data to MySQL server. And it does so by using Arduino at the logger end and JAVA at the server.   The concept is so simple that the Arduino uses LM35 (providing analog output for measured temperature) ,which is connected to one of the analogIn pin of Arduino. The sketch burned to Arduino converts the read value from the pin to corresponding temperature. And it sends the data through the serial port.…

Read More

Control VLC Player using Android (Wifi Connected)

    My first application of Android comes here.In my first tutorial on Controlling VLC using JAVA you can see that the VLC provides a Web interface from which it can be controlled and it also accepts certain commands.So that can be used to control the media player in Local Area Network using any programming language.This time its Android Code: MainActivity.Java package com.example.first_app;import java.net.Authenticator;import java.net.URL;import android.os.Build;import android.os.Bundle;import android.os.StrictMode;import android.annotation.SuppressLint;import android.annotation.TargetApi;import android.app.Activity;import android.content.Intent;import android.graphics.Color;import android.view.Menu;import android.view.View;import android.widget.Button;import android.widget.SeekBar;import android.widget.SeekBar.OnSeekBarChangeListener;import android.widget.TextView;public class MainActivity extends Activity { @TargetApi(Build.VERSION_CODES.GINGERBREAD) @SuppressLint(“NewApi”) @Override protected void onCreate(Bundle…

Read More