Archive

Author Archive

STM32 USB Connection

January 25th, 2010 8 comments

The USB connection between the STM32 and the computer is finally working.
I’ve tried the different USB programs from the StdPeriph Library

Fx.

  • Virtual COM Port
  • DFU Programming

As I’m using Ride7 for programming, I can upload the project and sources if you want me too.

 

OBS: If you have projects which DOESN’T use the USB, you have to set the USB Disconnect jupmer to Ground (Pos. 1-2), as if not, the STM32 will stop in some kind of USB Interrupt trying to make a data communication with the computer, but it never comes as the STM32 doesn’t start one!

I discovered this Ã? when I tried DFU’ing my 320×240 LCD code – and when I went back to normal .hex, it didn’t work – that was because I had to set the USB Disconnect to Ground!

Categories: ARM Tags: , , ,

WiFi SMS Gateway

September 5th, 2009 10 comments

After a long search on the internet, trying to find a cheap SMS Gateway, I got the idea to create one myself.
As I already had a GM862 module laying around, and I’ve got the WiShield WiFi module for the Arduino too, I thought it would be easy – but it wasn’t!

The hardware setup is pretty easy, except the powering for the GM862, as it requires about 3.8V. That was made with a Linear LT1528 3A low dropout voltage regulator.
After alot of testing and measuring, I finally made a working circuit, and afterwards an Eagle Schematic.

WiFi SMS Gateway - Schematic

WiFi SMS Gateway - Schematic

� 

In the following picture you will see the hardware setup, which consists of the Arduino with the WiShield on the top, the GM862 on two breadboards, and alot of wires!

WiFi SMS Gateway - Hardware

WiFi SMS Gateway - Hardware

� 

But the real problems appeared when I started programming! I had alot of troubles with the serial connection between the Arduino and the GM862 module, which apparently wasn’t caused by the hardware setup!

� 
After alot of debugging I figured it out, and a simple SMS sending code was working 🙂
Then after a couple of hours I’ve added the WiFi parsing code which sends an SMS to the requested number, with the requested message, read from the GET parameters!

You can grab the code here, and try it out:

/*
 * WiFi SMS Gateway sketch by Thomas Jespersen - http://elec.tkjweb.dk/blog
 * --- Remeber to change the PIN, if any, in the setup() routine! ---
 */

#include <WiServer.h>

#define WIRELESS_MODE_INFRA	1
#define WIRELESS_MODE_ADHOC	2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,111};	// IP address of WiShield
unsigned char gateway_ip[] = {192,168,2,254};	// router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};	// subnet mask for the local network
const prog_char ssid[] PROGMEM = {"SSID"};		// max 32 bytes


unsigned char security_type = 0;	// 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"Passphrase"};	// max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,	// Key 0
				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	// Key 1
				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,	// Key 2
				  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00	// Key 3
				};

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------

//unsigned byte TimeBeforeConnection;

unsigned int lastSMStime = 0;

   char number[7];
   char* message;

void sendSMS() {
  if (millis()/1000 > lastSMStime) {
    Serial.print("AT+CMGF=1\r\n");
    delay(500);
    Serial.print("AT+CMGS=");
    delay(250);
    for (int i=0; i < 8; i++) {
      Serial.print(number[i]);
    }
    //Serial.print(number);
    // Replace with a valid phone number
    Serial.print("\r\n");
    delay(2500);
    Serial.print(message);
    delay(500);

    // End the SMS with a control-z
    Serial.print(0x1A,BYTE);
    lastSMStime = (millis()/1000) + 2;
  }
}

// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {

    // Check if the requested URL matches "/"
    if (strcmp(URL, "/") == 0) {
        // Use WiServer's print and println functions to write out the page content
        WiServer.print("<html>");
        WiServer.print("<head><title>TKJ's SMS Gateway</title>");
        WiServer.print("<h1>This is TKJ's SMS Gateway</h1><br>");
        WiServer.print("</html>");

        // URL was recognized
        return true;
    }

    // Check if the requested URL starts with "/?"
    if (URL[0] == '/' && URL[1] == '?') {
        for (int i=0; i<8; i++) {
          number[i] = '0';
        }
        message = "";

        for (int i=0; i < 8; i++) {
          number[i] = URL[i+2];
        }
        for (int i=0; i < strlen(URL); i++) {
          message[i] = URL[i+10];
        }

        // Use WiServer's print and println functions to write out the page content
        WiServer.print("<html>");
        WiServer.print("<head><title>TKJ's SMS Gateway</title>");
        WiServer.print("<h1>The SMS is now sent!</h1><br><p>");
        //WiServer.print(message);
        WiServer.print("</p>");
        WiServer.print("</html>");

        sendSMS();

        // URL was recognized
        return true;
    }

    // URL not found
    return false;
}

void setup() {
  // Turn GSM Module ON
  pinMode(3, OUTPUT);
  digitalWrite(3, HIGH);
  delay(500);
  digitalWrite(3, LOW);
  delay(500);
  digitalWrite(3, HIGH);
  delay(1000);

  // Type Mobile SIM Pin Code
  Serial.begin(9600);
  // Remember to change the PIN, if any
  Serial.print("AT+CPIN=0000\r\n");

  // Initialize WiServer and have it use the sendMyPage function to serve pages
  WiServer.init(sendMyPage);

  // Enable Serial output and ask WiServer to generate log messages (optional)
  WiServer.enableVerboseMode(false);

}

void loop(){

  // Run WiServer
  WiServer.server_task();
  delay(10);
}


Categories: Arduino Tags: , , , , ,

RFID Modded Safe

June 20th, 2009 3 comments

This project is about my RFID Modded Safe.

I’ve modded an old electronic toy-safe, which is unlocked by typing the 4-char password.

RFID Modded Safe

RFID Modded Safe

I’ve unsoldered the locking-mechanism from the circuitboard, and connected it to the Arduino instead.

Locking-Mechanism Hack

Locking-Mechanism Hack

Then I connected a ID-20 RFID Reader to the Arduino and programmed it to read the tag, and see if it was allowed to enter the safe.

ID-20 RFID Reader

ID-20 RFID Reader

If it was allowed, the Arduino will keep the safe unlocked in 3 seconds!

I’ve also made this video to show how it works:
httphd://www.youtube.com/watch?v=oxuD–7wWE8

You can grab the code here, and try it out:

#include <NewSoftSerial.h>

NewSoftSerial ID12(5,6);
//                RX,TX

// RFID reader ID-12 for Arduino
// Based on code by BARRAGAN
// and code from HC Gilje - http://hcgilje.wordpress.com/resources/rfid_id12_tagreader/
// Modified for Arudino by djmatic
// Modified for ID-12 and checksum by Martijn The - http://www.martijnthe.nl/
//
// Use the drawings from HC Gilje to wire up the ID-12.
// Remark: disconnect the rx serial wire to the ID-12 when uploading the sketch


void setup() {
  Serial.begin(9600);                                 // connect to the serial port
  ID12.begin(9600);
  pinMode(12, OUTPUT);
}

void loop () {
  byte i = 0;
  byte val = 0;
  byte code[6];
  byte checksum = 0;
  byte bytesread = 0;
  byte tempbyte = 0;

  if(ID12.available() > 0) {
    if((val = ID12.read()) == 2) {                  // check for header
      bytesread = 0;
      while (bytesread < 12) {                        // read 10 digit code + 2 digit checksum
        if( ID12.available() > 0) {
          val = ID12.read();
          if((val == 0x0D)||(val == 0x0A)||(val == 0x03)||(val == 0x02)) { // if header or stop bytes before the 10 digit reading
            break;                                    // stop reading
          }

          // Do Ascii/Hex conversion:
          if ((val >= '0') && (val <= '9')) {
            val = val - '0';
          } else if ((val >= 'A') && (val <= 'F')) {
            val = 10 + val - 'A';
          }

          // Every two hex-digits, add byte to code:
          if (bytesread & 1 == 1) {
            // make some space for this hex-digit by
            // shifting the previous hex-digit with 4 bits to the left:
            code[bytesread >> 1] = (val | (tempbyte << 4));

            if (bytesread >> 1 != 5) {                // If we're at the checksum byte,
              checksum ^= code[bytesread >> 1];       // Calculate the checksum... (XOR)
            };
          } else {
            tempbyte = val;                           // Store the first hex digit first...
          };

          bytesread++;                                // ready to read next digit
        }
      }

      // Output to Serial:

      if (bytesread == 12) {                          // if 12 digit read is complete
        Serial.print("5-byte code: ");
        for (i=0; i<5; i++) {
          if (code[i] < 16) Serial.print("0");
          Serial.print(code[i], HEX);
          Serial.print(" ");
        }
        Serial.println();

        Serial.print("Checksum: ");
        Serial.print(code[5], HEX);
        Serial.println(code[5] == checksum ? " -- passed." : " -- error.");
        Serial.println();

        if (code[0] == 0x01 && code[1] == 0x07 && code[2] == 0x7A && code[3] == 0x21 && code[4] == 0xD9 && code[5] == checksum) {
          Serial.println("Case Unlocked by User1");
          digitalWrite(12, HIGH);
          delay(3000);
          Serial.println("Case Locked");
          digitalWrite(12, LOW);
        }
        if (code[0] == 0x01 && code[1] == 0x07 && code[2] == 0x7A && code[3] == 0x1A && code[4] == 0xBA && code[5] == checksum) {
          Serial.println("Case Unlocked by User2");
          digitalWrite(12, HIGH);
          delay(3000);
          Serial.println("Case Locked");
          digitalWrite(12, LOW);
        }
      }

      bytesread = 0;
    }
  }
}

Categories: Arduino Tags: , , , , , , ,

Ethernet TV

After my last success with the Serial TV, I’ve got the idea making it possible for you to the television using a browser.

I’m still using my Serial TV, but now it’s connected to an Arduino instead of the computer. The Arduino has an Ethernet Shield on top, and it’s programmed to make a homepage with a text-field and a submit button!

Here is some pictures of the project:

Ethernet TV - Full

Ethernet TV - Full


Ethernet TV - Arduino

Ethernet TV - Arduino


Ethernet TV - iphone

Ethernet TV - iphone


Ethernet TV - iphone + TV

Ethernet TV - iphone + TV


Ethernet TV - Test Text

Ethernet TV - Test Text

Categories: Arduino, PIC Tags: , , ,

Serial PAL TV

Finally I’ve finished my Serial TV project.
It uses a PIC18F4620 running 32 Mhz (8 Mhz crystal + HS PLL), so I’m using the EasyPIC5 for the testing. It is also possible to use other PIC’s, but the available TV Pixel lines will be reduced, caused by the limited RAM.

First I’m going to give alot of the credit to Bruno from Micro-Examples, as I’ve used his PAL TV Code: http://www.micro-examples.com/public/microex-navig/doc/089-pic-pal-tv

Then I’ve wrote some extra code, to make it possible, to write text strings to the television, via a serial communication.

You can download the MikroC project here: Serial TV – MikroC

Here is some pictures of the project:

Serial TV - EasyPIC5

Serial TV - EasyPIC5


Composite Video Resistor Array

Composite Video Resistor Array


Serial TV - Test Text

Serial TV - Test Text

Categories: PIC Tags: , ,

Ethernet DMX

March 25th, 2009 15 comments

Last week I recieved the Arduino Ethernet Shield – http://www.arduino.cc/en/Main/ArduinoEthernetShield
There were all ready complete examples provided, so it was very easy to get started.
Then I thought it would be nice to have a Ethernet DMX Controller, so i could type the IP-Adress of the Ethernet Shield in explorer, and from there control my movinghead (Stairville MV250H). 

Then I found this page showing how to use an MAX485 and the Arduino as a DMX interface – http://iad.projects.zhdk.ch/physicalcomputing/hardware/arduino/dmx-shield-fur-arduino/
I tried it, and it worked 🙂 – And the Arduino could communicate with my movinghead.

Then I combined the Ethernet example and the DMX example, to make a HTML Page where i could click on different buttons to change the DMX values that would be sent to my movinghead.
Try it out yourself… You need a MAX485, follow the link above on how to connect it to the Arduino. Just use pin 3 instead of pin 11, as the Ethernet shield uses Pin 9 to 13!

Read more…

Categories: Arduino Tags: , ,

We are looking for article-writers

January 27th, 2009 No comments

At the moment we are only two adminstrators who also writes the articles.
We would like to have other electronics-interested to write some articles here on the TKJ Electronics blog.

Simon, the other adminstrator has got a Graphical Designer to make us a new layout, which would be published when it’s finished!

But please write a comment to this post if you would like to help us.

SD Card and EEPROM 24FC1025

January 27th, 2009 No comments

Yesterday i started my development with Microchips 24FC1025 EEPROM.
I have successfully connected one 24FC1025 to the PIC16F877A, but i will try and connect 4 of them, which is the maximum.

I’ve also got my SD Card holder soldered so i could use it. I’ve connected the SD Card to the PIC18F452 and made some code in mikroBasic, using their SD library. I’ve successfully made a logging code, and a piture manager.

24FC1025 EEPROM <-> PIC

24FC1025 EEPROM PIC


SD <-> PIC

SD PIC

Categories: PIC Tags: , , ,

TKJ Electronics is here

January 25th, 2009 No comments

Finally TKJ Electronics is here.

My name is Thomas Jespersen, and I’m going to tell and teach you a lot about different electronic projects, including the PIC (Microchip).

But right now this blog is quite empty, but take a look at mikroElektronika’s forum

Categories: TKJ Electronics Tags: